GridBrushBase

class in UnityEngine

/

Inherits from:ScriptableObject

Switch to Manual

Description

使用网格绘图工具(如绘画、擦除、拾取、选择和填充)在网格上创作数据的基类。

通过继承该类和/或从继承的类创建画笔资源实例,您可以创建自定义画笔,以响应高级网格事件,如绘画、擦除、拾取、选择和填充。

using UnityEngine;

// Paints two Prefabs in checkerboard pattern [CreateAssetMenu] public class CheckerboardBrush : GridBrushBase { public GameObject prefabA; public GameObject prefabB;

public override void Paint(GridLayout grid, GameObject brushTarget, Vector3Int position) { bool evenCell = Mathf.Abs(position.y + position.x) % 2 > 0; GameObject toBeInstantiated = evenCell ? prefabA : prefabB;

if (toBeInstantiated != null) { GameObject newInstance = Instantiate(toBeInstantiated, grid.CellToWorld(position), Quaternion.identity); newInstance.transform.SetParent(brushTarget.transform); } } }

Public Functions

BoxErase擦除网格上给定边界内的数据。
BoxFill将瓦片和 GameObject 框填到所选图层的给定边界内。
ChangeZPositionChanges the Z position of the GridBrushBase.
Erase擦除网格上给定边界内的数据。
Flip翻转给定 FlipAxis 中的网格画笔。
FloodFill给定单元格的起始坐标,将数据灌填到网格中。
Move当用户移动之前使用选取框选择的区域时,将调用 Move。
MoveEnd当用户已结束对之前使用选取框选择的区域进行移动时,将调用 MoveEnd。
MoveStart当用户开始对之前使用选取框选择的区域进行移动时,将调用 MoveEnd。
Paint将数据绘制到网格上的给定边界内。
Pick给定单元格坐标,从网格中选取数据。
ResetZPositionResets Z position changes of the GridBrushBase.
Rotate按照给定的 RotationDirection 旋转网格画笔上的所有瓦片。
Select选择网格区域。

Inherited members

Variables

hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
name对象的名称。

Public Functions

GetInstanceID返回对象的实例 ID。
ToString返回 GameObject 的名称。

Static Functions

Destroy删除 GameObject、组件或资源。
DestroyImmediate立即销毁对象 /obj/。强烈建议您改用 Destroy。
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindObjectOfType返回第一个类型为 type 的已加载的激活对象。
FindObjectsOfType返回所有类型为 type 的已加载的激活对象的列表。
Instantiate克隆 original 对象并返回克隆对象。
CreateInstance创建脚本化对象的实例。

Operators

bool该对象是否存在?
operator !=比较两个对象是否引用不同的对象。
operator ==比较两个对象引用,判断它们是否引用同一个对象。

Messages

Awake当 ScriptableObject 脚本启动时调用此函数。
OnDestroy当脚本化对象将销毁时调用此函数。
OnDisable当脚本化对象超出范围时调用此函数。
OnEnable当对象加载时调用此函数。