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_Selection.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_Selection.cs')
| -rw-r--r-- | Library/PackageCache/com.unity.timeline@1.2.13/Editor/Window/TimelineWindow_Selection.cs | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Window/TimelineWindow_Selection.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Window/TimelineWindow_Selection.cs new file mode 100644 index 0000000..c736e2e --- /dev/null +++ b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Window/TimelineWindow_Selection.cs @@ -0,0 +1,80 @@ +using UnityEngine; +using UnityEngine.Playables; +using UnityEngine.Timeline; + +namespace UnityEditor.Timeline +{ + partial class TimelineWindow + { + [SerializeField] + SequencePath m_SequencePath; + private Object lastSelectedGO { get; set; } + + void OnSelectionChange() + { + RefreshSelection(false); + } + + void RefreshSelection(bool forceRebuild) + { + // if we're in Locked mode, keep current selection - don't use locked property because the + // sequence hierarchy may need to be rebuilt and it assumes no asset == unlocked + if (m_LockTracker.isLocked || (state != null && state.recording)) + { + RestoreLastSelection(forceRebuild); + return; + } + + // selection is a TimelineAsset + Object selectedObject = Selection.activeObject as TimelineAsset; + if (selectedObject != null) + { + SetCurrentSelection(Selection.activeObject); + return; + } + + // selection is a GameObject, or a prefab with a director + var selectedGO = Selection.activeGameObject; + if (selectedGO != null) + { + bool isSceneObject = !PrefabUtility.IsPartOfPrefabAsset(selectedGO); + bool hasDirector = selectedGO.GetComponent<PlayableDirector>() != null; + if (isSceneObject || hasDirector) + { + SetCurrentSelection(selectedGO); + return; + } + } + + // otherwise, keep the same selection. + RestoreLastSelection(forceRebuild); + } + + void RestoreLastSelection(bool forceRebuild) + { + state.SetCurrentSequencePath(m_SequencePath, forceRebuild); + } + + void SetCurrentSelection(Object obj) + { + var selectedGameObject = obj as GameObject; + if (selectedGameObject != null) + { + PlayableDirector director = TimelineUtility.GetDirectorComponentForGameObject(selectedGameObject); + SetCurrentTimeline(director); + lastSelectedGO = selectedGameObject; + } + else + { + var selectedSequenceAsset = obj as TimelineAsset; + if (selectedSequenceAsset != null) + { + SetCurrentTimeline(selectedSequenceAsset); + lastSelectedGO = selectedGameObject; + } + } + + Repaint(); + } + } +} |
