Ejemplo n.º 1
0
        void CallOnPaintSceneGUI()
        {
            bool hasSelection = GridSelection.active && GridSelection.target == brushTarget;

            if (!hasSelection && GridPaintingState.activeGrid != this)
            {
                return;
            }

            RectInt rect = new RectInt(mouseGridPosition, new Vector2Int(1, 1));

            if (m_MarqueeStart.HasValue)
            {
                rect = GridEditorUtility.GetMarqueeRect(mouseGridPosition, m_MarqueeStart.Value);
            }
            else if (hasSelection)
            {
                rect = new RectInt(GridSelection.position.xMin, GridSelection.position.yMin, GridSelection.position.size.x, GridSelection.position.size.y);
            }

            var       layoutGrid  = tilemap != null ? tilemap : grid as GridLayout;
            BoundsInt brushBounds = new BoundsInt(new Vector3Int(rect.x, rect.y, zPosition), new Vector3Int(rect.width, rect.height, 1));

            if (GridPaintingState.activeBrushEditor != null)
            {
                GridPaintingState.activeBrushEditor.OnPaintSceneGUI(layoutGrid, brushTarget, brushBounds
                                                                    , EditTypeToBrushTool(EditorTools.EditorTools.activeToolType), m_MarqueeStart.HasValue || executing);
            }
            else // Fallback when user hasn't defined custom editor
            {
                GridBrushEditorBase.OnPaintSceneGUIInternal(layoutGrid, brushTarget, brushBounds
                                                            , EditTypeToBrushTool(EditorTools.EditorTools.activeToolType), m_MarqueeStart.HasValue || executing);
            }
        }
        private void CallOnPaintSceneGUI(Vector2Int position)
        {
            if (!unlocked && !TilemapEditorTool.IsActive(typeof(SelectTool)) && !TilemapEditorTool.IsActive(typeof(PickingTool)))
            {
                return;
            }

            bool hasSelection = GridSelection.active && GridSelection.target == brushTarget;

            if (!hasSelection && GridPaintingState.activeGrid != this)
            {
                return;
            }

            GridBrushBase brush = GridPaintingState.gridBrush;

            if (brush == null)
            {
                return;
            }

            var rect = new RectInt(position, new Vector2Int(1, 1));

            if (m_MarqueeStart.HasValue)
            {
                rect = GridEditorUtility.GetMarqueeRect(position, m_MarqueeStart.Value);
            }
            else if (hasSelection)
            {
                rect = new RectInt(GridSelection.position.xMin, GridSelection.position.yMin, GridSelection.position.size.x, GridSelection.position.size.y);
            }

            var       gridLayout  = tilemap != null ? tilemap.layoutGrid : grid as GridLayout;
            BoundsInt brushBounds = new BoundsInt(new Vector3Int(rect.x, rect.y, zPosition), new Vector3Int(rect.width, rect.height, 1));

            if (GridPaintingState.activeBrushEditor != null)
            {
                GridPaintingState.activeBrushEditor.OnPaintSceneGUI(gridLayout, brushTarget, brushBounds,
                                                                    EditTypeToBrushTool(UnityEditor.EditorTools.ToolManager.activeToolType),
                                                                    m_MarqueeStart.HasValue || executing);
            }
            else // Fallback when user hasn't defined custom editor
            {
                GridBrushEditorBase.OnPaintSceneGUIInternal(gridLayout, Selection.activeGameObject, brushBounds,
                                                            EditTypeToBrushTool(UnityEditor.EditorTools.ToolManager.activeToolType),
                                                            m_MarqueeStart.HasValue || executing);
            }
        }
        private void CallOnSceneGUI()
        {
            var  gridLayout   = tilemap != null ? tilemap : grid as GridLayout;
            bool hasSelection = GridSelection.active && GridSelection.target == brushTarget;

            if (hasSelection)
            {
                var       rect        = new RectInt(GridSelection.position.xMin, GridSelection.position.yMin, GridSelection.position.size.x, GridSelection.position.size.y);
                BoundsInt brushBounds = new BoundsInt(new Vector3Int(rect.x, rect.y, zPosition), new Vector3Int(rect.width, rect.height, 1));
                GridBrushEditorBase.OnSceneGUIInternal(gridLayout, brushTarget, brushBounds, EditTypeToBrushTool(UnityEditor.EditorTools.ToolManager.activeToolType), m_MarqueeStart.HasValue || executing);
            }
            if (GridPaintingState.activeBrushEditor != null)
            {
                GridPaintingState.activeBrushEditor.OnSceneGUI(gridLayout, brushTarget);
            }
        }