scripts
This commit is contained in:
@@ -0,0 +1,355 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine.Playables;
|
||||
|
||||
namespace UnityEngine.Timeline
|
||||
{
|
||||
// Token: 0x0200002D RID: 45
|
||||
[NotKeyable]
|
||||
[Serializable]
|
||||
public class ControlPlayableAsset : PlayableAsset, IPropertyPreview, ITimelineClipAsset
|
||||
{
|
||||
// Token: 0x060001A1 RID: 417 RVA: 0x0000849D File Offset: 0x0000669D
|
||||
public void OnEnable()
|
||||
{
|
||||
if (this.particleRandomSeed == 0U)
|
||||
{
|
||||
this.particleRandomSeed = (uint)Random.Range(1, ControlPlayableAsset.k_MaxRandInt);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000087 RID: 135
|
||||
// (get) Token: 0x060001A2 RID: 418 RVA: 0x000084BC File Offset: 0x000066BC
|
||||
public override double duration
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_Duration;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000088 RID: 136
|
||||
// (get) Token: 0x060001A3 RID: 419 RVA: 0x000084D8 File Offset: 0x000066D8
|
||||
public ClipCaps clipCaps
|
||||
{
|
||||
get
|
||||
{
|
||||
return ClipCaps.ClipIn | ClipCaps.SpeedMultiplier | ((!this.m_SupportLoop) ? ClipCaps.None : ClipCaps.Looping);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060001A4 RID: 420 RVA: 0x00008504 File Offset: 0x00006704
|
||||
public override Playable CreatePlayable(PlayableGraph graph, GameObject go)
|
||||
{
|
||||
List<Playable> list = new List<Playable>();
|
||||
GameObject gameObject = this.sourceGameObject.Resolve(graph.GetResolver());
|
||||
if (this.prefabGameObject != null)
|
||||
{
|
||||
Transform transform = ((!(gameObject != null)) ? null : gameObject.transform);
|
||||
ScriptPlayable<PrefabControlPlayable> scriptPlayable = PrefabControlPlayable.Create(graph, this.prefabGameObject, transform);
|
||||
gameObject = scriptPlayable.GetBehaviour().prefabInstance;
|
||||
list.Add(scriptPlayable);
|
||||
}
|
||||
this.UpdateDurationAndLoopFlag(gameObject);
|
||||
Playable playable;
|
||||
if (gameObject == null)
|
||||
{
|
||||
playable = Playable.Create(graph, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayableDirector component = go.GetComponent<PlayableDirector>();
|
||||
if (component != null)
|
||||
{
|
||||
this.m_ControlDirectorAsset = component.playableAsset;
|
||||
}
|
||||
if (go == gameObject && this.prefabGameObject == null)
|
||||
{
|
||||
Debug.LogWarning("Control Playable (" + base.name + ") is referencing the same PlayableDirector component than the one in which it is playing.");
|
||||
this.active = false;
|
||||
if (!this.searchHierarchy)
|
||||
{
|
||||
this.updateDirector = false;
|
||||
}
|
||||
}
|
||||
if (this.active)
|
||||
{
|
||||
this.CreateActivationPlayable(gameObject, graph, list);
|
||||
}
|
||||
if (this.updateDirector)
|
||||
{
|
||||
this.SearchHierarchyAndConnectDirector(gameObject, graph, list);
|
||||
}
|
||||
if (this.updateParticle)
|
||||
{
|
||||
this.SearchHiearchyAndConnectParticleSystem(gameObject, graph, list);
|
||||
}
|
||||
if (this.updateITimeControl)
|
||||
{
|
||||
this.SearchHierarchyAndConnectControlableScripts(gameObject, graph, list);
|
||||
}
|
||||
Playable playable2 = this.ConnectPlayablesToMixer(graph, list);
|
||||
playable = playable2;
|
||||
}
|
||||
return playable;
|
||||
}
|
||||
|
||||
// Token: 0x060001A5 RID: 421 RVA: 0x0000867C File Offset: 0x0000687C
|
||||
private Playable ConnectPlayablesToMixer(PlayableGraph graph, List<Playable> playables)
|
||||
{
|
||||
Playable playable = Playable.Create(graph, playables.Count);
|
||||
for (int num = 0; num != playables.Count; num++)
|
||||
{
|
||||
this.ConnectMixerAndPlayable(graph, playable, playables[num], num);
|
||||
}
|
||||
playable.SetPropagateSetTime(true);
|
||||
return playable;
|
||||
}
|
||||
|
||||
// Token: 0x060001A6 RID: 422 RVA: 0x000086D0 File Offset: 0x000068D0
|
||||
private void CreateActivationPlayable(GameObject root, PlayableGraph graph, List<Playable> outplayables)
|
||||
{
|
||||
ScriptPlayable<ActivationControlPlayable> scriptPlayable = ActivationControlPlayable.Create(graph, root, this.postPlayback);
|
||||
if (scriptPlayable.IsValid<ScriptPlayable<ActivationControlPlayable>>())
|
||||
{
|
||||
outplayables.Add(scriptPlayable);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060001A7 RID: 423 RVA: 0x00008704 File Offset: 0x00006904
|
||||
private bool SearchHiearchyAndConnectParticleSystem(GameObject root, PlayableGraph graph, List<Playable> outplayables)
|
||||
{
|
||||
bool flag;
|
||||
if (root == null)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag2 = false;
|
||||
foreach (ParticleSystem particleSystem in this.GetParticleSystems(root))
|
||||
{
|
||||
if (particleSystem != null)
|
||||
{
|
||||
flag2 = true;
|
||||
outplayables.Add(ParticleControlPlayable.Create(graph, particleSystem, this.particleRandomSeed));
|
||||
}
|
||||
}
|
||||
flag = flag2;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x060001A8 RID: 424 RVA: 0x000087A0 File Offset: 0x000069A0
|
||||
private void SearchHierarchyAndConnectDirector(GameObject root, PlayableGraph graph, List<Playable> outplayables)
|
||||
{
|
||||
if (!(root == null))
|
||||
{
|
||||
foreach (PlayableDirector playableDirector in this.GetDirectors(root))
|
||||
{
|
||||
if (playableDirector != null)
|
||||
{
|
||||
if (playableDirector.playableAsset != this.m_ControlDirectorAsset)
|
||||
{
|
||||
outplayables.Add(DirectorControlPlayable.Create(graph, playableDirector));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060001A9 RID: 425 RVA: 0x00008840 File Offset: 0x00006A40
|
||||
private void SearchHierarchyAndConnectControlableScripts(GameObject root, PlayableGraph graph, List<Playable> outplayables)
|
||||
{
|
||||
if (!(root == null))
|
||||
{
|
||||
foreach (MonoBehaviour monoBehaviour in this.GetControlableScripts(root))
|
||||
{
|
||||
outplayables.Add(TimeControlPlayable.Create(graph, (ITimeControl)monoBehaviour));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060001AA RID: 426 RVA: 0x000088C0 File Offset: 0x00006AC0
|
||||
private void ConnectMixerAndPlayable(PlayableGraph graph, Playable mixer, Playable playable, int portIndex)
|
||||
{
|
||||
graph.Connect<Playable, Playable>(playable, 0, mixer, portIndex);
|
||||
mixer.SetInputWeight(playable, 1f);
|
||||
}
|
||||
|
||||
// Token: 0x060001AB RID: 427 RVA: 0x000088DC File Offset: 0x00006ADC
|
||||
private IEnumerable<ParticleSystem> GetParticleSystems(GameObject gameObject)
|
||||
{
|
||||
if (gameObject != null)
|
||||
{
|
||||
ParticleSystem particleSystem = gameObject.GetComponent<ParticleSystem>();
|
||||
if (particleSystem != null)
|
||||
{
|
||||
yield return particleSystem;
|
||||
}
|
||||
else if (this.searchHierarchy)
|
||||
{
|
||||
int count = gameObject.transform.childCount;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
IEnumerable<ParticleSystem> childPS = this.GetParticleSystems(gameObject.transform.GetChild(i).gameObject);
|
||||
foreach (ParticleSystem ps in childPS)
|
||||
{
|
||||
yield return ps;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
// Token: 0x060001AC RID: 428 RVA: 0x00008910 File Offset: 0x00006B10
|
||||
private IEnumerable<PlayableDirector> GetDirectors(GameObject gameObject)
|
||||
{
|
||||
if (gameObject != null)
|
||||
{
|
||||
if (this.searchHierarchy)
|
||||
{
|
||||
PlayableDirector[] directors = gameObject.GetComponentsInChildren<PlayableDirector>(true);
|
||||
foreach (PlayableDirector d in directors)
|
||||
{
|
||||
yield return d;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayableDirector director = gameObject.GetComponent<PlayableDirector>();
|
||||
if (director != null)
|
||||
{
|
||||
yield return director;
|
||||
}
|
||||
}
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
// Token: 0x060001AD RID: 429 RVA: 0x00008944 File Offset: 0x00006B44
|
||||
private IEnumerable<MonoBehaviour> GetControlableScripts(GameObject root)
|
||||
{
|
||||
if (root == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
foreach (MonoBehaviour script in root.GetComponentsInChildren<MonoBehaviour>())
|
||||
{
|
||||
if (script is ITimeControl)
|
||||
{
|
||||
yield return script;
|
||||
}
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
// Token: 0x060001AE RID: 430 RVA: 0x00008970 File Offset: 0x00006B70
|
||||
private void UpdateDurationAndLoopFlag(GameObject gameObject)
|
||||
{
|
||||
this.m_Duration = PlayableBinding.DefaultDuration;
|
||||
this.m_SupportLoop = false;
|
||||
if (!(gameObject == null))
|
||||
{
|
||||
List<PlayableDirector> list = this.GetDirectors(gameObject).ToList<PlayableDirector>();
|
||||
List<ParticleSystem> list2 = this.GetParticleSystems(gameObject).ToList<ParticleSystem>();
|
||||
if (list.Count == 1 && list2.Count == 0 && list[0].playableAsset != null)
|
||||
{
|
||||
this.m_Duration = list[0].playableAsset.duration;
|
||||
this.m_SupportLoop = list[0].extrapolationMode == DirectorWrapMode.Loop;
|
||||
}
|
||||
else if (list.Count == 0 && list2.Count == 1)
|
||||
{
|
||||
this.m_Duration = (double)list2[0].main.duration;
|
||||
this.m_SupportLoop = list2[0].main.loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060001AF RID: 431 RVA: 0x00008A6C File Offset: 0x00006C6C
|
||||
public void GatherProperties(PlayableDirector director, IPropertyCollector driver)
|
||||
{
|
||||
GameObject gameObject = this.sourceGameObject.Resolve(director);
|
||||
if (gameObject != null)
|
||||
{
|
||||
if (this.updateParticle)
|
||||
{
|
||||
foreach (ParticleSystem particleSystem in this.GetParticleSystems(gameObject))
|
||||
{
|
||||
driver.AddFromName<ParticleSystem>(particleSystem.gameObject, "randomSeed");
|
||||
driver.AddFromName<ParticleSystem>(particleSystem.gameObject, "autoRandomSeed");
|
||||
}
|
||||
}
|
||||
if (this.active)
|
||||
{
|
||||
driver.AddFromName(gameObject, "m_IsActive");
|
||||
}
|
||||
if (this.updateITimeControl)
|
||||
{
|
||||
foreach (MonoBehaviour monoBehaviour in this.GetControlableScripts(gameObject))
|
||||
{
|
||||
IPropertyPreview propertyPreview = monoBehaviour as IPropertyPreview;
|
||||
if (propertyPreview != null)
|
||||
{
|
||||
propertyPreview.GatherProperties(director, driver);
|
||||
}
|
||||
else
|
||||
{
|
||||
driver.AddFromComponent(monoBehaviour.gameObject, monoBehaviour);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x040000BF RID: 191
|
||||
private static readonly int k_MaxRandInt = 10000;
|
||||
|
||||
// Token: 0x040000C0 RID: 192
|
||||
[SerializeField]
|
||||
public ExposedReference<GameObject> sourceGameObject;
|
||||
|
||||
// Token: 0x040000C1 RID: 193
|
||||
[SerializeField]
|
||||
public GameObject prefabGameObject;
|
||||
|
||||
// Token: 0x040000C2 RID: 194
|
||||
[SerializeField]
|
||||
public bool updateParticle = true;
|
||||
|
||||
// Token: 0x040000C3 RID: 195
|
||||
[SerializeField]
|
||||
public uint particleRandomSeed;
|
||||
|
||||
// Token: 0x040000C4 RID: 196
|
||||
[SerializeField]
|
||||
public bool updateDirector = true;
|
||||
|
||||
// Token: 0x040000C5 RID: 197
|
||||
[SerializeField]
|
||||
public bool updateITimeControl = true;
|
||||
|
||||
// Token: 0x040000C6 RID: 198
|
||||
[SerializeField]
|
||||
public bool searchHierarchy = true;
|
||||
|
||||
// Token: 0x040000C7 RID: 199
|
||||
[SerializeField]
|
||||
public bool active = true;
|
||||
|
||||
// Token: 0x040000C8 RID: 200
|
||||
[SerializeField]
|
||||
public ActivationControlPlayable.PostPlaybackState postPlayback = ActivationControlPlayable.PostPlaybackState.Revert;
|
||||
|
||||
// Token: 0x040000C9 RID: 201
|
||||
private PlayableAsset m_ControlDirectorAsset;
|
||||
|
||||
// Token: 0x040000CA RID: 202
|
||||
private double m_Duration = PlayableBinding.DefaultDuration;
|
||||
|
||||
// Token: 0x040000CB RID: 203
|
||||
private bool m_SupportLoop;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user