🌐 中文文档
RicKit RDebug is a Unity-based debug panel utility for quickly creating custom runtime debug UIs. By inheriting from the abstract RDebug class, you can easily add buttons, input fields, and more for runtime debugging and parameter tweaking.
- One-click creation of a debug panel.
- Supports common controls like buttons and input fields.
- Flexible layout options (vertical/horizontal).
- Customizable button/input field styles (color, font, etc.).
- Designed for Unity MonoBehaviour workflow.
- Create a new class that inherits from
RDebugand implement theOnShow()method. You can also override properties for customization.
using RicKit.RDebug;
using UnityEngine;
public class MyDebugPanel : RDebug
{
protected override void Awake()
{
// Customize styles in Awake
TextColor = Color.yellow;
BgColor = new Color(0.2f, 0.2f, 0.2f, 0.8f);
// BgSprite = ... // set a custom background image if desired
base.Awake();
}
protected override void OnShow()
{
UsingHorizontalLayoutGroup(() =>
{
CreateButton("customBtn", "My Button", () => Debug.Log("Button clicked!"));
CreateInputField("customInput", "Input", value => Debug.Log($"Input: {value}"));
});
}
}protected abstract void OnShow()- Implement this to define the content of your debug panel.
-
protected Button CreateButton(string key, string name, UnityAction onClick, int width = 100, int height = 100, int fontSize = 30)- Add a button to the panel.
key: Unique identifier for the button.name: Display text.onClick: Callback when button is pressed.
-
protected InputField CreateInputField(string key, string name, UnityAction<string> onValueChanged, int width = 100, int height = 100, int fontSize = 30, string defaultValue = "")- Add an input field.
key: Unique identifier.name: Label text.onValueChanged: Callback on text change.
-
protected GameObject CreateLabel(string key, string name, int width = 100, int height = 100, int fontSize = 30)- Add a label (display-only text) to the panel.
-
protected void UsingHorizontalLayoutGroup(Action action, int height = 100)- Group controls horizontally.
-
public void OnHide()- Manually hide the debug panel and clear controls.
protected Dictionary<string, GameObject> Components { get; }- Stores references to all created UI elements (buttons, input fields, labels, etc.) with their corresponding keys.
protected Color TextColor { get; set; }protected Color BgColor { get; set; }protected Sprite BgSprite { get; set; }
- Must be used within a Unity project.
- Attach your custom debug class to a GameObject in your scene.
- Style and layout can be freely customized.
Apache License 2.0
See Assets/RicKit/RDebug/CHANGELOG.md for the latest updates.
Recent changes (v1.1.0):
- Refactored the
RDebugclass for more effective UI component management. - API changes:
- All control creation methods (
CreateButton,CreateInputField, etc.) now require a uniquekeyparameter as the first argument. - Added
CreateLabelfor display-only text. - Improved panel clearing and layout group management.
- Exposed
Componentsdictionary for managing and accessing all created UI elements.
- All control creation methods (