TilemapEditorTool 是一个可继承的类,它定义了瓦片调色板窗口的 编辑工具。要为瓦片调色板窗口创建一个新的编辑工具,创建一个新的类,从 TilemapEditorTool 继承。为你的新 TilemapEditorTool 类覆盖任何所需的函数。
你可以覆盖以下来自 TilemapEditorTool 的方法
protected abstract string tooltipStringFormat { get; }
定义此方法以显示你的 TilemapEditorTool 的工具提示。你的 TilemapEditorTool 的快捷键将通过此入口传递并格式化成最终的工具提示。
protected abstract string shortcutId { get; }
定义此方法为分配你的工具的快捷键ID。
public virtual GUIContent toolbarIcon { get; }
定义此方法以显示你的 TilemapEditorTool 的图标。如果未定义,将显示 工具栏Unity编辑器顶部的按钮和基本控制行,可让您以多种方式与编辑器交互(例如缩放、平移)。 更多信息
在 词汇表 中查看 中的 工具模式 图标。
public virtual bool HandleTool(bool isHotControl, GridLayout gridLayout, GameObject brushTarget, Vector3Int gridMousePosition)
覆盖此方法以确定处理你的 TilemapEditorTool 的任何自定义行为。方法传入以下参数以提供附加信息
| 名称 | 函数 |
|---|---|
| isHotControl | 该工具是否是 UnityGUI 下的热控件(有关更多信息,请参阅 GUIUtility.hotControl)。 |
| gridLayout | 工具正在处理的 GridLayout。 |
| brushTarget | 工具正在处理的 GameObjectUnity场景中的基本对象,可以代表角色、道具、风景、相机、航点等。GameObject 的功能由附加到其上的组件定义。 更多信息 在 词汇表 中查看。 |
| gridMousePosition | 鼠标光标当前的网格单元格位置。 |
public override bool IsAvailable()
确定你的 TilemapEditorTool 在当前时间能否被激活。使用此方法验证激活你的 TilemapEditorTool 的先决条件是否可用。
自定义 TilemapEditorTool 可作为瓦片调色板中的默认工具添加,或作为特定网格画笔的工具,当你的 GridBrush 具有具有你的自定义 TilemapEditorTool 类型的 BrushTool 属性时。
TilemapEditorTool 页面在 2021.2 中添加.