private void Draging(Event e) { TimeAreaView timeAreaView = window.GetPartialView <TimeAreaView>(); ShowRect.x += e.delta.x; Clip.StartTime = timeAreaView.PiexlToTime(ShowRect.x); Clip.StartTime = Mathf.Max(0, Clip.StartTime); e.Use(); OnDraging(); }
//绘制结束标识线 private void DrawEndLine() { TimeAreaView timeAreaView = window.GetPartialView <TimeAreaView>(); float x = timeAreaView.TimeToPixel(Timeline.DurationTime); if (Timeline.DurationTime > 1e-1 && x > 200) { Rect rec = new Rect(x, timeAreaView.TimeContent.y, 1, TracksBottommY - timeAreaView.TimeContent.y - 2); EditorGUI.DrawRect(rec, ColorEndLine); } }
public override void OnDraw() { TimeAreaView timeAreaView = window.GetPartialView <TimeAreaView>(); Rect timeAreaRect = timeAreaView.TimeContent; //显示区域 ShowRect = Track.TrackViewRect; ShowRect.x = timeAreaView.TimeToPixel(Clip.StartTime); float y = timeAreaView.TimeToPixel(Clip.EndTime); ShowRect.x = Mathf.Max(ShowRect.x, timeAreaRect.x); y = Mathf.Min(y, timeAreaRect.xMax); ShowRect.width = y - ShowRect.x; ShowRect.height = ShowRect.height - 2; if (ShowRect.width < 0) { ShowRect.width = 0; } //显示 EditorGUI.DrawRect(ShowRect, IsSelected ? SelectColor : UnSelectColor); //左右侧拖拽 Rect left = ShowRect; left.x = ShowRect.x - Mathf.Min(10, ShowRect.width / 4); left.x = Mathf.Max(left.x, timeAreaRect.x); left.width = Mathf.Min(20, ShowRect.width / 2); EditorGUIUtility.AddCursorRect(left, MouseCursor.SplitResizeLeftRight); LeftRect = left; //EditorGUI.DrawRect(LeftRect, Color.green); Rect right = left; right.x = ShowRect.x + ShowRect.width - Mathf.Min(10, ShowRect.width / 4); right.x = Mathf.Max(right.x, timeAreaRect.x); EditorGUIUtility.AddCursorRect(right, MouseCursor.SplitResizeLeftRight); RightRect = right; //EditorGUI.DrawRect(RightRect, Color.blue); GUILayout.BeginArea(ShowRect); OnDrawClip(); GUILayout.EndArea(); MiscHelper.DrawOutline(ShowRect, 1, Color.black); }
private void DragEnd(Event e) { TimeAreaView timeAreaView = window.GetPartialView <TimeAreaView>(); ShowRect.x = timeAreaView.TimeToPixel(Clip.EndTime); ShowRect.x += e.delta.x; var end = timeAreaView.PiexlToTime(ShowRect.x); if (end > Clip.StartTime) { Clip.DurationTime += (end - Clip.EndTime); e.Use(); } OnDragEnd(); }
private void DragStart(Event e) { TimeAreaView timeAreaView = window.GetPartialView <TimeAreaView>(); ShowRect.x = timeAreaView.TimeToPixel(Clip.StartTime); ShowRect.x += e.delta.x; var start2 = timeAreaView.PiexlToTime(ShowRect.x); if (start2 >= 0 && start2 <= Clip.EndTime) { Clip.DurationTime -= (start2 - Clip.StartTime); Clip.StartTime = Mathf.Max(0, start2); e.Use(); } OnDragStart(); }