void OnSceneGUI() { if (grid == null || Application.isPlaying) { return; } Event e = Event.current; grid.CheckRay(HandleUtility.GUIPointToWorldRay(e.mousePosition)); if (cellHighlightedIndex != grid.cellHighlightedIndex) { cellHighlightedIndex = grid.cellHighlightedIndex; SceneView.RepaintAll(); } int controlID = GUIUtility.GetControlID(FocusType.Passive); if (e.GetTypeForControl(controlID) == EventType.MouseDown) { if (cellHighlightedIndex != cellSelectedIndex) { cellSelectedIndex = cellHighlightedIndex; if (textureMode > 0) { grid.CellToggle(cellSelectedIndex, true, Color.white, false, textureMode); SceneView.RepaintAll(); } if (cellSelectedIndex >= 0) { cellTerritoryIndex = grid.CellGetTerritoryIndex(cellSelectedIndex); cellColor = grid.CellGetColor(cellSelectedIndex); if (cellColor.a == 0) { cellColor = Color.white; } cellTextureIndex = grid.CellGetTextureIndex(cellSelectedIndex); cellTag = grid.CellGetTag(cellSelectedIndex); } EditorUtility.SetDirty(target); } } if (cellSelectedIndex >= 0 && cellSelectedIndex < grid.cells.Count) { Vector3 pos = grid.CellGetPosition(cellSelectedIndex); Handles.color = colorSelection; Handles.DrawSolidDisc(pos, grid.transform.forward, HandleUtility.GetHandleSize(pos) * 0.075f); } }