diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2020-04-19 17:19:32 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2020-04-19 17:19:32 -0400 |
| commit | c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78 (patch) | |
| tree | ee4d51c7c1d633e11f46453ef1edd3c77c4ef9f7 /Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Activation/ActivationMixerPlayable.cs | |
| download | Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.tar.gz Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.tar.bz2 Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.zip | |
Inital commit
Diffstat (limited to 'Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Activation/ActivationMixerPlayable.cs')
| -rw-r--r-- | Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Activation/ActivationMixerPlayable.cs | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Activation/ActivationMixerPlayable.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Activation/ActivationMixerPlayable.cs new file mode 100644 index 0000000..61054f7 --- /dev/null +++ b/Library/PackageCache/com.unity.timeline@1.2.13/Runtime/Activation/ActivationMixerPlayable.cs @@ -0,0 +1,71 @@ +using UnityEngine.Playables; + +namespace UnityEngine.Timeline +{ + class ActivationMixerPlayable : PlayableBehaviour + { + ActivationTrack.PostPlaybackState m_PostPlaybackState; + bool m_BoundGameObjectInitialStateIsActive; + + private GameObject m_BoundGameObject; + + + public static ScriptPlayable<ActivationMixerPlayable> Create(PlayableGraph graph, int inputCount) + { + return ScriptPlayable<ActivationMixerPlayable>.Create(graph, inputCount); + } + + public ActivationTrack.PostPlaybackState postPlaybackState + { + get { return m_PostPlaybackState; } + set { m_PostPlaybackState = value; } + } + + public override void OnPlayableDestroy(Playable playable) + { + if (m_BoundGameObject == null) + return; + + switch (m_PostPlaybackState) + { + case ActivationTrack.PostPlaybackState.Active: + m_BoundGameObject.SetActive(true); + break; + case ActivationTrack.PostPlaybackState.Inactive: + m_BoundGameObject.SetActive(false); + break; + case ActivationTrack.PostPlaybackState.Revert: + m_BoundGameObject.SetActive(m_BoundGameObjectInitialStateIsActive); + break; + case ActivationTrack.PostPlaybackState.LeaveAsIs: + default: + break; + } + } + + public override void ProcessFrame(Playable playable, FrameData info, object playerData) + { + if (m_BoundGameObject == null) + { + m_BoundGameObject = playerData as GameObject; + m_BoundGameObjectInitialStateIsActive = m_BoundGameObject != null && m_BoundGameObject.activeSelf; + } + + if (m_BoundGameObject == null) + return; + + int inputCount = playable.GetInputCount(); + bool hasInput = false; + for (int i = 0; i < inputCount; i++) + { + if (playable.GetInputWeight(i) > 0) + { + hasInput = true; + break; + } + } + + m_BoundGameObject.SetActive(hasInput); + } + } +} |
