TextSwitcherTrack.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using UnityEngine;
  2. using UnityEngine.Playables;
  3. using UnityEngine.Timeline;
  4. using System.Collections.Generic;
  5. using UnityEngine.UI;
  6. [TrackColor(0.1394896f, 0.4411765f, 0.3413077f)]
  7. [TrackClipType(typeof(TextSwitcherClip))]
  8. [TrackBindingType(typeof(Text))]
  9. public class TextSwitcherTrack : TrackAsset
  10. {
  11. public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
  12. {
  13. return ScriptPlayable<TextSwitcherMixerBehaviour>.Create (graph, inputCount);
  14. }
  15. public override void GatherProperties (PlayableDirector director, IPropertyCollector driver)
  16. {
  17. #if UNITY_EDITOR
  18. Text trackBinding = director.GetGenericBinding(this) as Text;
  19. if (trackBinding == null)
  20. return;
  21. var serializedObject = new UnityEditor.SerializedObject (trackBinding);
  22. var iterator = serializedObject.GetIterator();
  23. while (iterator.NextVisible(true))
  24. {
  25. if (iterator.hasVisibleChildren)
  26. continue;
  27. driver.AddFromName<Text>(trackBinding.gameObject, iterator.propertyPath);
  28. }
  29. #endif
  30. base.GatherProperties (director, driver);
  31. }
  32. }