gum-property-assignment
Skill659 starsChanged 2 months agoMITView on GitHub
How Gum instantiates runtime objects from save data and applies variables to renderables. Triggers: ToGraphicalUiElement, SetGraphicalUiElement, ApplyState, SetProperty, SetVariablesRecursively, CustomSetPropertyOnRenderable, font loading, IsAllLayoutSuspended, isFontDirty.
In this repository69 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- debuggingSkill
- frb-build-verificationSkill
- frb-pixel-harnessSkill
- gum-architecture-layersSkill
- gum-bundleSkill
- gum-cliSkill
- gum-cross-platform-unificationSkill
- gum-docs-writingSkill
- gum-file-pathsSkill
- gum-forms-behaviorsSkill
- gum-forms-controlsSkill
- gum-forms-default-visualsSkill
- gum-forms-itemscontrolSkill
- gum-forms-theme-importSkill
- gum-iconsSkill
- gum-issue-creationSkill
- gum-kernsmith-integrationsSkill
- gum-layout-engineSkill
- gum-layoutSkill
- gum-localizationSkill
- gum-monogame-renderingSkill
- gum-monthly-releaseSkill
- gum-project-versioningSkill
- gum-raylib-renderingSkill
- gum-releaseSkill
- gum-runtime-animation-chainsSkill
- gum-runtime-bindingSkill
- gum-runtime-fontsSkill
- gum-runtime-hot-reloadSkill
- gum-runtime-syntax-versionSkill
- gum-runtime-systemmanagers-initSkill
- gum-runtime-topologySkill
- gum-runtime-variable-referencesSkill
- gum-samplesSkill
- gum-serviceSkill
- gum-source-linked-projectSkill
- gum-themingSkill
- gum-tool-animationsSkill
- gum-tool-codegenSkill
- gum-tool-copy-pasteSkill
- gum-tool-delete-logicSkill
- gum-tool-dialogsSkill
- gum-tool-errorsSkill
- gum-tool-file-watchSkill
- gum-tool-font-generationSkill
- gum-tool-import-from-gumxSkill
- gum-tool-loggingSkill
- gum-tool-outputSkill
- gum-tool-pluginsSkill
- gum-tool-save-classesSkill
- gum-tool-screenshotsSkill
- gum-tool-selectionSkill
- gum-tool-tree-viewSkill
- gum-tool-undoSkill
- gum-tool-variable-gridSkill
- gum-tool-variable-referencesSkill
- gum-tool-viewmodelsSkill
- gum-unit-testsSkill
- gum-variable-deep-diveSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
When a game loads a Gum project, ElementSave.ToGraphicalUiElement() is the entry point that creates a live GraphicalUiElement tree from a …
- Very specific: line 33
After this, the GUE tree is fully created and has its default state applied.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Gum Property Assignment Reference
For the Forms, visual and Renderable layers this code moves between, see gum-architecture-layers.
Save-to-Runtime Instantiation
When a game loads a Gum project, ElementSave.ToGraphicalUiElement() is the entry point that
creates a live GraphicalUiElement tree from a save element (screen, component, or standard).
Without a loaded Gum project, ElementSave classes are not used at runtime — but StateSave,
StateSaveCategory, and VariableSave are always used (they power the state system on GUE).
ToGraphicalUiElement → SetGraphicalUiElement pipeline
ToGraphicalUiElement (in ElementSaveExtensions.GumRuntime.cs) creates a GUE and delegates
to SetGraphicalUiElement, which does the heavy lifting in this order:
- AddStatesAndCategoriesRecursivelyToGue — walks the inheritance chain (via
BaseType) and copiesStateSaveCategoryandStateSaveentries onto the GUE. - CreateGraphicalComponent — creates the underlying renderable (
IRenderable) viaCustomCreateGraphicalComponentFuncand assigns it withSetContainedObject. - AddExposedVariablesRecursively — registers exposed variable bindings.
- CreateChildrenRecursively — iterates
elementSave.Instances, callsinstance.ToGraphicalUiElement()for each, and parents the child GUE. For screens, children are not parented directly (they useElementGueContainingThisinstead). - SetInitialState — applies the default state's variables via
ApplyState. - Animations — if the project has
ElementAnimations, wires them up.
After this, the GUE tree is fully created and has its default state applied. The GUE's Tag
and ElementSave properties point back to the source ElementSave.
For a deep dive into the full variable lifecycle including Forms state updates and
RefreshStyles, see the gum-variable-deep-dive skill.
Two Paths for Setting Properties on a GUE
Direct property setters (e.g. textRuntime.Font = "Arial") — these are typed C# properties
on TextRuntime or GraphicalUiElement that immediately call helpers like UpdateToFontValues().
String-based path (e.g. SetProperty("Font", "Arial")) — used by ApplyState and
SetVariablesRecursively when processing state variables. This path goes through:
ApplyState / SetVariablesRecursively
→ GraphicalUiElement.SetProperty(string, object)
→ CustomSetPropertyOnRenderable.SetPropertyOnRenderable(...)
→ TrySetPropertyOnText / TrySetPropertyOnSprite / etc.
→ modifies the underlying renderable directlyCustomSetPropertyOnRenderable is the bridge between the string-based variable system and the
actual renderable objects. It lives in Gum/Wireframe/CustomSetPropertyOnRenderable.cs (with
parallel copies in Runtimes/SkiaGum/ and Runtimes/RaylibGum/).
The delegate GraphicalUiElement.UpdateFontFromProperties is wired to the static
CustomSetPropertyOnRenderable.UpdateToFontValues(IText, GUE) at startup. This is how the
string path and the instance method path both ultimately call the same font loading logic.
All CustomSetPropertyOnRenderable statics (including FontService) are wired by
EditorTabPlugin_XNA.StartUp() in the Gum tool. The class itself must not reference DI
containers or service locators. Game runtimes assign FontService directly.
CustomSetPropertyOnRenderable's dispatch tree actually mixes renderable-type and Runtime-type
branches, and which one a property takes isn't obvious from this pipeline alone — see
gum-architecture-layers for why both exist and which one new branches should prefer.
Combining Variables
Several independent variables can combine into one derived value — X/XUnits into position,
Font+FontSize+IsBold+... into a loaded BitmapFont (below), or a boolean opt-out flag alongside
a text/state value into the final displayed string. SetProperty never peeks across variables to
sequence or dedupe this: each contributing setter independently recomputes the full derived value
from whatever is currently live on the object, so any application order converges to the same
result, at the cost of tolerated redundant recomputation (e.g. re-deriving a font twice if both
Font and FontSize land in the same batch).
Layout Runs on Every Assignment
Gum cannot tell when a run of assignments ends (an object initializer, a.Font = ...; a.FontSize = ...;, a state apply), so each setter finishes with its layout already done. Layout results are stored values: AbsoluteWidth returns the width the last layout wrote to the renderable (GraphicalUiElement.Properties.cs IPositionedSizedObject.Width), and X/Y, a parent's size and a stacked sibling's position are stored the same way. Reads are plain field reads with no flush hook, so code may read any of them after any single assignment and must see a correct value.
Fonts are part of this. Text measure (WrappedTextWidth, WrappedTextHeight, DescenderHeight) reads the loaded BitmapFont, so a font setter loads the font before it lays out (LoadFontFromProperties). Only a caller-declared batch (SuspendLayout, or IsAllLayoutSuspended during load) defers the font and the layout. Do not propose building the font or running layout "later" (next layout, next draw, first read): that leaves stored layout results stale for the element, its parent and its siblings.
Font Deferred-Loading System
Loading a .fnt file is expensive. A text element has ~6 font-related properties (Font,
FontSize, IsBold, IsItalic, UseFontSmoothing, OutlineThickness), so without deferral each
property assignment during a screen load triggers a separate disk read.
The Flag: isFontDirty
GraphicalUiElement.isFontDirty is set to true instead of loading the font when layout is
suspended. It is consumed (font loaded, flag cleared) by UpdateFontRecursive().
Where deferral happens
Both paths defer for IsAllLayoutSuspended and instance-level IsLayoutSuspended (#4567): the
direct setters through GUE.UpdateToFontValues(), and the string path because it now calls that
same method.
Where fonts actually load
Three code paths consume isFontDirty:
WireframeObjectManager(Gum tool screen load): afterIsAllLayoutSuspended = false, callsRootGue.UpdateFontRecursive()thenRootGue.UpdateLayout(). At this point all elements havemIsLayoutSuspended = false(becauseApplyStateskipsSuspendLayoutwhen the global flag is set), so every dirty text element loads its font in one pass.ResumeLayoutUpdateIfDirtyRecursive(instance-level suspension): setsmIsLayoutSuspended = falseon the current element before callingUpdateFontRecursive(), then recurses to children. This ordering is critical — ifmIsLayoutSuspendedwere still true whenUpdateFontRecursiveruns, that element's font load would be skipped.UpdateLayoutitself (#2999): each node realizes its own deferred font at the top of its layout body, before it measures itself. So a bareUpdateLayout()after liftingIsAllLayoutSuspendedloads deferred fonts too — callers don't have to also callUpdateFontRecursive. The load's own follow-upUpdateLayoutis suppressed during this flush viaGraphicalUiElement.SuppressLayoutFromFontChange, since the in-progress pass already sizes the element;isFontDirtyis cleared before the load so the suppressed re-layout can't re-trigger it.
Backend font loaders (the UpdateFontFromProperties delegate) never lay out. The element does it in
GraphicalUiElement.LoadFontFromProperties, once, when the text's measured size or descender
changed. The string path reaches it through graphicalUiElement.UpdateToFontValues().
Why deferral is font-specific: 1:1 file references load immediately
Deferral exists only because ~6 font properties (Font, FontSize, IsBold, IsItalic,
UseFontSmoothing, OutlineThickness) collapse into a single cache filename — without
isFontDirty, each property assignment during a load would trigger a redundant intermediate disk
read of the same .fnt.
A 1:1 file-reference asset has no such many-to-one mapping: one property holds one path that maps
to one file. So textures (SourceFile → AssignSourceFileOnSprite) and render-target shaders
(SourceShaderFile → AssignSourceShaderFileOnContainer, #3206) resolve immediately on
assignment — no dirty flag, no deferral. Both cache the resolved asset in LoaderManager by
normalized path so a file referenced by multiple elements loads once.
Shader parameter variables (#7010). A Container variable named <stem>_<Param> (or ..__X..__W
per component, ShaderVariableNaming) is claimed by the container dispatch's default branch and
routed by ShaderParameterVariables onto the renderable's ShaderParameters. It sees only a name
and value, so it keeps a per-container layer (raw variable values, shader file, and for each driven
parameter the value it covered) and recomputes per parameter whenever a variable, SourceShaderFile or the legacy
ShaderParameters text changes: any arrival order gives the same result, the variable beats the text
for its parameter, and a variable with another shader's stem is inert. The stem matches ignoring case,
so names differing only in stem case address one parameter. A value set in code over a driven
parameter survives the variable going away. A container with an underscore-named unknown variable and
no shader file still pays a small layer allocation (accepted; deferring it would break order
independence). Never call
ShaderParameterText.Assign from a dispatcher; call ShaderParameterVariables.AssignText.
Key Files
| File | Role |
GumRuntime/GraphicalUiElement.SetValuesAndStates.cs | SetProperty, ApplyState |
GumRuntime/GraphicalUiElement.Text.cs | UpdateToFontValues (instance), UpdateFontRecursive (isFontDirty is declared in GraphicalUiElement.cs) |
Gum/Wireframe/CustomSetPropertyOnRenderable.cs | String-path dispatch + static UpdateToFontValues(IText, GUE) |
GumRuntime/ElementSaveExtensions.cs | SetVariablesRecursively — iterates state variables and calls ApplyState |
Gum/Wireframe/WireframeObjectManager.cs | Sets IsAllLayoutSuspended around screen load, calls UpdateFontRecursive after |
Tool/EditorTabPlugin_XNA/MainEditorTabPlugin.cs | Wires all CustomSetPropertyOnRenderable statics in StartUp() |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

