public void OnSceneGUI(SceneView sceneView) { if (selectedNode.Count > 0) { for (int i = 0; i < selectedNode.Count; i++) { if (!selectedNode[i].transform) { UpdateSelection(); break; } } modifiedNodes.Clear(); for (int i = 0; i < selectedNode.Count; i++) { var transform = selectedNode[i].transform; var node = selectedNode[i].node; var curLocalToWorldMatrix = transform.localToWorldMatrix; var oldLocalToWorldMatrix = node.hierarchyItem.LocalToWorldMatrix; if (curLocalToWorldMatrix.m00 != oldLocalToWorldMatrix.m00 || curLocalToWorldMatrix.m01 != oldLocalToWorldMatrix.m01 || curLocalToWorldMatrix.m02 != oldLocalToWorldMatrix.m02 || curLocalToWorldMatrix.m03 != oldLocalToWorldMatrix.m03 || curLocalToWorldMatrix.m10 != oldLocalToWorldMatrix.m10 || curLocalToWorldMatrix.m11 != oldLocalToWorldMatrix.m11 || curLocalToWorldMatrix.m12 != oldLocalToWorldMatrix.m12 || curLocalToWorldMatrix.m13 != oldLocalToWorldMatrix.m13 || curLocalToWorldMatrix.m20 != oldLocalToWorldMatrix.m20 || curLocalToWorldMatrix.m21 != oldLocalToWorldMatrix.m21 || curLocalToWorldMatrix.m22 != oldLocalToWorldMatrix.m22 || curLocalToWorldMatrix.m23 != oldLocalToWorldMatrix.m23 //|| //curLocalToWorldMatrix.m30 != oldLocalToWorldMatrix.m30 || //curLocalToWorldMatrix.m31 != oldLocalToWorldMatrix.m31 || //curLocalToWorldMatrix.m32 != oldLocalToWorldMatrix.m32 || //curLocalToWorldMatrix.m33 != oldLocalToWorldMatrix.m33 ) { node.hierarchyItem.LocalToWorldMatrix = curLocalToWorldMatrix; node.hierarchyItem.WorldToLocalMatrix = transform.worldToLocalMatrix; modifiedNodes.Add(node); } } if (modifiedNodes.Count > 0) { CSGNodeHierarchyManager.NotifyTransformationChanged(modifiedNodes); } } // Handle selection clicks / marquee selection CSGRectSelectionManager.Update(sceneView); }
public void OnSceneGUI(SceneView sceneView, Rect dragArea) { var defaultID = GUIUtility.GetControlID(kSurfaceEditModeHash, FocusType.Passive, dragArea); HandleUtility.AddDefaultControl(defaultID); var selectionType = CSGRectSelectionManager.GetCurrentSelectionType(); var repaint = SurfaceSelection(dragArea, selectionType); var cursor = MouseCursor.Arrow; // Handle tool specific actions switch (Tools.current) { case Tool.Move: repaint = SurfaceMoveTool(selectionType, dragArea) || repaint; cursor = MouseCursor.MoveArrow; break; case Tool.Rotate: repaint = SurfaceRotateTool(selectionType, dragArea) || repaint; cursor = MouseCursor.RotateArrow; break; case Tool.Scale: repaint = SurfaceScaleTool(selectionType, dragArea) || repaint; cursor = MouseCursor.ScaleArrow; break; //case Tool.Rect: break; } // Set cursor depending on selection type and/or active tool { switch (selectionType) { case SelectionType.Additive: cursor = MouseCursor.ArrowPlus; break; case SelectionType.Subtractive: cursor = MouseCursor.ArrowMinus; break; } EditorGUIUtility.AddCursorRect(dragArea, cursor); } // Repaint the scene-views if we need to if (repaint && // avoid infinite loop Event.current.type != EventType.Layout && Event.current.type != EventType.Repaint) { SceneView.RepaintAll(); } }