User Interface
Last updated
PanelDefinition.Left(...)
PanelDefinition.Right(...)
PanelDefinition.Overlay(...).Ordered(100)
.HiddenByDefault()
.Widths(320f, 220f, 500f)
.Heights(400f, 250f, 700f)
.Flexible()builder.AddDefaultSceneToolOverlayItem(
SceneToolOverlayItem.Button(
"my-game.spawn",
context =>
{
CreateObject();
})
.WithTooltip("Create Object")
.Ordered(100)
);.WithLabel("Spawn")
.WithTooltip("Create Object")
.Ordered(100)
.VisibleWhen(context => true)
.EnabledWhen(context => true)
.ActiveWhen(context => false).Placed(SceneToolOverlayPlacement.TransformTools)
.Placed(SceneToolOverlayPlacement.SceneViewActions)builder.AddDefaultSceneSettingsMenuItem(
SceneSettingsMenuItem.Button(
"my-game.rebuild",
context =>
{
RebuildData();
})
.WithLabel("Rebuild Data")
);SceneSettingsMenuItem.Header(
"my-game.header",
"My Tools"
);SceneSettingsMenuItem.Submenu(
"my-game.options",
"Options",
context => BuildItems()
);using System;
using Fullscreen.RuntimeStudio.Runtime.UI.ComponentDrawers;
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
);
}
}builder.AddDefaultComponentDrawer(
new HealthDrawer()
);context.DrawBool(...)
context.DrawInt(...)
context.DrawFloat(...)
context.DrawVector2(...)
context.DrawVector3(...)
context.DrawText(...)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
);
}
}builder.AddDefaultPropertyDrawer( new StatBlockDrawer());builder.AddDefaultHierarchyAdornment(
new HierarchyAdornmentDefinition
{
Id = "my-game.spawn",
Tooltip = "Spawn Point",
IsVisible = go =>
go.GetComponent<MySpawnPoint>() != null
}
);builder.AddDefaultHierarchyAction(
new CreateSpawnAction()
);context.FieldDrawer.DrawValue(
context.Parent,
"Speed",
typeof(float),
speed,
"speed",
value => speed = (float)value
);context.FieldDrawer.DrawObjectFields(
context.Parent,
settings,
"settings",
0
);context.FieldDrawer.DrawTypeSelector(
context.Parent,
"action",
typeof(MyAction),
currentType,
selected => Create(selected),
"Select Action"
);parent.Add(
EditorStyles.Title("Settings")
);parent.Add(
EditorStyles.Button(
"Reset",
ResetSettings
)
);var row = EditorStyles.RowElement();var panel = EditorStyles.PanelElement("MyPanel");