private void UpdateGrabHandle() { FloatingWidth = additionalFloatingWidth + BaseFloatingWidth; var resizeHandle = new Rect(FloatingWidth - 10.0f, ScrubArea.y, 10.0f, ScrubArea.height); using (new Shared.GUIBeginArea(resizeHandle, "", "box")) { if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { extendingFloatingWidth = true; } if (extendingFloatingWidth && Event.current.type == EventType.MouseDrag) { additionalFloatingWidth += Event.current.delta.x; FloatingWidth = additionalFloatingWidth + BaseFloatingWidth; UpdateCachedMarkerInformation(); SequenceWindow.Repaint(); } } if (Event.current.type == EventType.MouseUp) { extendingFloatingWidth = false; } }
private void UpdateGrabHandle() { FloatingWidth = additionalFloatingWidth + BaseFloatingWidth; Rect resizeHandle = new Rect(FloatingWidth - 10.0f, ScrubArea.y, 10.0f, ScrubArea.height); GUILayout.BeginArea(resizeHandle, "", "box"); if (UnityEngine.Event.current.type == EventType.MouseDown && UnityEngine.Event.current.button == 0) { extendingFloatingWidth = true; } if (extendingFloatingWidth && UnityEngine.Event.current.type == EventType.MouseDrag) { additionalFloatingWidth += UnityEngine.Event.current.delta.x; FloatingWidth = additionalFloatingWidth + BaseFloatingWidth; UpdateCachedMarkerInformation(); SequenceWindow.Repaint(); } GUILayout.EndArea(); if (UnityEngine.Event.current.type == EventType.MouseUp) { extendingFloatingWidth = false; } }
public void OnSequenceChange(JSequencer newSequence) { CurrentSequence = newSequence; ZoomInfo.Reset(); ScrollInfo.Reset(); totalPixelWidthOfTimeline = 1.0f; UpdateCachedMarkerInformation(); InitializeRenderMapWithSequence(); SequenceWindow.Repaint(); }
public void OnSequenceChange(USSequencer newSequence) { CurrentSequence = newSequence; ZoomInfo.Reset(); ScrollInfo.Reset(); totalPixelWidthOfTimeline = 1.0f; UpdateCachedMarkerInformation(); if (USHierarchy == null) { USHierarchy = CreateInstance(typeof(USHierarchy)) as USHierarchy; } foreach (var newTimelineContainer in CurrentSequence.TimelineContainers) { var newHierarchyItem = CreateInstance(typeof(USTimelineContainerHierarchyItem)) as USTimelineContainerHierarchyItem; newHierarchyItem.SetupWithTimelineContainer(newTimelineContainer); USHierarchy.AddHierarchyItemToRoot(newHierarchyItem as IUSHierarchyItem); } SequenceWindow.Repaint(); }
public void HandleEvent(EventType eventType, int button, Vector2 mousePosition) { var selectableContainers = USHierarchy.ISelectableContainers(); var allObjectsUnderMouse = new List <UnityEngine.Object>(); var hasObjectsUnderMouse = false; objectContainerMap.Clear(); foreach (var selectableContainer in selectableContainers) { var objectsUnderMouse = new List <UnityEngine.Object>(); if (IsBoxSelecting && HasStartedDrag) { objectsUnderMouse = selectableContainer.GetSelectableObjectsUnderRect(SelectionArea, ScrollInfo.currentScroll.y); } else { objectsUnderMouse = selectableContainer.GetSelectableObjectUnderPos(mousePosition); } allObjectsUnderMouse.AddRange(objectsUnderMouse); if (objectsUnderMouse.Count > 0) { hasObjectsUnderMouse = true; } objectContainerMap[selectableContainer] = objectsUnderMouse; } switch (eventType) { case EventType.MouseDown: { HasProcessedInitialDrag = false; IsDragging = false; IsBoxSelecting = false; DragStartPosition = mousePosition; if (!hasObjectsUnderMouse && Event.current.button == 0) { IsBoxSelecting = true; } if (hasObjectsUnderMouse && Event.current.button == 0) { IsDragging = true; } if (IsDragging && Event.current.alt && Event.current.control) { IsDuplicating = true; } // if we have no objects under our mouse, then we are likely trying to clear our selection if (!hasObjectsUnderMouse && (!Event.current.control && !Event.current.command)) { foreach (var selectableContainer in selectableContainers) { selectableContainer.ResetSelection(); } } if (!Event.current.control && !Event.current.command) { Selection.activeGameObject = null; Selection.activeObject = null; Selection.activeTransform = null; Selection.objects = new UnityEngine.Object[] { }; } HasStartedDrag = false; SequenceWindow.Repaint(); } break; case EventType.MouseDrag: { if (!HasStartedDrag) { HasStartedDrag = true; } SequenceWindow.Repaint(); } break; case EventType.MouseUp: { HasProcessedInitialDrag = false; IsBoxSelecting = false; IsDragging = false; IsDuplicating = false; HasDuplicated = false; SequenceWindow.Repaint(); } break; } if (IsBoxSelecting && HasStartedDrag && eventType == EventType.MouseDrag) { foreach (var selectableContainer in selectableContainers) { var objectsUnderSelection = objectContainerMap[selectableContainer]; var difference = objectsUnderSelection.Where(selectedObject => !selectableContainer.SelectedObjects.Contains(selectedObject)).ToList(); if (difference.Count > 0 || (selectableContainer.SelectedObjects.Count != objectsUnderSelection.Count)) { EditorGUI.FocusTextInControl(""); selectableContainer.ResetSelection(); selectableContainer.OnSelectedObjects(objectsUnderSelection); } } } if ((!Event.current.control && !Event.current.command) && hasObjectsUnderMouse && !HasStartedDrag && (eventType == EventType.MouseUp || (eventType == EventType.MouseDown && button == 1))) { foreach (var selectableContainer in selectableContainers) { EditorGUI.FocusTextInControl(""); var objectsUnderSelection = objectContainerMap[selectableContainer]; selectableContainer.ResetSelection(); selectableContainer.OnSelectedObjects(objectsUnderSelection); } if (allObjectsUnderMouse.Count == 1) { var internalKeyframe = allObjectsUnderMouse[0] as USInternalKeyframe; if (internalKeyframe) { SequenceWindow.SetRunningTime(internalKeyframe.Time); } var observerKeyframe = allObjectsUnderMouse[0] as USObserverKeyframe; if (observerKeyframe) { Selection.activeObject = observerKeyframe; } var eventBase = allObjectsUnderMouse[0] as USEventBase; if (eventBase) { Selection.activeGameObject = eventBase.gameObject; Selection.activeTransform = eventBase.transform; } } } else if ((Event.current.control || Event.current.command) && hasObjectsUnderMouse && !HasStartedDrag && eventType == EventType.MouseUp) { foreach (var selectableContainer in selectableContainers) { var objectsUnderSelection = objectContainerMap[selectableContainer]; foreach (var selectedObject in objectsUnderSelection) { if (!selectableContainer.SelectedObjects.Contains(selectedObject)) { selectableContainer.OnSelectedObjects(new List <UnityEngine.Object> { selectedObject }); } else { selectableContainer.OnDeSelectedObjects(new List <UnityEngine.Object> { selectedObject }); } } } } else if (IsDragging && HasStartedDrag) { DragStartPosition = new Vector2(DragStartPosition.x, DragStartPosition.y); var mouseDelta = Event.current.mousePosition - DragStartPosition; if (!HasProcessedInitialDrag) { foreach (var selectableContainer in selectableContainers) { // if our under mouse isn't currently selected, clear our selection var objectsUnderSelection = objectContainerMap[selectableContainer]; if (objectsUnderSelection.Count == 1 && !selectableContainer.SelectedObjects.Contains(objectsUnderSelection[0]) && !Event.current.control && !Event.current.command) { selectableContainer.ResetSelection(); EditorGUI.FocusTextInControl(""); } selectableContainer.OnSelectedObjects(objectsUnderSelection); selectableContainer.StartDraggingObjects(); } HasProcessedInitialDrag = true; } if (IsDuplicating && !HasDuplicated) { foreach (var selectableContainer in selectableContainers) { selectableContainer.DuplicateSelection(); } HasDuplicated = true; } else { foreach (var selectableContainer in selectableContainers) { selectableContainer.ProcessDraggingObjects(mouseDelta, Snap, TimeToContentX(SnapAmount)); } } } else if (!HasStartedDrag && !hasObjectsUnderMouse && eventType == EventType.MouseUp) { foreach (var selectableContainer in selectableContainers) { selectableContainer.ResetSelection(); } var selectableArea = USHierarchy.VisibleArea; if (selectableArea.Contains(Event.current.mousePosition)) { EditorGUI.FocusTextInControl(""); } } }
private void ContentGUI() { MaintainHierarchyFor(CurrentSequence); using (new Shared.GUIBeginArea(HierarchyArea)) { if (Event.current.type == EventType.ScrollWheel) { ScrollInfo.currentScroll.x += Event.current.delta.x; ScrollInfo.currentScroll.y += Event.current.delta.y; var widthOfContent = ScrubArea.x + (CurrentSequence.Duration / ZoomInfo.meaningOfEveryMarker * ZoomInfo.currentXMarkerDist); ScrollInfo.currentScroll.x = Mathf.Clamp(ScrollInfo.currentScroll.x, 0, widthOfContent); UpdateCachedMarkerInformation(); Event.current.Use(); } USHierarchy.DoGUI(0); var selectableArea = USHierarchy.VisibleArea; if (!SequenceWindow.HasOpenPopup) { if (selectableArea.Contains(Event.current.mousePosition) || Event.current.rawType == EventType.MouseUp || Event.current.rawType == EventType.MouseDrag) { HandleEvent(Event.current.rawType == EventType.MouseUp ? Event.current.rawType : Event.current.type, Event.current.button, Event.current.mousePosition); } } // Render our mouse drag box. if (IsBoxSelecting && HasStartedDrag) { var mousePosition = Event.current.mousePosition; var origin = DragStartPosition; var destination = mousePosition; if (mousePosition.x < DragStartPosition.x) { origin.x = mousePosition.x; destination.x = DragStartPosition.x; } if (mousePosition.y < DragStartPosition.y) { origin.y = mousePosition.y; destination.y = DragStartPosition.y; } var mouseDelta = destination - origin; SelectionArea = new Rect(origin.x, origin.y, mouseDelta.x, mouseDelta.y); if (!EditorGUIUtility.isProSkin) { GUI.Box(SelectionArea, "", USEditorUtility.USeqSkin.box); } else { GUI.Box(SelectionArea, ""); } SequenceWindow.Repaint(); } } }
private void LayoutAreas() { using (new Shared.GUIBeginVertical()) { using (new Shared.GUIBeginHorizontal()) { using (new Shared.GUIBeginVertical()) { using (new Shared.GUIBeginHorizontal()) { GUILayout.Box("Floating", USEditorUtility.ContentBackground, GUILayout.Width(FloatingWidth), GUILayout.Height(18.0f)); if (Event.current.type == EventType.Repaint) { if (FloatingArea != GUILayoutUtility.GetLastRect()) { FloatingArea = GUILayoutUtility.GetLastRect(); SequenceWindow.Repaint(); } } GUILayout.Box("Scrub", USEditorUtility.ContentBackground, GUILayout.ExpandWidth(true), GUILayout.Height(18.0f)); if (Event.current.type == EventType.Repaint) { if (ScrubArea != GUILayoutUtility.GetLastRect()) { ScrubArea = GUILayoutUtility.GetLastRect(); SequenceWindow.Repaint(); UpdateCachedMarkerInformation(); } } } GUILayout.Box("Hierarchy", USEditorUtility.ContentBackground, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); if (Event.current.type == EventType.Repaint) { if (HierarchyArea != GUILayoutUtility.GetLastRect()) { HierarchyArea = GUILayoutUtility.GetLastRect(); SequenceWindow.Repaint(); UpdateCachedMarkerInformation(); } } } GUILayout.Box("Scroll", USEditorUtility.ContentBackground, GUILayout.Width(18.0f), GUILayout.ExpandHeight(true)); if (Event.current.type == EventType.Repaint) { if (VerticalScrollArea != GUILayoutUtility.GetLastRect()) { VerticalScrollArea = GUILayoutUtility.GetLastRect(); SequenceWindow.Repaint(); UpdateCachedMarkerInformation(); } } } using (new Shared.GUIBeginHorizontal()) { GUILayout.Box("Scroll", USEditorUtility.ContentBackground, GUILayout.ExpandWidth(true), GUILayout.Height(18.0f)); if (Event.current.type == EventType.Repaint) { if (HorizontalScrollArea != GUILayoutUtility.GetLastRect()) { HorizontalScrollArea = GUILayoutUtility.GetLastRect(); SequenceWindow.Repaint(); UpdateCachedMarkerInformation(); } } GUILayout.Box("block bit", USEditorUtility.ContentBackground, GUILayout.Width(18.0f), GUILayout.Height(18.0f)); } } }
public void HandleEvent(EventType eventType, int button, Vector2 mousePosition) { hasObjectsUnderMouse = false; List <UnityEngine.Object> allObjectsUnderMouse = new List <UnityEngine.Object>(); foreach (KeyValuePair <UnityEngine.Object, List <JClipRenderData> > kvp in timelineClipRenderDataMap) { foreach (JClipRenderData renderclip in kvp.Value) { if (IsBoxSelecting && HasStartedDrag) { Rect temp = SelectionArea; temp.y += ScrollInfo.currentScroll.y; if (USEditorUtility.DoRectsOverlap(temp, renderclip.renderRect)) { allObjectsUnderMouse.Add(renderclip); } } else { if (renderclip.renderRect.Contains(mousePosition)) { allObjectsUnderMouse.Add(renderclip); } } } } if (allObjectsUnderMouse.Count > 0) { hasObjectsUnderMouse = true; } switch (eventType) { case EventType.MouseDown: { HasProcessedInitialDrag = false; IsDragging = false; IsBoxSelecting = false; DragStartPosition = mousePosition; if (!hasObjectsUnderMouse && UnityEngine.Event.current.button == 0) { IsBoxSelecting = true; } if (hasObjectsUnderMouse && UnityEngine.Event.current.button == 0) { IsDragging = true; } if (IsDragging && UnityEngine.Event.current.alt && UnityEngine.Event.current.control) { IsDuplicating = true; } // if we have no objects under our mouse, then we are likely trying to clear our selection if (!hasObjectsUnderMouse && (!UnityEngine.Event.current.control && !UnityEngine.Event.current.command)) { ResetSelection(); } if (!UnityEngine.Event.current.control && !UnityEngine.Event.current.command) { Selection.activeGameObject = null; Selection.activeObject = null; Selection.activeTransform = null; Selection.objects = new UnityEngine.Object[] { }; } HasStartedDrag = false; SequenceWindow.Repaint(); } break; case EventType.MouseDrag: { if (!HasStartedDrag) { HasStartedDrag = true; } SequenceWindow.Repaint(); } break; case EventType.MouseUp: { HasProcessedInitialDrag = false; IsBoxSelecting = false; IsDragging = false; IsDuplicating = false; HasDuplicated = false; SequenceWindow.Repaint(); } break; } //单选 if ((!UnityEngine.Event.current.control && !UnityEngine.Event.current.command) && hasObjectsUnderMouse && !HasStartedDrag && ((eventType == EventType.MouseUp && button == 0) || (eventType == EventType.MouseDown && button == 1))) { EditorGUI.FocusTextInControl(""); ResetSelection(); OnSelectedObjects(allObjectsUnderMouse); if (SelectedObjects.Count == 1) { //单选 处理更类型的属性显示 var selectobj = SelectedObjects[0] as JClipRenderData; OnSingleClipSelected(selectobj); } } else //多选 添加和删除 if ((UnityEngine.Event.current.control || UnityEngine.Event.current.command) && hasObjectsUnderMouse && !HasStartedDrag && eventType == EventType.MouseUp) { foreach (var selectedObject in allObjectsUnderMouse) { if (!SelectedObjects.Contains(selectedObject)) { OnSelectedObjects(new List <UnityEngine.Object> { selectedObject }); } else { OnDeSelectedObjects(new List <UnityEngine.Object> { selectedObject }); } } } else if (IsBoxSelecting && HasStartedDrag) { OnSelectedObjects(allObjectsUnderMouse); } //移动 if (IsDragging && HasStartedDrag) { if (allObjectsUnderMouse.Count == 1) { if (!selectedObjects.Contains(allObjectsUnderMouse[0])) { ResetSelection(); } } OnSelectedObjects(allObjectsUnderMouse); DragStartPosition = new Vector2(DragStartPosition.x, DragStartPosition.y); Vector2 mouseDelta = UnityEngine.Event.current.mousePosition - DragStartPosition; if (!HasProcessedInitialDrag) { StartDraggingObjects(); HasProcessedInitialDrag = true; } ProcessDraggingObjects(mouseDelta); if (IsDuplicating && !HasDuplicated) { } else { /// ProcessDraggingObjects(mouseDelta); } } }
private void ContentGUI() { GUILayout.BeginArea(HierarchyArea); { if (UnityEngine.Event.current.type == EventType.ScrollWheel) { ScrollInfo.currentScroll.x += UnityEngine.Event.current.delta.x; ScrollInfo.currentScroll.y += 2 * UnityEngine.Event.current.delta.y; float widthOfContent = ScrubArea.x + (CurrentSequence.Duration / ZoomInfo.meaningOfEveryMarker * ZoomInfo.currentXMarkerDist); ScrollInfo.currentScroll.x = Mathf.Clamp(ScrollInfo.currentScroll.x, 0, widthOfContent); UpdateCachedMarkerInformation(); UnityEngine.Event.current.Use(); } GUILayout.BeginVertical(); GUILayout.Box("", USEditorUtility.ContentBackground, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); if (UnityEngine.Event.current.type == EventType.Repaint) { if (VisibleArea != GUILayoutUtility.GetLastRect()) { VisibleArea = GUILayoutUtility.GetLastRect(); SequenceWindow.Repaint(); } } GUILayout.BeginArea(VisibleArea); GUILayout.BeginScrollView(ScrollInfo.currentScroll, GUIStyle.none, GUIStyle.none); GUILayout.BeginVertical(); DrawSideBarAndTimeLines(); GUILayout.EndVertical(); if (UnityEngine.Event.current.type == EventType.Repaint) { if (TotalArea != GUILayoutUtility.GetLastRect()) { TotalArea = GUILayoutUtility.GetLastRect(); SequenceWindow.Repaint(); } } GUILayout.EndScrollView(); GUILayout.EndArea(); // SelectionArea = VisibleArea; if (VisibleArea.Contains(UnityEngine.Event.current.mousePosition) || UnityEngine.Event.current.rawType == EventType.MouseUp || UnityEngine.Event.current.rawType == EventType.MouseDrag) { HandleEvent(UnityEngine.Event.current.rawType == EventType.MouseUp ? UnityEngine.Event.current.rawType : UnityEngine.Event.current.type, UnityEngine.Event.current.button, UnityEngine.Event.current.mousePosition); } // Render our mouse drag box. if (IsBoxSelecting && HasStartedDrag) { Vector2 mousePosition = UnityEngine.Event.current.mousePosition; Vector2 origin = DragStartPosition; Vector2 destination = mousePosition; if (mousePosition.x < DragStartPosition.x) { origin.x = mousePosition.x; destination.x = DragStartPosition.x; } if (mousePosition.y < DragStartPosition.y) { origin.y = mousePosition.y; destination.y = DragStartPosition.y; } Vector2 mouseDelta = destination - origin; SelectionArea = new Rect(origin.x, origin.y, mouseDelta.x, mouseDelta.y); if (!EditorGUIUtility.isProSkin) { GUI.Box(SelectionArea, "", USEditorUtility.USeqSkin.box); } else { GUI.Box(SelectionArea, ""); } SequenceWindow.Repaint(); } } GUILayout.EndVertical(); GUILayout.EndArea(); }
/// <summary> /// 基本布局 /// </summary> private void LayoutAreas() { GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { //时间标尺背景 GUILayout.Box("Floating", USEditorUtility.ContentBackground, GUILayout.Width(FloatingWidth), GUILayout.Height(lineHeight)); if (UnityEngine.Event.current.type == EventType.Repaint) { if (FloatingArea != GUILayoutUtility.GetLastRect()) { FloatingArea = GUILayoutUtility.GetLastRect(); SequenceWindow.Repaint(); } } //时间标尺 GUILayout.Box("Scrub", USEditorUtility.ContentBackground, GUILayout.ExpandWidth(true), GUILayout.Height(lineHeight)); if (UnityEngine.Event.current.type == EventType.Repaint) { if (ScrubArea != GUILayoutUtility.GetLastRect()) { ScrubArea = GUILayoutUtility.GetLastRect(); SequenceWindow.Repaint(); UpdateCachedMarkerInformation(); } } } GUILayout.EndHorizontal(); //整个内容显示区域 GUILayout.Box("Hierarchy", USEditorUtility.ContentBackground, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); if (UnityEngine.Event.current.type == EventType.Repaint) { if (HierarchyArea != GUILayoutUtility.GetLastRect()) { HierarchyArea = GUILayoutUtility.GetLastRect(); SequenceWindow.Repaint(); UpdateCachedMarkerInformation(); } } } //垂直滚动条 GUILayout.EndVertical(); GUILayout.Box("Scroll", USEditorUtility.ContentBackground, GUILayout.Width(lineHeight), GUILayout.ExpandHeight(true)); if (UnityEngine.Event.current.type == EventType.Repaint) { if (VerticalScrollArea != GUILayoutUtility.GetLastRect()) { VerticalScrollArea = GUILayoutUtility.GetLastRect(); SequenceWindow.Repaint(); UpdateCachedMarkerInformation(); } } } GUILayout.EndHorizontal(); //水平滚动条 GUILayout.BeginHorizontal(); { GUILayout.Box("Scroll", USEditorUtility.ContentBackground, GUILayout.ExpandWidth(true), GUILayout.Height(lineHeight)); if (UnityEngine.Event.current.type == EventType.Repaint) { if (HorizontalScrollArea != GUILayoutUtility.GetLastRect()) { HorizontalScrollArea = GUILayoutUtility.GetLastRect(); SequenceWindow.Repaint(); UpdateCachedMarkerInformation(); } } //右下角的横纵滚动条的边角 GUILayout.Box("block bit", USEditorUtility.ContentBackground, GUILayout.Width(lineHeight), GUILayout.Height(lineHeight)); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }