Firstborn/Library/PackageCache/com.unity.terrain-tools@4.0.5/Documentation~/create-add-brush-controls.md

36 lines
1.2 KiB
Markdown
Raw Normal View History

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;
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.
public override string GetDescription()
2023-03-28 13:24:16 -04:00
{
return "This terrain tool shows how to add custom UI to a tool.";
2023-03-28 13:24:16 -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);
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
}
}
```