public override void OnMouseClick(Vector2 worldPos, int button, PP2DToolType tool) { if (tool == PP2DToolType.Single) { HandleSingleTool(WorldToCell(worldPos), button); } else if (tool == PP2DToolType.Rectangle) { _rectangleDragStart = WorldToCell(worldPos); } }
public override void OnMouseRelease(Vector2 worldPos, int button, PP2DToolType tool) { _lastDragCellId = new Vec2i(int.MaxValue, int.MaxValue); if (tool == PP2DToolType.Rectangle) { Vec2i curCell = WorldToCell(worldPos); Vec2i min = new Vec2i(Mathf.Min(curCell.x, _rectangleDragStart.x), Mathf.Min(curCell.y, _rectangleDragStart.y)); Vec2i max = new Vec2i(Mathf.Max(curCell.x, _rectangleDragStart.x), Mathf.Max(curCell.y, _rectangleDragStart.y)); for (int i = min.x; i <= max.x; i++) { for (int j = min.y; j <= max.y; j++) { HandleSingleTool(new Vec2i(i, j), button); } } } }
public abstract void OnMouseClick(Vector2 worldPos, int button, PP2DToolType tool);
public abstract void OnRepaint(UnityEditor.SceneView view, bool isDragging, Vector2 dragStart, Vector2 curMousePos, int button, PP2DToolType tool);
public abstract void OnMouseDrag(Vector2 dragStart, Vector2 worldPos, int button, PP2DToolType tool);
public override void OnMouseDrag(Vector2 dragStart, Vector2 worldPos, int button, PP2DToolType tool) { Vec2i cellId = WorldToCell(worldPos); if (cellId != _lastDragCellId) { if (tool == PP2DToolType.Single) { HandleSingleTool(cellId, button); } } _lastDragCellId = cellId; }
public override void OnRepaint(UnityEditor.SceneView view, bool isDragging, Vector2 dragStart, Vector2 curMousePos, int button, PP2DToolType tool) { if (_drawSettings.drawGrid) { DrawGridInView(view); } if (!isDragging) { DrawCellAtMouse(curMousePos); } else { if (tool == PP2DToolType.Rectangle) { DrawSelectionRectangle(dragStart, curMousePos); } else if (tool == PP2DToolType.Single) { DrawCellAtMouse(curMousePos); } } }
private void OnGUI() { _selectedPrefabLayer = (APP2DLayer)EditorGUILayout.ObjectField("PrefabLayer:", _selectedPrefabLayer, typeof(APP2DLayer), true); _toolType = (PP2DToolType)EditorGUILayout.EnumPopup("ToolType", _toolType); }