Hey!
Does anyone know if we can give order/priority to custom editor tool? There aren’t any parameters to do this in the attribute EditorTool. I am using Unity 2022.2.
Edit: The only way I found is to rename the classes like this: “01_CircleTool” and “02_BrushTool” but it’s a bit messy.
I’m back 1 year later with the “solution”. They added a priority parameter to the ToolAttribute but only from the 2023.1 Unity version.
The class name workaround that I mentioned in my previous post didn’t work in the long run.
If you’re like me and you are stuck in 2022 or less, here’s a quick hack to do it:
- Remove all EditorTool attributes from your tools.
- Create a EditorToolContext.
- Override “GetAdditionalToolTypes” and give it your EditorTools in the order you want.
[EditorToolContext("Terrain Editor", typeof(TerrainEditor))]
public class TerrainEditorContext : EditorToolContext
{
public override IEnumerable<Type> GetAdditionalToolTypes()
{
return new List<Type>()
{
typeof(Tool_01_TerrainBrushTool),
typeof(Tool_05_TerrainRectangleTool),
typeof(Tool_06_TerrainCircleTool),
typeof(Tool_07_TerrainStampTool),
typeof(Tool_08_TerrainFlattenTool),
typeof(Tool_10_TerrainSelectionTool),
typeof(Tool_11_TerrainResizeTool)
};
}
}
With this, you’ll need an extra click to access your tools which is not nice. I set the active context in the initialization of my tool to avoid that. Maybe it’s not the best location to do it but I did it in the CreateInspectorGUI of my custom inspector:
EditorApplication.delayCall += () => ToolManager.SetActiveContext<TerrainEditorContext>();
Hope it helps someone!