"Runtime textures for UI panels must be assigned from C#"
You create a Texture at runtime (e.g. a minimap, heatmap, or procedural preview) and want to display it in a Razor UI panel. Setting background-image in SCSS doesn't work — it only accepts asset path strings, not runtime texture references.
SCSS background-image: resolves a path string to a compiled asset at load time. A Texture created in C# at runtime has no asset path — it exists only in memory.
1. Create the texture
var tex = Texture.Create(width, height)
.WithFormat(ImageFormat.RGBA8888)
.WithDynamicUsage() // makes repeated Update() cheap
.WithName("minimap")
.Finish();2. Fill and update
var colors = new Color32[width * height]; // row-major
// ... fill colors ...
tex.Update(colors, 0, 0, width, height);Color32 fields are lowercase r, g, b, a. Use .WithDynamicUsage() so you only recreate the texture when dimensions change — otherwise just call Update in place.
3. Assign from code-behind
@ref a Panel in the Razor markup and set the texture in OnTreeBuilt():
protected override void OnTreeBuilt()
{
// @ref is a new Panel each rebuild — re-assign here
MapPanel.Style.BackgroundImage = _texture;
}The engine's own PreviewImage component uses this exact pattern. SCSS styles are resolved statically against the asset system; runtime textures bypass the asset system entirely and must be wired through C#.