Class TilemapEditorTool
A base class for Editor Tools which work with the Tile Palette and GridBrushes
Inherited Members
Namespace: UnityEditor.Tilemaps
Assembly: Unity.2D.Tilemap.Editor.dll
Syntax
public abstract class TilemapEditorTool : EditorTool
Properties
shortcutId
Shortcut Id for this tool
Declaration
protected abstract string shortcutId { get; }
Property Value
| Type | Description |
|---|---|
| string |
tilemapEditorTools
All currently active Editor Tools which work with the Tile Palette
Declaration
public static EditorTool[] tilemapEditorTools { get; }
Property Value
| Type | Description |
|---|---|
| EditorTool[] |
tilemapEditorToolsToolbarSize
The horizontal size of a Toolbar with all the TilemapEditorTools
Declaration
[Obsolete]
public static float tilemapEditorToolsToolbarSize { get; }
Property Value
| Type | Description |
|---|---|
| float |
tooltipStringFormat
Tooltip String format which accepts a shortcut combination as the parameter
Declaration
protected abstract string tooltipStringFormat { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
GetKeysFromToolName(string)
Gets the key combination for triggering the shortcut for this tool
Declaration
protected static string GetKeysFromToolName(string id)
Parameters
| Type | Name | Description |
|---|---|---|
| string | id | The shortcut id for this tool |
Returns
| Type | Description |
|---|---|
| string | The key combination for triggering the shortcut for this tool |
GetTooltipText(string, string)
Gets the text for the tooltip given a tooltip string format and the shortcut combination for a tooltip
Declaration
protected static string GetTooltipText(string tooltipStringFormat, string shortcutId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | tooltipStringFormat | String format which accepts a shortcut combination as the parameter |
| string | shortcutId | Shortcut Id for this tool |
Returns
| Type | Description |
|---|---|
| string | The final text for the tooltip |
HandleTool(bool, GridLayout, GameObject, Vector3Int)
Method called when the Tool is being used. Override this to have custom behaviour when the Tool is used.
Declaration
public virtual bool HandleTool(bool isHotControl, GridLayout gridLayout, GameObject brushTarget, Vector3Int gridMousePosition)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | isHotControl | Whether the tool is the hot control |
| GridLayout | gridLayout | GridLayout the tool is being used on |
| GameObject | brushTarget | Target GameObject the tool is being used on |
| Vector3Int | gridMousePosition | Grid Cell position of the Mouse on the GridLayout |
Returns
| Type | Description |
|---|---|
| bool | Whether the tool has been used and modified the brushTarget |
IsAvailable()
Gets whether the tool is available for use
Declaration
public override bool IsAvailable()
Returns
| Type | Description |
|---|---|
| bool | Whether the tool is available for use |
Overrides
OnActivated()
Callback when a TilemapEditorTool is activated
Declaration
public override void OnActivated()
Overrides
SetActiveEditorTool(Type)
Sets the current active editor tool to the type passed in
Declaration
public static void SetActiveEditorTool(Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | type | The type of editor tool. This must be inherited from TilemapEditorTool |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Throws this if an invalid type parameter is set |
ToggleActiveEditorTool(Type)
Toggles the state of active editor tool with the type passed in.
Declaration
public static void ToggleActiveEditorTool(Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | type | The type of editor tool. This must be inherited from EditorTool. |
Remarks
This will change the current active editor tool if the type passed in is not the same as the current active editor tool. Otherwise, it will set the View Mode tool as the current active editor tool.
UpdateTooltip()
Updates the tooltip whenever there is a change in shortcut combinations
Declaration
protected void UpdateTooltip()