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/Editor/Window/TimelineWindow_ActiveTimeline.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/Editor/Window/TimelineWindow_ActiveTimeline.cs')
| -rw-r--r-- | Library/PackageCache/com.unity.timeline@1.2.13/Editor/Window/TimelineWindow_ActiveTimeline.cs | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Window/TimelineWindow_ActiveTimeline.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Window/TimelineWindow_ActiveTimeline.cs new file mode 100644 index 0000000..004209f --- /dev/null +++ b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Window/TimelineWindow_ActiveTimeline.cs @@ -0,0 +1,80 @@ +using UnityEngine; +using UnityEngine.Playables; +using UnityEngine.Timeline; + +namespace UnityEditor.Timeline +{ + partial class TimelineWindow + { + private TimelineAsset m_PreviousMasterSequence; + + public void ClearCurrentTimeline() + { + SetCurrentTimeline(null, null, null, true); + } + + public void SetCurrentTimeline(TimelineAsset seq) + { + SetCurrentTimeline(seq, null, null); + } + + public void SetCurrentTimeline(PlayableDirector director, TimelineClip hostClip = null) + { + var asset = director != null ? director.playableAsset as TimelineAsset : null; + SetCurrentTimeline(asset, director, hostClip); + } + + void SetCurrentTimeline(TimelineAsset seq, PlayableDirector instanceOfDirector, TimelineClip hostClip, bool force = false) + { + if (state == null) + return; + + if (!force && + state.editSequence.hostClip == hostClip && + state.editSequence.director == instanceOfDirector && + state.editSequence.asset == seq) + return; + + state.SetCurrentSequence(seq, instanceOfDirector, hostClip); + } + + void OnBeforeSequenceChange() + { + treeView = null; + m_MarkerHeaderGUI = null; + m_TimeAreaDirty = true; + + state.Reset(); + m_PlayableLookup.ClearPlayableLookup(); + + // clear old editors to caches, like audio previews, get flushed + CustomTimelineEditorCache.ClearCache<ClipEditor>(); + CustomTimelineEditorCache.ClearCache<MarkerEditor>(); + CustomTimelineEditorCache.ClearCache<TrackEditor>(); + + m_PreviousMasterSequence = state.masterSequence.asset; + } + + void OnAfterSequenceChange() + { + Repaint(); + + m_SequencePath = state.GetCurrentSequencePath(); + + m_LastFrameHadSequence = state.editSequence.asset != null; + TimelineWindowViewPrefs.SaveAll(); + + // this prevent clearing the animation window when going in/out of playmode, but + // clears it when we switch master timelines + // the cast to a object will handle the case where the sequence has been deleted. + object previousMasterSequence = m_PreviousMasterSequence; + bool isDeleted = previousMasterSequence != null && m_PreviousMasterSequence == null; + bool hasChanged = m_PreviousMasterSequence != null && m_PreviousMasterSequence != state.masterSequence.asset; + if (isDeleted || hasChanged) + { + AnimationClipCurveCache.Instance.Clear(); + TimelineAnimationUtilities.UnlinkAnimationWindow(); + } + } + } +} |
