Files
Dec2017-Script-Dump/UnityEngine.Timeline/Timeline/AnimationOutputWeightProcessor.cs
T
2026-06-04 11:42:34 +02:00

111 lines
3.5 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine.Animations;
using UnityEngine.Playables;
namespace UnityEngine.Timeline
{
// Token: 0x02000024 RID: 36
internal class AnimationOutputWeightProcessor : ITimelineEvaluateCallback
{
// Token: 0x06000150 RID: 336 RVA: 0x00006E12 File Offset: 0x00005012
public AnimationOutputWeightProcessor(AnimationPlayableOutput output)
{
this.m_Output = output;
this.FindMixers();
}
// Token: 0x06000151 RID: 337 RVA: 0x00006E34 File Offset: 0x00005034
private void FindMixers()
{
this.m_Mixers.Clear();
this.m_LayerMixer = AnimationLayerMixerPlayable.Null;
Playable sourcePlayable = this.m_Output.GetSourcePlayable<AnimationPlayableOutput>();
int sourceInputPort = this.m_Output.GetSourceInputPort<AnimationPlayableOutput>();
if (sourcePlayable.IsValid<Playable>() && sourceInputPort >= 0 && sourceInputPort < sourcePlayable.GetInputCount<Playable>())
{
Playable input = sourcePlayable.GetInput(sourceInputPort).GetInput(0);
if (input.IsValid<Playable>() && input.IsPlayableOfType<AnimationLayerMixerPlayable>())
{
this.m_LayerMixer = (AnimationLayerMixerPlayable)input;
int inputCount = this.m_LayerMixer.GetInputCount<AnimationLayerMixerPlayable>();
for (int i = 0; i < inputCount; i++)
{
this.FindMixers(this.m_LayerMixer, i, this.m_LayerMixer.GetInput(i));
}
}
}
}
// Token: 0x06000152 RID: 338 RVA: 0x00006F10 File Offset: 0x00005110
private void FindMixers(Playable parent, int port, Playable node)
{
if (node.IsValid<Playable>())
{
Type playableType = node.GetPlayableType();
if (playableType == typeof(AnimationMixerPlayable) || playableType == typeof(AnimationLayerMixerPlayable))
{
int inputCount = node.GetInputCount<Playable>();
for (int i = 0; i < inputCount; i++)
{
this.FindMixers(node, i, node.GetInput(i));
}
AnimationOutputWeightProcessor.WeightInfo weightInfo = new AnimationOutputWeightProcessor.WeightInfo
{
parentMixer = parent,
mixer = node,
port = port,
modulate = (playableType == typeof(AnimationLayerMixerPlayable))
};
this.m_Mixers.Add(weightInfo);
}
else
{
int inputCount2 = node.GetInputCount<Playable>();
for (int j = 0; j < inputCount2; j++)
{
this.FindMixers(parent, port, node.GetInput(j));
}
}
}
}
// Token: 0x06000153 RID: 339 RVA: 0x00007000 File Offset: 0x00005200
public void Evaluate()
{
for (int i = 0; i < this.m_Mixers.Count; i++)
{
AnimationOutputWeightProcessor.WeightInfo weightInfo = this.m_Mixers[i];
float num = ((!weightInfo.modulate) ? 1f : weightInfo.parentMixer.GetInputWeight(weightInfo.port));
weightInfo.parentMixer.SetInputWeight(weightInfo.port, num * WeightUtility.NormalizeMixer(weightInfo.mixer));
}
this.m_Output.SetWeight(WeightUtility.NormalizeMixer(this.m_LayerMixer));
}
// Token: 0x04000096 RID: 150
private AnimationPlayableOutput m_Output;
// Token: 0x04000097 RID: 151
private AnimationLayerMixerPlayable m_LayerMixer;
// Token: 0x04000098 RID: 152
private readonly List<AnimationOutputWeightProcessor.WeightInfo> m_Mixers = new List<AnimationOutputWeightProcessor.WeightInfo>();
// Token: 0x02000025 RID: 37
private struct WeightInfo
{
// Token: 0x04000099 RID: 153
public Playable mixer;
// Token: 0x0400009A RID: 154
public Playable parentMixer;
// Token: 0x0400009B RID: 155
public int port;
// Token: 0x0400009C RID: 156
public bool modulate;
}
}
}