1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- 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();
- }
- }
- }
|