API reference
API overview
The engine's API has two sides: what you write inside a .dcue component, and what game code calls from outside. This page maps both to their namespaces.
Where to look
| You want to | Page |
|---|---|
| Declare state, props, effects and lifecycle in a component | Component script |
| Write markup: expressions, directives, blocks | Template syntax |
| Show an app or a page, and reach it from a MonoBehaviour | Views and UiSystem |
| Change elements, set styles without allocating, find things by name | DOM, styles and queries |
| Handle pointer and keyboard events; send input from code | Events and input |
| Use signals and reactive collections directly | Reactivity |
| Read and switch texts | Locale |
| Register cameras, models, videos, materials, font packs | Unity content and fonts |
Namespaces
| Namespace | Main types |
|---|---|
DevCore.UiEngine.Unity.Hosting | DevCoreApp, DevCore3DView, AppView, UIView, UiSystem, UIRenderMode, UIScaleMode, FontFallbackSettings, UIStatsOverlay |
DevCore.UiEngine.Unity.Elements | UnityElements |
DevCore.UiEngine.View | DocumentView, ViewResources, ClientRect, the GetBoundingClientRect and ElementFromPoint extensions |
DevCore.UiEngine.Dom | Document, Element, Node, Text, InlineStyle |
DevCore.UiEngine.Dom.Events | Event, EventType |
DevCore.UiEngine.Input | PointerEvent, KeyboardEvent, WheelEvent, FocusEvent, InputEvent, DocumentInput, PointerInput, NavigationDirection, the pointer-capture extensions |
DevCore.UiEngine.Css.Properties | CssPropertyId |
DevCore.UiEngine.Css.Values | CssUnit, Rgba |
DevCore.UiEngine.Components | Component, ComponentRegistry, ContextKey<T> |
DevCore.UiEngine.Reactivity | Reactive, Signal<T>, StateList<T>, StateDictionary<K, V>, ReactiveScope |
DevCore.UiEngine.Localization | Locale, LocaleKey, LocaleTable, PluralRules |
Your game's own components are in the namespace of their folder: GameUI for Assets/DevCoreUIEngine/App, GameUI.Components for its Components folder.
Assembly references
The engine is split into assemblies named after its namespaces. An assembly definition that holds .dcue files, or game code that calls the engine, references the assemblies it uses: for example DevCore.UiEngine.Input for PointerEvent, DevCore.UiEngine.View for ElementFromPoint, DevCore.UiEngine.Css for CssPropertyId, and DevCore.UiEngine.Localization wherever there are components.
Conventions
- Main thread. The engine runs on Unity's main thread; call it from there.
- Batched. Changes mark things dirty. The page updates once per frame, after
LateUpdate, however many values changed. - Allocation-free paths are marked. Typed style setters, name queries,
Text.SetDataand template expressions allocate nothing. String-based setters parse and allocate. - Events are pooled. An event object is valid only while its handler runs; copy what you need out of it.
- Web names, C# casing.
querySelectorisQuerySelector,classList.toggleisClassList.Toggle,clientXisClientX. - Lengths are CSS pixels unless a unit is given.
A complete example
using DevCore.UiEngine.Css.Properties;
using DevCore.UiEngine.Css.Values;
using DevCore.UiEngine.Dom;
using DevCore.UiEngine.Unity.Hosting;
using UnityEngine;
public class HudController : MonoBehaviour
{
Element marker;
void Start()
{
var app = DevCoreApp.Current;
marker = app.Q("player-marker"); // look up once, keep it
}
void Update()
{
Vector2 p = Minimap.PositionOf(transform); // your game's code
marker.Style.Set(CssPropertyId.Translate, p.x, p.y, CssUnit.Px); // no restyle, no layout, no paint
}
}