| using UnityEngine; |
| using UnityEngine.Playables; |
| using UnityEngine.Timeline; |
|
|
| namespace UnityEditor.Timeline |
| { |
| partial class TimelineWindow |
| { |
| [SerializeField] |
| SequencePath m_SequencePath; |
|
|
| void OnSelectionChange() |
| { |
| |
| SelectionManager.GetCurrentInlineEditorCurve()?.ValidateCurvesSelection(); |
|
|
| RefreshSelection(false); |
| } |
|
|
| void RefreshSelection(bool forceRebuild) |
| { |
| |
| |
| if (m_LockTracker.isLocked || (state != null && state.recording)) |
| { |
| RestoreLastSelection(forceRebuild); |
| return; |
| } |
|
|
| |
| Object selectedObject = Selection.activeObject as TimelineAsset; |
| if (selectedObject != null) |
| { |
| SetCurrentSelection(Selection.activeObject); |
| return; |
| } |
|
|
| |
| var selectedGO = Selection.activeGameObject; |
| if (selectedGO != null) |
| { |
| bool isSceneObject = !PrefabUtility.IsPartOfPrefabAsset(selectedGO); |
| bool hasDirector = selectedGO.GetComponent<PlayableDirector>() != null; |
| if (isSceneObject || hasDirector) |
| { |
| SetCurrentSelection(selectedGO); |
| return; |
| } |
| } |
|
|
| |
| if (Selection.activeObject == null && |
| state.IsEditingAnEmptyTimeline()) |
| { |
| SetCurrentSelection(null); |
| } |
|
|
|
|
| |
| RestoreLastSelection(forceRebuild); |
| } |
|
|
| void RestoreLastSelection(bool forceRebuild) |
| { |
| state.SetCurrentSequencePath(m_SequencePath, forceRebuild); |
|
|
| |
| if (m_LockTracker.isLocked && state.editSequence.asset == null) |
| m_LockTracker.isLocked = false; |
| } |
|
|
| void SetCurrentSelection(Object obj) |
| { |
| var selectedGameObject = obj as GameObject; |
| if (selectedGameObject != null) |
| { |
| PlayableDirector director = TimelineUtility.GetDirectorComponentForGameObject(selectedGameObject); |
| SetTimeline(director); |
| } |
| else |
| { |
| var selectedSequenceAsset = obj as TimelineAsset; |
| if (selectedSequenceAsset != null) |
| { |
| SetTimeline(selectedSequenceAsset); |
| } |
| } |
|
|
| Repaint(); |
| } |
| } |
| } |
|
|