From c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sun, 19 Apr 2020 17:19:32 -0400 Subject: Inital commit --- .../Runtime/Activation/ActivationTrack.cs | 93 ++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Activation/ActivationTrack.cs (limited to 'Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Activation/ActivationTrack.cs') diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Activation/ActivationTrack.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Activation/ActivationTrack.cs new file mode 100644 index 0000000..8e06ddb --- /dev/null +++ b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Activation/ActivationTrack.cs @@ -0,0 +1,93 @@ +using System; +using UnityEngine.Playables; + +namespace UnityEngine.Timeline +{ + /// + /// Track that can be used to control the active state of a GameObject. + /// + [Serializable] + [TrackClipType(typeof(ActivationPlayableAsset))] + [TrackBindingType(typeof(GameObject))] + [ExcludeFromPreset] + public class ActivationTrack : TrackAsset + { + [SerializeField] + PostPlaybackState m_PostPlaybackState = PostPlaybackState.LeaveAsIs; + ActivationMixerPlayable m_ActivationMixer; + + /// + /// Specify what state to leave the GameObject in after the Timeline has finished playing. + /// + public enum PostPlaybackState + { + /// + /// Set the GameObject to active. + /// + Active, + + /// + /// Set the GameObject to Inactive. + /// + Inactive, + + /// + /// Revert the GameObject to the state in was in before the Timeline was playing. + /// + Revert, + + /// + /// Leave the GameObject in the state it was when the Timeline was stopped. + /// + LeaveAsIs + } + + internal override bool CanCompileClips() + { + return !hasClips || base.CanCompileClips(); + } + + /// + /// Specifies what state to leave the GameObject in after the Timeline has finished playing. + /// + public PostPlaybackState postPlaybackState + { + get { return m_PostPlaybackState; } + set { m_PostPlaybackState = value; UpdateTrackMode(); } + } + + /// + public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount) + { + var mixer = ActivationMixerPlayable.Create(graph, inputCount); + m_ActivationMixer = mixer.GetBehaviour(); + + UpdateTrackMode(); + + return mixer; + } + + internal void UpdateTrackMode() + { + if (m_ActivationMixer != null) + m_ActivationMixer.postPlaybackState = m_PostPlaybackState; + } + + /// + public override void GatherProperties(PlayableDirector director, IPropertyCollector driver) + { + var gameObject = GetGameObjectBinding(director); + if (gameObject != null) + { + driver.AddFromName(gameObject, "m_IsActive"); + } + } + + /// + protected override void OnCreateClip(TimelineClip clip) + { + clip.displayName = "Active"; + base.OnCreateClip(clip); + } + } +} -- cgit v1.2.3