A game about forced loneliness, made by TACStudios
at master 87 lines 3.1 kB view raw
1using UnityEngine; 2using UnityEngine.Playables; 3using UnityEngine.Timeline; 4 5namespace UnityEditor.Timeline 6{ 7 partial class TimelineWindow 8 { 9 private TimelineAsset m_PreviousMasterSequence; 10 11 public override void ClearTimeline() 12 { 13 SetCurrentTimeline(null, null, null, true); 14 } 15 16 public override void SetTimeline(TimelineAsset seq) 17 { 18 SetCurrentTimeline(seq, null, null); 19 } 20 21 public override void SetTimeline(PlayableDirector director) 22 { 23 SetCurrentTimeline(director, null); 24 } 25 26 public void SetCurrentTimeline(PlayableDirector director, TimelineClip hostClip) 27 { 28 var asset = director != null ? director.playableAsset as TimelineAsset : null; 29 SetCurrentTimeline(asset, director, hostClip); 30 } 31 32 void SetCurrentTimeline(TimelineAsset seq, PlayableDirector instanceOfDirector, TimelineClip hostClip, bool force = false) 33 { 34 if (state == null) 35 return; 36 37 if (!force && 38 state.editSequence.hostClip == hostClip && 39 state.editSequence.director == instanceOfDirector && 40 state.editSequence.asset == seq) 41 return; 42 43 state.SetCurrentSequence(seq, instanceOfDirector, hostClip); 44 } 45 46 void OnBeforeSequenceChange() 47 { 48 treeView = null; 49 m_MarkerHeaderGUI = null; 50 m_TimeAreaDirty = true; 51 52 state.Reset(); 53 m_PlayableLookup.ClearPlayableLookup(); 54 55 // clear old editors to caches, like audio previews, get flushed 56 CustomTimelineEditorCache.ClearCache<ClipEditor>(); 57 CustomTimelineEditorCache.ClearCache<MarkerEditor>(); 58 CustomTimelineEditorCache.ClearCache<TrackEditor>(); 59 60 m_PreviousMasterSequence = state.masterSequence.asset; 61 } 62 63 void OnAfterSequenceChange() 64 { 65 Repaint(); 66 67 m_SequencePath = state.GetCurrentSequencePath(); 68 69 m_LastFrameHadSequence = state.editSequence.asset != null; 70 TimelineWindowViewPrefs.SaveAll(); 71 72 // this prevent clearing the animation window when going in/out of playmode, but 73 // clears it when we switch master timelines 74 // the cast to a object will handle the case where the sequence has been deleted. 75 object previousMasterSequence = m_PreviousMasterSequence; 76 bool isDeleted = previousMasterSequence != null && m_PreviousMasterSequence == null; 77 bool hasChanged = m_PreviousMasterSequence != null && m_PreviousMasterSequence != state.masterSequence.asset; 78 if (isDeleted || hasChanged) 79 { 80 AnimationClipCurveCache.Instance.Clear(); 81 TimelineAnimationUtilities.UnlinkAnimationWindow(); 82 83 state.analytics.SendAfterSequenceChangeEvent(); // Changing timelines resets analytics that are aggregated in the Timeline Window 84 } 85 } 86 } 87}