2023-03-28 13:24:16 -04:00
# Add UI for Brush controls
[Create your tool script ](create-tool-script.md ) showed you how to create a new custom tool without any additional functionality. The example below shows you how to add UI for Brush controls in your script.
```
using UnityEngine;
using UnityEditor;
using UnityEditor.TerrainTools;
2023-04-27 19:37:28 -04:00
class CustomTerrainToolWithBrushUI : TerrainPaintTool< CustomTerrainToolWithBrushUI >
2023-03-28 13:24:16 -04:00
{
private float m_BrushRotation;
// Name of the Terrain Tool. This appears in the tool UI.
public override string GetName()
{
return "Examples/Custom Terrain Tool with Brush UI";
}
// Description for the Terrain Tool. This appears in the tool UI.
2023-04-27 19:37:28 -04:00
public override string GetDescription()
2023-03-28 13:24:16 -04:00
{
2023-04-27 19:37:28 -04:00
return "This terrain tool shows how to add custom UI to a tool.";
2023-03-28 13:24:16 -04:00
}
2023-04-27 19:37:28 -04:00
// Override this function to add UI elements to the inspector
2023-03-28 13:24:16 -04:00
public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext)
{
editContext.ShowBrushesGUI(5, BrushGUIEditFlags.Select | BrushGUIEditFlags.Opacity | BrushGUIEditFlags.Size);
2023-04-27 19:37:28 -04:00
EditorGUILayout.HelpBox("Rotation is specific to this tool", MessageType.Info);
m_BrushRotation = EditorGUILayout.Slider("Rotation", m_BrushRotation, 0, 360);
2023-03-28 13:24:16 -04:00
}
}
```