用于在网格上绘制或擦除瓦片和/或游戏对象的默认内置画笔。
默认画笔旨在完成两项操作:在网格上创作游戏对象和在网格上创作瓦片。必要时,它可同时用于这两种操作。基本上,默认画笔允许您在区域之间选择和粘贴瓦片和游戏对象。
如果带有 Tilemap 的游戏对象当前处于选中状态,则瓦片地图中的瓦片将被视为处于活动状态,可进行画笔编辑。
如果游戏对象的父项当前处于选中状态,则这些对象被视为处于活动状态,可进行画笔编辑。
例如:场景视图选取操作生成大小为 2x3 的新默认画笔。新实例包含六个单元格 (BrushCell),并且来自选取区域的瓦片和游戏对象将馈入这些单元格。
稍后,当此画笔用于绘制操作时,这些单元格中包含的所有瓦片和游戏对象都会设置/克隆到一个新的场景位置中。
创建自定义画笔时,建议默认继承 GridBrushBase。当需要类似功能时,可以继承 GridBrush,但是与基类相比,它在扩展方面具有局限性。
此外,也可以通过在其中一个自定义画笔上使用 GridDefaultBrush 属性来完全替换 Tile Palette 画笔列表中的默认 GridBrush,并将其提升为项目的新默认画笔。当较高级别的画笔可作为默认画笔运行并避免设计师意外使用内置画笔时,这十分有用。
BoxErase | 从所选层的给定边界内擦除瓦片和游戏对象。 |
BoxFill | 将瓦片和 GameObject 框填到所选图层的给定边界内。 |
Erase | 擦除所选层中给定位置内的瓦片和游戏对象。 |
Flip | 在给定的轴上翻转画笔。 |
FloodFill | 从所选层中的给定位置开始灌填瓦片和游戏对象。 |
GetCellIndex | 基于 BrushCell 的位置,获取到 GridBrush.BrushCell 的索引。 |
GetCellIndexWrapAround | 基于 BrushCell 的位置,获取到 GridBrush.BrushCell 的索引。如果每个坐标的大小大于 GridBrush,则对其进行封装。 |
Init | 初始化 GridBrush 的内容。 |
MoveEnd | 当用户已结束对之前使用选取框选择的区域进行移动时,将调用 MoveEnd。 |
MoveStart | 当用户开始对之前使用选取框选择的区域进行移动时,将调用 MoveEnd。 |
Paint | 将瓦片和游戏对象绘制到所选层中的给定位置。 |
Pick | 在给定单元格坐标的情况下,从所选的 tile maps 和子游戏对象中选取瓦片。 |
Reset | 清除画笔的所有数据。 |
Rotate | 按给定方向将画笔旋转 90 度。 |
SetColor | 设置画笔中相应位置的着色颜色。 |
SetMatrix | 在画笔中的相应位置设置变换矩阵。此矩阵专门用于 Tilemap 上的瓦片,而非画笔单元格的游戏对象。 |
SetTile | 在画笔中的相应位置设置瓦片。 |
UpdateSizeAndPivot | 更新画笔的大小、轴心和层数。 |
ChangeZPosition | 更改 GridBrushBase 的 Z 位置。 |
Move | 当用户移动之前使用选取框选择的区域时,将调用 Move。 |
ResetZPosition | 重置 GridBrushBase 的 Z 位置更改。 |
Select | 选择网格区域。 |
GetInstanceID | 返回对象的实例 ID。 |
ToString | 返回 GameObject 的名称。 |
Destroy | 删除 GameObject、组件或资源。 |
DestroyImmediate | 立即销毁对象 /obj/。强烈建议您改用 Destroy。 |
DontDestroyOnLoad | 在加载新的 Scene 时,请勿销毁 Object。 |
FindObjectOfType | 返回第一个类型为 type 的已加载的激活对象。 |
FindObjectsOfType | 返回所有类型为 type 的已加载的激活对象的列表。 |
Instantiate | 克隆 original 对象并返回克隆对象。 |
CreateInstance | 创建脚本化对象的实例。 |
bool | 该对象是否存在? |
operator != | 比较两个对象是否引用不同的对象。 |
operator == | 比较两个对象引用,判断它们是否引用同一个对象。 |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.