🌀 Circular menus in the Unity Editor
Adding a circular menu to the Unity Editor.
1 minute read
Jump to heading Introduction
This weekend I was working in Blender and noticed their easy to use circular menu. By pressing a button, the menu appears and then by pointing your mouse in a direction, you can select one of the options.
Jump to heading Circular menu + Unity Editor = ⚡
Using UI Toolkit and the new Vector API I added a circular menu to the Unity Editor. I hooked it up to my scene view debug views which allows me to quickly switch between views.
The circular menu has the following features
- nested radial menus
- a label showing the current 'directory'
- a mouse angle indicator
- hover highlights
Jump to heading Show me the code!
The code for this was inspired by BennyKok's original prototype. A big thank you to them for sharing their original code. You can find the code that I used for my circular menu here.
https://gist.github.com/alexanderameye/1eef648d7d1699a9548bc2de3dde2a45
⚠️ Use this code at your own risk! It was quickly thrown together, is a bit messy and may contain bugs.
The gist contains 3 scripts
- CircularMenu.cs
- CircularMenuButton.cs
- CircularMenuAttribute.cs
You can add a method to the circular menu simply by using the following method attribute and specifying a path and an icon.
[CircularMenu(Path = "Debug Views/Normals", Icon = "d_DirectionalLight Icon")]
public static void ShowDebugNormals()
{
EnableDebugView(true);
SetDebugView(DebugView.Normals);
}
That's all! Now that I am using this circular menu in my own project I will probably continue iterating on it and updating the gists as well.