public static void OnSceneGUI(SceneView sceneView) { if (EditorApplication.isPlayingOrWillChangePlaymode) { return; } CameraUtility.InitDistanceChecks(sceneView); SelectionUtility.HandleEvents(); InitTools(); HandleBuilderEvents(); { UpdateTool(); if (instance.activeTool != null) { if (RealtimeCSG.CSGSettings.EnableRealtimeCSG) { // handle the tool var sceneSize = sceneView.position.size; var sceneRect = new Rect(0, 0, sceneSize.x, sceneSize.y - ((CSG_GUIStyleUtility.BottomToolBarHeight + 4) + 17)); instance.activeTool.HandleEvents(sceneRect); } else { if (Event.current.type == EventType.Repaint) { var brushes = instance.filteredSelection.BrushTargets; var wireframes = new List <GeometryWireframe>(brushes.Length); var transformations = new List <Matrix4x4>(brushes.Length); for (int i = 0; i < brushes.Length; i++) { var brush = brushes[i]; if (!brush) { continue; } if (brush.ChildData == null || !brush.ChildData.Model) { continue; } var brushTransformation = brush.compareTransformation.localToWorldMatrix; wireframes.Add(BrushOutlineManager.GetBrushOutline(brushes[i].brushNodeID)); transformations.Add(brushTransformation); } if (wireframes.Count > 0) { CSGRenderer.DrawSelectedBrushes(instance.zTestLineMeshManager, instance.noZTestLineMeshManager, wireframes.ToArray(), transformations.ToArray(), ColorSettings.SelectedOutlines, GUIConstants.thickLineScale); } MaterialUtility.LineDashMultiplier = 1.0f; MaterialUtility.LineThicknessMultiplier = 1.0f; MaterialUtility.LineAlphaMultiplier = 1.0f; instance.zTestLineMeshManager.Render(MaterialUtility.ZTestGenericLine); instance.zTestLineMeshManager.Render(MaterialUtility.ZTestGenericLine); } } } } int sceneWindowId = GUIUtility.GetControlID(SceneWindowHash, FocusType.Passive); var sceneWindowType = Event.current.GetTypeForControl(sceneWindowId); if (sceneWindowType == EventType.Repaint) { if (currentEditorWindows.Count > 0) { for (int i = 0; i < currentEditorWindows.Count; i++) { currentEditorWindows[i].Repaint(); } return; } } if (sceneWindowType == EventType.MouseMove) { SceneDragToolManager.IsDraggingObjectInScene = false; } if (RealtimeCSG.CSGSettings.EnableRealtimeCSG) { if (sceneView && sceneWindowType != EventType.Used && !SceneDragToolManager.IsDraggingObjectInScene) { if (currentEditorWindows.Count == 0) { try { Handles.BeginGUI(); Rect windowRect = new Rect(Vector2.zero, sceneView.position.size); EditModeSelectionGUI.HandleWindowGUI(windowRect); } finally { Handles.EndGUI(); } } } } }
//void OnSceneGUI() <- paints -everything- again for every selected brush public static void OnSceneGUI(SceneView sceneView) { if (EditorApplication.isPlayingOrWillChangePlaymode) { return; } /* * int prevHotControl = GUIUtility.hotControl; * int prevKeyboardControl = GUIUtility.keyboardControl; * * // make it impossible for the tool to click in the bottom bar area * int bottomBarId = GUIUtility.GetControlID (BottomBarInputHash, FocusType.Passive); * bool forceRevert = false; * //if (GUIUtility.hotControl == 0) * { * var bottomBarRect = sceneView.position; * var min = bottomBarRect.min; * var max = bottomBarRect.max; * * min.y = max.y - (GUIStyleUtility.BottomToolBarHeight + 18); * * bottomBarRect.min = min; * bottomBarRect.max = max; * * if (bottomBarRect.Contains(Event.current.mousePosition)) * { * GUIUtility.hotControl = bottomBarId; * GUIUtility.keyboardControl = bottomBarId; * forceRevert = true; * } * } */ SelectionUtility.HandleEvents(); InitTools(); HandleBuilderEvents(); //HandleYMode(); { UpdateTool(); if (instance.activeTool != null) { if (RealtimeCSG.CSGSettings.EnableRealtimeCSG) { // handle the tool var sceneSize = sceneView.position.size; var sceneRect = new Rect(0, 0, sceneSize.x, sceneSize.y - ((GUIStyleUtility.BottomToolBarHeight + 4) + 17)); //var originalEventType = Event.current.type; //if (originalEventType == EventType.MouseMove || // originalEventType == EventType.MouseUp) // holdingDownMouse = false; //var mousePos = Event.current.mousePosition; //if (originalEventType == EventType.Layout || // originalEventType == EventType.Repaint || // sceneRect.Contains(mousePos) || // holdingDownMouse) instance.activeTool.HandleEvents(sceneRect); //if (originalEventType == EventType.MouseDown || // originalEventType == EventType.MouseDrag) // holdingDownMouse = true; } else { if (Event.current.type == EventType.Repaint) { var brushes = instance.filteredSelection.BrushTargets; var wireframes = new List <GeometryWireframe>(brushes.Length); var translations = new List <Vector3>(brushes.Length); for (int i = 0; i < brushes.Length; i++) { var brush = brushes[i]; if (!brush) { continue; } var brushCache = InternalCSGModelManager.GetBrushCache(brush); if (brushCache == null || brushCache.childData == null || !brushCache.childData.Model) { continue; } var brushTranslation = brushCache.compareTransformation.modelLocalPosition + brushCache.childData.ModelTransform.position; wireframes.Add(BrushOutlineManager.GetBrushOutline(brushes[i].brushID)); translations.Add(brushTranslation); } if (wireframes.Count > 0) { CSGRenderer.DrawSelectedBrushes(instance.zTestLineMeshManager, instance.noZTestLineMeshManager, wireframes.ToArray(), translations.ToArray(), ColorSettings.SelectedOutlines, ToolConstants.thickLineScale); } MaterialUtility.LineDashMultiplier = 1.0f; MaterialUtility.LineThicknessMultiplier = 1.0f; MaterialUtility.LineAlphaMultiplier = 1.0f; instance.zTestLineMeshManager.Render(MaterialUtility.ZTestGenericLine); instance.zTestLineMeshManager.Render(MaterialUtility.ZTestGenericLine); } } } } /* * // reset the control so the bottom bar can take over * if (forceRevert) * { * GUIUtility.hotControl = prevHotControl; * GUIUtility.keyboardControl = prevKeyboardControl; * } */ int sceneWindowId = GUIUtility.GetControlID(SceneWindowHash, FocusType.Passive); var sceneWindowType = Event.current.GetTypeForControl(sceneWindowId); if (sceneWindowType == EventType.Repaint) { if (currentEditorWindows.Count > 0) { for (int i = 0; i < currentEditorWindows.Count; i++) { currentEditorWindows[i].Repaint(); } return; } } if (sceneWindowType == EventType.MouseMove) { SceneTools.IsDraggingObjectInScene = false; } if (RealtimeCSG.CSGSettings.EnableRealtimeCSG) { if (sceneView != null && sceneWindowType != EventType.Used && !SceneTools.IsDraggingObjectInScene) { if (currentEditorWindows.Count == 0) { try { Handles.BeginGUI(); Rect windowRect = new Rect(Vector2.zero, sceneView.position.size); CSGBrushEditorGUI.HandleWindowGUI(windowRect); } finally { Handles.EndGUI(); } } } } }