void DrawHandleGUI(SceneView sceneView) { if (sceneView != SceneView.lastActiveSceneView) { return; } if (m_CurrentEvent.type == EventType.Repaint && !SceneDragAndDropListener.isDragging && m_Hovering != null && GUIUtility.hotControl == 0 && HandleUtility.nearestControl == m_DefaultControl && selectMode.IsMeshElementMode()) { try { EditorMeshHandles.DrawSceneSelection(m_Hovering); } catch { // this happens on undo, when c++ object is destroyed but c# side thinks it's still alive } } using (new HandleGUI()) { int screenWidth = (int)sceneView.position.width; int screenHeight = (int)sceneView.position.height; switch ((SceneToolbarLocation)s_SceneToolbarLocation) { case SceneToolbarLocation.BottomCenter: m_ElementModeToolbarRect.x = (screenWidth / 2 - 64); m_ElementModeToolbarRect.y = screenHeight - m_ElementModeToolbarRect.height * 3; break; case SceneToolbarLocation.BottomLeft: m_ElementModeToolbarRect.x = 12; m_ElementModeToolbarRect.y = screenHeight - m_ElementModeToolbarRect.height * 3; break; case SceneToolbarLocation.BottomRight: m_ElementModeToolbarRect.x = screenWidth - (m_ElementModeToolbarRect.width + 12); m_ElementModeToolbarRect.y = screenHeight - m_ElementModeToolbarRect.height * 3; break; case SceneToolbarLocation.UpperLeft: m_ElementModeToolbarRect.x = 12; m_ElementModeToolbarRect.y = 10; break; case SceneToolbarLocation.UpperRight: m_ElementModeToolbarRect.x = screenWidth - (m_ElementModeToolbarRect.width + 96); m_ElementModeToolbarRect.y = 10; break; default: case SceneToolbarLocation.UpperCenter: m_ElementModeToolbarRect.x = (screenWidth / 2 - 64); m_ElementModeToolbarRect.y = 10; break; } selectMode = UI.EditorGUIUtility.DoElementModeToolbar(m_ElementModeToolbarRect, selectMode); if (s_ShowSceneInfo) { Vector2 size = UI.EditorStyles.sceneTextBox.CalcSize(m_SceneInfo); m_SceneInfoRect.width = size.x; m_SceneInfoRect.height = size.y; GUI.Label(m_SceneInfoRect, m_SceneInfo, UI.EditorStyles.sceneTextBox); } if (m_IsDragging) { if (m_CurrentEvent.type == EventType.Repaint) { // Always draw from lowest to largest values var start = Vector2.Min(m_InitialMousePosition, m_CurrentEvent.mousePosition); var end = Vector2.Max(m_InitialMousePosition, m_CurrentEvent.mousePosition); m_MouseDragRect = new Rect(start.x, start.y, end.x - start.x, end.y - start.y); SceneStyles.selectionRect.Draw(m_MouseDragRect, false, false, false, false); } else if (m_CurrentEvent.isMouse) { HandleUtility.Repaint(); } } } }
void DrawHandleGUI(SceneView sceneView) { if (sceneView != SceneView.lastActiveSceneView) { return; } if (m_CurrentEvent.type == EventType.Repaint && !SceneDragAndDropListener.isDragging && m_Hovering != null && GUIUtility.hotControl == 0 && HandleUtility.nearestControl == m_DefaultControl && selectMode.IsMeshElementMode()) { try { EditorMeshHandles.DrawSceneSelection(m_Hovering); } catch { // this happens on undo, when c++ object is destroyed but c# side thinks it's still alive } } using (new HandleGUI()) { int screenWidth = (int)sceneView.position.width; int screenHeight = (int)sceneView.position.height; switch ((SceneToolbarLocation)s_SceneToolbarLocation) { case SceneToolbarLocation.BottomCenter: m_ElementModeToolbarRect.x = (screenWidth / 2 - 64); m_ElementModeToolbarRect.y = screenHeight - m_ElementModeToolbarRect.height * 3; break; case SceneToolbarLocation.BottomLeft: m_ElementModeToolbarRect.x = 12; m_ElementModeToolbarRect.y = screenHeight - m_ElementModeToolbarRect.height * 3; break; case SceneToolbarLocation.BottomRight: m_ElementModeToolbarRect.x = screenWidth - (m_ElementModeToolbarRect.width + 12); m_ElementModeToolbarRect.y = screenHeight - m_ElementModeToolbarRect.height * 3; break; case SceneToolbarLocation.UpperLeft: m_ElementModeToolbarRect.x = 12; m_ElementModeToolbarRect.y = 10; break; case SceneToolbarLocation.UpperRight: m_ElementModeToolbarRect.x = screenWidth - (m_ElementModeToolbarRect.width + 96); m_ElementModeToolbarRect.y = 10; break; default: case SceneToolbarLocation.UpperCenter: m_ElementModeToolbarRect.x = (screenWidth / 2 - 64); m_ElementModeToolbarRect.y = 10; break; } selectMode = UI.EditorGUIUtility.DoElementModeToolbar(m_ElementModeToolbarRect, selectMode); // todo Move to VertexManipulationTool // if (m_IsMovingElements && s_ShowSceneInfo) // { // string handleTransformInfo = string.Format( // "translate: <b>{0}</b>\nrotate: <b>{1}</b>\nscale: <b>{2}</b>", // (m_ElementHandlePosition - m_TranslateOrigin).ToString(), // (m_HandleRotation.eulerAngles - m_RotateOrigin).ToString(), // (m_HandleScale - m_ScaleOrigin).ToString()); // // var gc = UI.EditorGUIUtility.TempContent(handleTransformInfo); // // sceneview screen.height includes the tab and toolbar // var toolbarHeight = EditorStyles.toolbar.CalcHeight(gc, Screen.width); // var size = UI.EditorStyles.sceneTextBox.CalcSize(gc); // // Rect handleTransformInfoRect = new Rect( // sceneView.position.width - (size.x + 8), sceneView.position.height - (size.y + 8 + toolbarHeight), // size.x, // size.y); // // GUI.Label(handleTransformInfoRect, gc, UI.EditorStyles.sceneTextBox); // } if (s_ShowSceneInfo) { Vector2 size = UI.EditorStyles.sceneTextBox.CalcSize(m_SceneInfo); m_SceneInfoRect.width = size.x; m_SceneInfoRect.height = size.y; GUI.Label(m_SceneInfoRect, m_SceneInfo, UI.EditorStyles.sceneTextBox); } if (m_IsDragging) { if (m_CurrentEvent.type == EventType.Repaint) { // Always draw from lowest to largest values var start = Vector2.Min(m_InitialMousePosition, m_CurrentEvent.mousePosition); var end = Vector2.Max(m_InitialMousePosition, m_CurrentEvent.mousePosition); m_MouseDragRect = new Rect(start.x, start.y, end.x - start.x, end.y - start.y); SceneStyles.selectionRect.Draw(m_MouseDragRect, false, false, false, false); } else if (m_CurrentEvent.isMouse) { HandleUtility.Repaint(); } } } }