112 lines
3.2 KiB
C#
112 lines
3.2 KiB
C#
using System;
|
|
using UnityEngine.Playables;
|
|
|
|
namespace UnityEngine.Timeline
|
|
{
|
|
// Token: 0x02000034 RID: 52
|
|
public class DirectorControlPlayable : PlayableBehaviour
|
|
{
|
|
// Token: 0x060001C8 RID: 456 RVA: 0x00009520 File Offset: 0x00007720
|
|
public static ScriptPlayable<DirectorControlPlayable> Create(PlayableGraph graph, PlayableDirector director)
|
|
{
|
|
ScriptPlayable<DirectorControlPlayable> scriptPlayable;
|
|
if (director == null)
|
|
{
|
|
scriptPlayable = ScriptPlayable<DirectorControlPlayable>.Null;
|
|
}
|
|
else
|
|
{
|
|
ScriptPlayable<DirectorControlPlayable> scriptPlayable2 = ScriptPlayable<DirectorControlPlayable>.Create(graph, 0);
|
|
scriptPlayable2.GetBehaviour().director = director;
|
|
scriptPlayable = scriptPlayable2;
|
|
}
|
|
return scriptPlayable;
|
|
}
|
|
|
|
// Token: 0x060001C9 RID: 457 RVA: 0x00009564 File Offset: 0x00007764
|
|
public override void PrepareFrame(Playable playable, FrameData info)
|
|
{
|
|
if (!(this.director == null) && this.director.isActiveAndEnabled && !(this.director.playableAsset == null))
|
|
{
|
|
if (this.director.playableGraph.IsValid())
|
|
{
|
|
int rootPlayableCount = this.director.playableGraph.GetRootPlayableCount();
|
|
for (int i = 0; i < rootPlayableCount; i++)
|
|
{
|
|
Playable rootPlayable = this.director.playableGraph.GetRootPlayable(i);
|
|
if (rootPlayable.IsValid<Playable>())
|
|
{
|
|
rootPlayable.SetSpeed((double)info.effectiveSpeed);
|
|
}
|
|
}
|
|
}
|
|
if (info.evaluationType == FrameData.EvaluationType.Evaluate)
|
|
{
|
|
if (Application.isPlaying)
|
|
{
|
|
this.director.Pause();
|
|
}
|
|
this.UpdateTime(playable);
|
|
this.director.Evaluate();
|
|
}
|
|
else if (Application.isPlaying)
|
|
{
|
|
if (playable.GetTime<Playable>() < this.director.time)
|
|
{
|
|
this.UpdateTime(playable);
|
|
}
|
|
this.director.Play();
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x060001CA RID: 458 RVA: 0x00009694 File Offset: 0x00007894
|
|
public override void OnBehaviourPlay(Playable playable, FrameData info)
|
|
{
|
|
if (this.director != null && this.director.playableAsset != null)
|
|
{
|
|
this.UpdateTime(playable);
|
|
this.director.Evaluate();
|
|
this.director.Play();
|
|
}
|
|
}
|
|
|
|
// Token: 0x060001CB RID: 459 RVA: 0x000096E8 File Offset: 0x000078E8
|
|
public override void OnBehaviourPause(Playable playable, FrameData info)
|
|
{
|
|
if (this.director != null && this.director.playableAsset != null)
|
|
{
|
|
this.director.Stop();
|
|
}
|
|
}
|
|
|
|
// Token: 0x060001CC RID: 460 RVA: 0x00009720 File Offset: 0x00007920
|
|
private void UpdateTime(Playable playable)
|
|
{
|
|
double num = Math.Max(0.1, this.director.playableAsset.duration);
|
|
DirectorWrapMode extrapolationMode = this.director.extrapolationMode;
|
|
if (extrapolationMode != DirectorWrapMode.Hold)
|
|
{
|
|
if (extrapolationMode != DirectorWrapMode.Loop)
|
|
{
|
|
if (extrapolationMode == DirectorWrapMode.None)
|
|
{
|
|
this.director.time = playable.GetTime<Playable>();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.director.time = Math.Max(0.0, playable.GetTime<Playable>() % num);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.director.time = Math.Min(num, Math.Max(0.0, playable.GetTime<Playable>()));
|
|
}
|
|
}
|
|
|
|
// Token: 0x040000D7 RID: 215
|
|
public PlayableDirector director;
|
|
}
|
|
}
|