private void CheckBrush() { if (_brushType == BrushData.BrushType.None) { return; } if (_grid.Data == null) { return; } var brushData = _grid.BrushData; if (brushData == null || !brushData.HasPathBrushes()) { return; } if (_curBrush < 0 || _curBrush > brushData.pathBrushes.Count) { return; } var brush = brushData.pathBrushes[_curBrush]; var gridPos = _grid.transform.position; var curEvent = Event.current; HexPoint worldPos = GetMouseWorldPosition(curEvent.mousePosition, _grid.transform); var gridData = _grid.Data; var centerHex = worldPos.PixelToHex(gridData.size); foreach (var hex in centerHex.Ranges(_brushFeature.brushRange)) { brush.renderer.ShowHex(hex, gridPos, gridData.size, _grid.HexMat); } UpdateSceneView(); // HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive)); if (curEvent.type == EventType.MouseUp) { switch (_brushFeature.brushOptionType) { case BrushFeature.BrushOptionType.None: { foreach (var hexData in _grid.Data.hexDatas) { if (hexData.path == brush.path) { hexData.path = null; } } break; } case BrushFeature.BrushOptionType.All: { foreach (var hexData in _grid.Data.hexDatas) { hexData.path = brush.path; } break; } case BrushFeature.BrushOptionType.Add: { foreach (var hex in centerHex.Ranges(_brushFeature.brushRange)) { var data = GetHexDataByHex(hex); if (data != null) { if (data.path != brush.path) { data.path = brush.path; } } } break; } case BrushFeature.BrushOptionType.Minus: { foreach (var hex in centerHex.Ranges(_brushFeature.brushRange)) { var data = GetHexDataByHex(hex); if (data != null) { if (data.path == brush.path) { data.path = null; } } } break; } } } HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive)); // GUIUtility.hotControl = GUIUtility.GetControlID(FocusType.Passive); }