User Interface API
Runtime Studio builds its editor UI with UI Toolkit. Register UI extensions from an IEditorModule so they load in a predictable order with the rest of the editor.
Panels
An IEditorPanel creates a docked or overlay UI Toolkit panel. Implement Refresh, Tick, and Dispose when the panel needs to react to the editor state or clean up resources.
using Fullscreen.RuntimeStudio.Runtime;
using Fullscreen.RuntimeStudio.Runtime.UI;
using UnityEngine.UIElements;
public sealed class NotesPanel : IEditorPanel
{
public NotesPanel()
{
Root = EditorStyles.PanelElement("NotesPanel");
Root.Add(EditorStyles.Title("Notes"));
Root.Add(new TextField());
}
public VisualElement Root { get; }
public void Refresh()
{
}
public void Tick()
{
}
public void Dispose()
{
}
}
public sealed class NotesModule : IEditorModule
{
public void Register(EditorModuleBuilder builder)
{
builder.AddDefaultPanel(
PanelDefinition.Left(
"my-game.notes",
"Notes",
_ => new NotesPanel()));
}
}Use PanelDefinition.Left, PanelDefinition.Right, or PanelDefinition.Overlay to choose a location. Definitions can set ordering, default visibility, fixed width or height ranges, and flexible sizing.
Scene tool overlay items
SceneToolOverlayItem adds a button or control to the Scene View overlay.
builder.AddDefaultSceneToolOverlayItem(
SceneToolOverlayItem.Button(
"my-game.spawn",
context => CreateObject())
.WithLabel("Spawn")
.WithTooltip("Create Object")
.Ordered(100)
.Placed(SceneToolOverlayPlacement.SceneViewActions));An item can set its label, tooltip, order, visibility, enabled state, active state, and placement. Use TransformTools or SceneViewActions to place the item with related controls.
Scene Settings menu items
Use SceneSettingsMenuItem for commands in the Scene Settings dropdown.
builder.AddDefaultSceneSettingsMenuItem(
SceneSettingsMenuItem.Button(
"my-game.rebuild",
context => RebuildData())
.WithLabel("Rebuild Data"));The API also supports headers and submenus with SceneSettingsMenuItem.Header and SceneSettingsMenuItem.Submenu.
Component drawers
IRuntimeComponentDrawer controls how a Unity component appears in the Runtime Studio inspector.
using System;
using Fullscreen.RuntimeStudio.Runtime.UI.ComponentDrawers;
using UnityEngine;
public sealed class HealthDrawer : IRuntimeComponentDrawer
{
public Type ComponentType => typeof(MyHealth);
public void Draw(ComponentDrawerContext context, Component component)
{
var health = component as MyHealth;
if (health == null)
{
return;
}
context.DrawFloat("Health", health.Current, value => health.Current = value);
context.DrawBool("Invincible", health.Invincible, value => health.Invincible = value);
}
}Register the drawer with builder.AddDefaultComponentDrawer(new HealthDrawer()). ComponentDrawerContext includes helpers for bool, int, float, vector, and text fields, along with selection and editor state.
Property drawers
IRuntimePropertyDrawer customizes a nested data type instead of a component.
using Fullscreen.RuntimeStudio.Runtime.UI.PropertyDrawers;
public sealed class StatBlockDrawer : IRuntimePropertyDrawer
{
public bool CanDraw(PropertyDrawerContext context)
{
return context.DeclaredType == typeof(MyStatBlock);
}
public void Draw(PropertyDrawerContext context)
{
var value = context.Value as MyStatBlock;
context.FieldDrawer.DrawValue(
context.Parent,
"Power",
typeof(float),
value.Power,
$"{context.Path}.power",
next => value.Power = (float)next);
}
}Register it with builder.AddDefaultPropertyDrawer(new StatBlockDrawer()).
Hierarchy extensions
HierarchyAdornmentDefinition displays an icon beside objects that match a condition. IRuntimeHierarchyContextAction adds right-click actions to the Hierarchy.
public sealed class CreateSpawnAction : IRuntimeHierarchyContextAction
{
public int Order => 100;
public bool Supports(HierarchyActionContext context)
{
return true;
}
public bool IsEnabled(HierarchyActionContext context)
{
return true;
}
public string GetMenuPath(HierarchyActionContext context)
{
return "Create/Spawn Point";
}
public void Execute(HierarchyActionContext context)
{
new GameObject("Spawn Point");
}
}Register the action with builder.AddDefaultHierarchyAction(new CreateSpawnAction()).
FieldInspector and styles
FieldInspector provides the same field UI used by Runtime Studio's built-in inspector. It can draw individual values, object fields, and type selectors.
context.FieldDrawer.DrawValue(
context.Parent,
"Speed",
typeof(float),
speed,
"speed",
value => speed = (float)value);Use EditorStyles for titles, buttons, rows, and panels so custom UI matches the rest of Runtime Studio.