DebugToolkit is a library that makes it easy to build runtime debug menus.
DebugToolkit helps you quickly create runtime debug UIs using Unity UIToolkit without writing USS styles. You can build and operate everything with C# scripts only. It provides useful features for development and debugging such as creating draggable debug windows, showing performance information, viewing console logs, and a text field with undo/redo history.
DebugToolkit is designed based on the following concepts:
- Add debug features using C# code only
- Engineers don’t need to worry about layout and styling
- Minimal and low dependency
Download a Unity package from Releases, or add via Package Manager using the following URL:
https://github.com/AndanteTribe/DebugToolkit.git?path=Packages/jp.andantetribe.debugtoolkit
DebugToolkit is enabled by default after installation. No additional setup is required.
Optional: If you want to disable DebugToolkit entirely, add DISABLE_DEBUGTOOLKIT to Project Settings > Player > Other Settings > Script Compilation > Scripting Define Symbols.
- Create a class that inherits
DebugViewerBase - Override
CreateViewGUI() - Implement your debug menu inside
CreateViewGUI() - Call
Start()at runtime
using DebugToolkit;
using UnityEngine;
using UnityEngine.UIElements;
public class MyDebugView : DebugViewerBase
{
protected override VisualElement CreateViewGUI()
{
var root = base.CreateViewGUI();
// Add performance info label
root.AddProfileInfoLabel();
// Add a button
var button = new Button() { text = "Hoge" };
button.RegisterCallback<ClickEvent>(_ => Debug.Log("Hoge"));
root.Add(button);
return root;
}
}using UnityEngine;
public class DebugInitializer : MonoBehaviour
{
private MyDebugView _debugView;
void Start()
{
_debugView = new MyDebugView();
// Build the debug menu
_debugView.Start();
}
}While using DebugToolkit, a toggle button is shown at the bottom of the screen. Pressing it toggles visibility of all debug windows. You can also restore windows that you’ve hidden.
You can import Samples from Package Manager to try sample scenes and scripts.
Adds a new debug window.
public class MyDebugView : DebugViewerBase
{
protected override VisualElement CreateViewGUI()
{
var root = base.CreateViewGUI();
var window = root.AddWindow("Window1");
window.Add(new Label("This is New Window"));
return root;
}
}Adds a console log viewer. You can check Unity’s console logs at runtime.
public class MyDebugView : DebugViewerBase
{
protected override VisualElement CreateViewGUI()
{
var root = base.CreateViewGUI();
root.AddConsoleView();
return root;
}
}Adds a label that shows performance information.
public class MyDebugView : DebugViewerBase
{
protected override VisualElement CreateViewGUI()
{
var root = base.CreateViewGUI();
root.AddProfileInfoLabel();
return root;
}
}Adds a new tab to an existing TabView.
Adds a TabView and a tab to the target VisualElement.
public class MyDebugView : DebugViewerBase
{
protected override VisualElement CreateViewGUI()
{
var root = base.CreateViewGUI();
var (tabView, scrollView) = root.AddTab("Tab1");
tabView.AddTab("Tab2");
scrollView.Add(new Button(() => { Debug.Log("Button Clicked!"); }) { text = "Click Me" });
return root;
}
}A TextField with undo/redo history.
- Undo:
Ctrl or Cmd + Z - Redo:
Ctrl or Cmd + YorCtrl or Cmd + Shift + Z
public class MyDebugView : DebugViewerBase
{
protected override VisualElement CreateViewGUI()
{
var root = base.CreateViewGUI();
var historyTextField = new HistoryTextField("Input");
historyTextField.RegisterValueChangedCallback(evt => Debug.Log(evt.newValue));
root.Add(historyTextField);
return root;
}
}- Unity 2021.3 or newer
- UIElements (UIToolkit)
This library is under the MIT License.







