Exemple #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 as GridLayout : 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
                                                                    , EditModeToBrushTool(EditMode.editMode), m_MarqueeStart.HasValue || executing);
            }
            else // Fallback when user hasn't defined custom editor
            {
                GridBrushEditorBase.OnPaintSceneGUIInternal(layoutGrid, brushTarget, brushBounds
                                                            , EditModeToBrushTool(EditMode.editMode), m_MarqueeStart.HasValue || executing);
            }
        }
        private void CallOnPaintSceneGUI()
        {
            bool flag = GridSelection.active && GridSelection.target == this.brushTarget;

            if (flag || !(GridPaintingState.activeGrid != this))
            {
                RectInt marqueeRect = new RectInt(base.mouseGridPosition, new Vector2Int(1, 1));
                if (this.m_MarqueeStart.HasValue)
                {
                    marqueeRect = GridEditorUtility.GetMarqueeRect(base.mouseGridPosition, this.m_MarqueeStart.Value);
                }
                else if (flag)
                {
                    marqueeRect = new RectInt(GridSelection.position.xMin, GridSelection.position.yMin, GridSelection.position.size.x, GridSelection.position.size.y);
                }
                GridLayout gridLayout = (!(this.tilemap != null)) ? this.grid : this.tilemap;
                if (GridPaintingState.activeBrushEditor != null)
                {
                    GridPaintingState.activeBrushEditor.OnPaintSceneGUI(gridLayout, this.brushTarget, new BoundsInt(new Vector3Int(marqueeRect.x, marqueeRect.y, 0), new Vector3Int(marqueeRect.width, marqueeRect.height, 1)), PaintableGrid.EditModeToBrushTool(EditMode.editMode), this.m_MarqueeStart.HasValue || base.executing);
                }
                else
                {
                    GridBrushEditorBase.OnPaintSceneGUIInternal(gridLayout, this.brushTarget, new BoundsInt(new Vector3Int(marqueeRect.x, marqueeRect.y, 0), new Vector3Int(marqueeRect.width, marqueeRect.height, 1)), PaintableGrid.EditModeToBrushTool(EditMode.editMode), this.m_MarqueeStart.HasValue || base.executing);
                }
            }
        }
        private void CallOnPaintSceneGUI(Vector2Int position)
        {
            if (!unlocked && EditMode.editMode != EditMode.SceneViewEditMode.GridSelect && EditMode.editMode != EditMode.SceneViewEditMode.GridPicking)
            {
                return;
            }

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

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

            GridBrushBase brush = GridPaintingState.gridBrush;

            if (brush == null)
            {
                return;
            }

            RectInt 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 as GridLayout : grid as GridLayout;
            BoundsInt brushBounds = new BoundsInt(new Vector3Int(rect.x, rect.y, 0), new Vector3Int(rect.width, rect.height, 1));

            if (GridPaintingState.activeBrushEditor != null)
            {
                GridPaintingState.activeBrushEditor.OnPaintSceneGUI(gridLayout, brushTarget, brushBounds, EditModeToBrushTool(EditMode.editMode), m_MarqueeStart.HasValue || executing);
            }
            else // Fallback when user hasn't defined custom editor
            {
                GridBrushEditorBase.OnPaintSceneGUIInternal(gridLayout, Selection.activeGameObject, brushBounds, EditModeToBrushTool(EditMode.editMode), m_MarqueeStart.HasValue || executing);
            }
        }
 public virtual void OnPaintSceneGUI(GridLayout gridLayout, GameObject brushTarget, BoundsInt position, GridBrushBase.Tool tool, bool executing)
 {
     GridBrushEditorBase.OnPaintSceneGUIInternal(gridLayout, brushTarget, position, tool, executing);
 }