Uses IMGUI to draw a menu system. Add actions and windows to this menu system with a little as one line of code.
Download the latest Unity package here: https://github.com/the-mr-matt/DebugUISystem/releases
This is not included by default in case you use a different input system.
See example folder for a demo.
- Add the DebugUISystem prefab into your scene.
- Call
DebugUISystem.RegisterAction
orDebugUISystem.RegisterWindow
.
To hide the menus, simple disable the DebugUISystem
component.
When registering an action
or window
, you need to pass in a path
. Paths are of the following format:
Menu/Sub Menu/Sub Menu 2/Action
or Menu/Sub Menu/Sub Menu 2/Window Name
You can add as many windows or actions to a menu or sub menu as you like.
e.g. Diagnostics/Stats/FPS
will generate a menu button called Diagnostics, with a sub menu called Stats, with an FPS button.
Actions are a single button press. Use a lambda or a function as the action. This is called when the button is pressed.
private void Start()
{
string path = "File/Save";
DebugUISystem.RegisterAction(path: path, action: () => Debug.Log("Action Called"));
}
Windows can contain customizable content. Content is drawn using IMGUI -- you are free to draw whatever you want inside the window. GUILayout
is recommended for ease of use.
Windows are not resizable.
private void Start()
{
string path = "File/Save";
DebugUISystem.RegisterWindow(path: path, defaultSize: new Vector2(250, 400), onDrawWindow: () =>
{
GUILayout.BeginHorizontal();
GUILayout.Button("Left");
GUILayout.Button("Right");
GUILayout.EndHorizontal();
});
}