summaryrefslogtreecommitdiff
path: root/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Window/TimelineWindow_PlayableLookup.cs
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2020-04-19 17:19:32 -0400
committerAndrew Lee <alee14498@protonmail.com>2020-04-19 17:19:32 -0400
commitc55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78 (patch)
treeee4d51c7c1d633e11f46453ef1edd3c77c4ef9f7 /Library/PackageCache/com.unity.timeline@1.2.13/Editor/Window/TimelineWindow_PlayableLookup.cs
downloadProject-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/Editor/Window/TimelineWindow_PlayableLookup.cs')
-rw-r--r--Library/PackageCache/com.unity.timeline@1.2.13/Editor/Window/TimelineWindow_PlayableLookup.cs79
1 files changed, 79 insertions, 0 deletions
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Window/TimelineWindow_PlayableLookup.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Window/TimelineWindow_PlayableLookup.cs
new file mode 100644
index 0000000..fbb3648
--- /dev/null
+++ b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Window/TimelineWindow_PlayableLookup.cs
@@ -0,0 +1,79 @@
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.Playables;
+using UnityEngine.Timeline;
+
+namespace UnityEditor.Timeline
+{
+ partial class TimelineWindow
+ {
+ PlayableLookup m_PlayableLookup = new PlayableLookup();
+
+ class PlayableLookup
+ {
+ const int k_InitialDictionarySize = 10;
+
+ readonly Dictionary<AnimationClip, Playable> m_AnimationClipToPlayable =
+ new Dictionary<AnimationClip, Playable>(k_InitialDictionarySize);
+ readonly Dictionary<AnimationClip, TimelineClip> m_AnimationClipToTimelineClip =
+ new Dictionary<AnimationClip, TimelineClip>(k_InitialDictionarySize);
+
+ public void UpdatePlayableLookup(TimelineClip clip, GameObject go, Playable p)
+ {
+ if (clip == null || go == null || !p.IsValid())
+ return;
+
+ if (clip.curves != null)
+ m_AnimationClipToTimelineClip[clip.curves] = clip;
+
+ UpdatePlayableLookup(clip.parentTrack.timelineAsset, clip, go, p);
+ }
+
+ public void UpdatePlayableLookup(TrackAsset track, GameObject go, Playable p)
+ {
+ if (track == null || go == null || !p.IsValid())
+ return;
+
+ UpdatePlayableLookup(track.timelineAsset, track, go, p);
+ }
+
+ void UpdatePlayableLookup(TimelineAsset timelineAsset, ICurvesOwner curvesOwner, GameObject go, Playable p)
+ {
+ var director = go.GetComponent<PlayableDirector>();
+ var editingDirector = instance.state.editSequence.director;
+ // No Asset mode update
+ if (curvesOwner.curves != null && director != null && director == editingDirector &&
+ timelineAsset == instance.state.editSequence.asset)
+ {
+ m_AnimationClipToPlayable[curvesOwner.curves] = p;
+ }
+ }
+
+ public bool GetPlayableFromAnimClip(AnimationClip clip, out Playable p)
+ {
+ if (clip == null)
+ {
+ p = Playable.Null;
+ return false;
+ }
+
+ return m_AnimationClipToPlayable.TryGetValue(clip, out p);
+ }
+
+ public TimelineClip GetTimelineClipFromCurves(AnimationClip clip)
+ {
+ if (clip == null)
+ return null;
+
+ TimelineClip timelineClip = null;
+ m_AnimationClipToTimelineClip.TryGetValue(clip, out timelineClip);
+ return timelineClip;
+ }
+
+ public void ClearPlayableLookup()
+ {
+ m_AnimationClipToPlayable.Clear();
+ }
+ }
+ }
+}