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_TimeCursor.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_TimeCursor.cs')
| -rw-r--r-- | Library/PackageCache/com.unity.timeline@1.2.13/Editor/Window/TimelineWindow_TimeCursor.cs | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Window/TimelineWindow_TimeCursor.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Window/TimelineWindow_TimeCursor.cs new file mode 100644 index 0000000..9a0bee4 --- /dev/null +++ b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/Window/TimelineWindow_TimeCursor.cs @@ -0,0 +1,83 @@ +using System; +using UnityEngine; +using UnityEngine.Timeline; +using UnityEngine.Playables; + +namespace UnityEditor.Timeline +{ + partial class TimelineWindow + { + TimeAreaItem m_PlayHead; + + void TimeCursorGUI(TimelineItemArea area) + { + DrawTimeOnSlider(); + if (!CanDrawTimeCursor(area)) + return; + + if (m_PlayHead == null || m_PlayHead.style != styles.timeCursor) + { + m_PlayHead = new TimeAreaItem(styles.timeCursor, OnTrackHeadDrag); + m_PlayHead.AddManipulator(new PlayheadContextMenu(m_PlayHead)); + } + + var headerMode = area == TimelineItemArea.Header; + DrawTimeCursor(headerMode, !headerMode); + } + + bool CanDrawTimeCursor(TimelineItemArea area) + { + if (!currentMode.ShouldShowTimeCursor(state)) + return false; + + if (treeView == null || state.editSequence.asset == null || (state.editSequence.asset != null && state.IsEditingAnEmptyTimeline())) + return false; + + if (area == TimelineItemArea.Lines && !state.TimeIsInRange((float)state.editSequence.time)) + return false; + + return true; + } + + void DrawTimeOnSlider() + { + if (currentMode.ShouldShowTimeCursor(state)) + { + var colorDimFactor = EditorGUIUtility.isProSkin ? 0.7f : 0.9f; + var c = styles.timeCursor.normal.textColor * colorDimFactor; + + float time = Mathf.Max((float)state.editSequence.time, 0); + float duration = (float)state.editSequence.duration; + + m_TimeArea.DrawTimeOnSlider(time, c, duration, DirectorStyles.kDurationGuiThickness); + } + } + + void DrawTimeCursor(bool drawHead, bool drawline) + { + m_PlayHead.HandleManipulatorsEvents(state); + + if (Event.current.type == EventType.MouseDown && Event.current.button == 0) + { + if (state.timeAreaRect.Contains(Event.current.mousePosition)) + { + state.SetPlaying(false); + m_PlayHead.HandleManipulatorsEvents(state); + state.editSequence.time = Math.Max(0.0, state.GetSnappedTimeAtMousePosition(Event.current.mousePosition)); + } + } + + state.isClipSnapping = false; + + m_PlayHead.drawLine = drawline; + m_PlayHead.drawHead = drawHead; + m_PlayHead.Draw(sequenceContentRect, state, state.editSequence.time); + } + + void OnTrackHeadDrag(double newTime) + { + state.editSequence.time = Math.Max(0.0, newTime); + m_PlayHead.showTooltip = true; + } + } +} |
