Resource providers¶
Tick UI looks up fonts, icons, images, and shaders through a
chain of resource providers. The bundled DefaultTickConfig sits
at the bottom as the always-on fallback. User-supplied providers
layer on top in priority order. This page explains the chain, how
to add providers in the Inspector or at runtime, and where lookup
order matters.
The composite chain¶
CompositeResourceProvider walks an ordered list of providers and
returns the first hit per TryGetFont, TryGetImage, or
TryGetShader. If a provider does not have a match, the lookup
falls through to the next provider in the list.
The default order, set up by BaseGameUI:
- User-supplied providers from the
Resource Providersarray on theBaseGameUIInspector. Index 0 is checked first. - The bundled
DefaultTickConfig, appended automatically as the lowest-priority fallback.
The bundled default ships the roboto_mono font in fourteen size
variants (12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, and
64), the shape and text shaders the drawer needs, and a small
icon set. A project that defines no providers still renders
correctly because every lookup falls through to the default.
Wire providers in the Inspector¶
BaseGameUI exposes m_resourceProviders as an array in the
Inspector, labelled Resource Providers. Add
GUIResourceProvider assets in priority order. Tick UI
appends the bundled default internally. Do not include it in the
Inspector array.
For authoring a GUIResourceProvider asset (creating it,
populating fields, using the bulk-import toggles), refer to
Author a resource provider asset.
For the narrower task of registering a single font, refer to
Add a custom font. For the broader
theming workflow, refer to Theming.
Push and remove providers at runtime¶
BaseGameUI.ResourceProviders exposes the underlying composite at
runtime. Use Push to insert a provider at the highest priority,
and Remove to take it back out:
m_baseGameUI.ResourceProviders.Push(localePack);
// later, when the locale changes again
m_baseGameUI.ResourceProviders.Remove(localePack);
The push-and-remove pattern fits localisation packs, theme swaps, and modded asset loads.
What providers return¶
A GUIResourceProvider carries three lookup tables, each consulted
through a typed TryGet*:
| Method | Returns | Used for |
|---|---|---|
TryGetFont(name, size, out font) |
A Font matching the name and size. |
Text rendering. |
TryGetImage(name, out texture) |
A Texture matching the name. |
Icon and image draws. |
TryGetShader(name, out shader) |
A Shader matching the name. |
Drawer material setup. |
Each method returns false when the provider does not have a match.
The composite then asks the next provider in the chain. If no
provider matches, the call returns false and the caller falls back
to a default behaviour. A missing font logs a warning. A missing
image renders nothing.
How shaders resolve through the chain¶
Shape and text shaders ship in the bundled default, so most projects keep them as-is. The chain consults user providers first, which lets a project supply pipeline-specific shader variants when needed. A user provider with no shaders defined falls through to the bundled default.
A custom provider with a half-populated shader list (some shapes defined, some not) produces pink materials for the missing shaders. Populate the full set, or remove the shader list entirely so the default supplies the shaders.
For the integration mechanics that consume these shaders, refer to Drawer and batching and Render pipelines.
Pitfalls¶
A user provider shadows the default. : The user provider lists a font with the same name as the default. The user version wins. Rename the font in your provider, or remove it to use the default.
Pink materials at runtime.
: The provider chain is missing the bundled default. The standard
BaseGameUI flow appends the default automatically, so a
missing default usually means a custom CreateUI override
skipped the append step. Append the default in the override.
A font lookup returns false for an expected size.
: GUIResourceProvider carries a list of size variants per font.
Add the missing size to the provider, or accept the fallback to
a different size.
A runtime push is not visible.
: The push happened before the BaseGameUI instance finished its
Start. Wait for Start to complete (or check
BaseGameUI.ResourceProviders is non-null) before pushing.
Additional resources¶
- Author a resource provider asset: step-by-step for the asset itself, including the bulk-import toggles.
- Add a custom font: the narrower procedure for registering a single font with the chain.
- Theming: the broader workflow including colours and icons.
- Architecture: where the provider lookup is
threaded through
DrawerandBaseGameUI.