A game about forced loneliness, made by TACStudios
1#if TEXT_TRACK_REQUIRES_TEXTMESH_PRO 2 3using TMPro; 4using UnityEngine; 5using UnityEngine.Playables; 6using UnityEngine.Timeline; 7 8namespace Timeline.Samples 9{ 10 // A track that allows the user to change Text parameters from a Timeline. 11 // It demonstrates the following 12 // * How to support blending of timeline clips. 13 // * How to change data over time on Components that is not supported by Animation. 14 // * Putting properties into preview mode. 15 // * Reacting to changes on the clip from the Timeline Editor. 16 // Note: This track requires the TextMeshPro package to be installed in the project. 17 [TrackColor(0.1394896f, 0.4411765f, 0.3413077f)] 18 [TrackClipType(typeof(TextPlayableAsset))] 19 [TrackBindingType(typeof(TMP_Text))] 20 public class TextTrack : TrackAsset 21 { 22 // Creates a runtime instance of the track, represented by a PlayableBehaviour. 23 // The runtime instance performs mixing on the timeline clips. 24 public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount) 25 { 26 return ScriptPlayable<TextTrackMixerBehaviour>.Create(graph, inputCount); 27 } 28 29 // Invoked by the timeline editor to put properties into preview mode. This permits the timeline 30 // to temporarily change fields for the purpose of previewing in EditMode. 31 public override void GatherProperties(PlayableDirector director, IPropertyCollector driver) 32 { 33 TMP_Text trackBinding = director.GetGenericBinding(this) as TMP_Text; 34 if (trackBinding == null) 35 return; 36 37 // The field names are the name of the backing serializable field. These can be found from the class source, 38 // or from the unity scene file that contains an object of that type. 39 driver.AddFromName<TMP_Text>(trackBinding.gameObject, "m_text"); 40 driver.AddFromName<TMP_Text>(trackBinding.gameObject, "m_fontSize"); 41 driver.AddFromName<TMP_Text>(trackBinding.gameObject, "m_fontColor"); 42 43 base.GatherProperties(director, driver); 44 } 45 } 46} 47 48#endif