void OnSceneGUI(SceneView sceneView) { if (voxelMesh == null) { return; } if (Event.current.type == EventType.Layout) { HandleUtility.AddDefaultControl(0); } Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit) && tool != null) { tool.Mode = mode; tool.SetVoxelMesh(voxelMesh); if (!Event.current.alt) { if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && !isPress) { tool.OnClickPress(hit); isPress = true; } else if (Event.current.type == EventType.MouseUp && Event.current.button == 0) { tool.OnClickRelease(hit); isPress = false; } else if (Event.current.type == EventType.MouseDrag && Event.current.button == 0) { tool.OnDrag(hit); } } tool.DisplayVisualHelp(hit); SceneView.RepaintAll(); } else { if (Event.current.type == EventType.MouseUp && Event.current.button == 0 && isPress) { tool.CancelAction(); isPress = false; } } voxelMesh.RefreshMesh(); }