TimelineWindow_StateChange.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. namespace UnityEditor.Timeline
  2. {
  3. partial class TimelineWindow
  4. {
  5. void InitializeStateChange()
  6. {
  7. state.OnPlayStateChange += OnPreviewPlayModeChanged;
  8. state.OnDirtyStampChange += OnStateChange;
  9. state.OnBeforeSequenceChange += OnBeforeSequenceChange;
  10. state.OnAfterSequenceChange += OnAfterSequenceChange;
  11. state.OnRebuildGraphChange += () =>
  12. {
  13. // called when the graph is rebuild, since the UI tree isn't necessarily rebuilt.
  14. if (!state.rebuildGraph)
  15. {
  16. // send callbacks to the tacks
  17. if (treeView != null)
  18. {
  19. var allTrackGuis = treeView.allTrackGuis;
  20. if (allTrackGuis != null)
  21. {
  22. for (int i = 0; i < allTrackGuis.Count; i++)
  23. allTrackGuis[i].OnGraphRebuilt();
  24. }
  25. }
  26. }
  27. };
  28. state.OnTimeChange += () =>
  29. {
  30. if (EditorApplication.isPlaying == false)
  31. {
  32. state.UpdateRecordingState();
  33. EditorApplication.SetSceneRepaintDirty();
  34. }
  35. if (state.ignorePreview && state.IsPlayableGraphDone())
  36. state.Pause();
  37. // the time is sync'd prior to the callback
  38. state.Evaluate(); // will do the repaint
  39. InspectorWindow.RepaintAllInspectors();
  40. };
  41. state.OnRecordingChange += () =>
  42. {
  43. if (!state.recording)
  44. {
  45. TrackAssetRecordingExtensions.ClearRecordingState();
  46. }
  47. };
  48. }
  49. }
  50. }