Table of Contents

Class StyleBackgroundImageResolver

Namespace
Velvet
Assembly
Velvet.Docs.dll

Parses utility-style arbitrary-value background-image className syntax and applies the result as an inline UnityEngine.UIElements.IStyle.backgroundImage.

public static class StyleBackgroundImageResolver
Inheritance
object
StyleBackgroundImageResolver

Remarks

Supports the bg-[addr:<key>] syntax, which loads a Texture2D from the Addressables system synchronously via Velvet.AddressableAssetCache. This mirrors a CSS background-image: url('./icon.png') expressed as a className — at runtime in UI Toolkit the equivalent has to go through Unity's asset loading, hence the addr: prefix to make the lookup mechanism explicit.

Methods

Apply(VisualElement, Texture2D?)

Sets the element's inline backgroundImage from the given Texture2D, through the SceneView ownership gate (a live camera feed keeps the slot and defers this value).

Clear(VisualElement)

Reverts the inline background-image to the USS default (same gate as Apply).

HasBackgroundImageClass(string[])

True when any class is a bg-[addr:<key>] background-image utility (a cheap prefix check, no Addressable load). Lets another owner of the inline background-image (the gradient background) avoid clearing it when this resolver owns the image.

TryParse(string, out Texture2D?)

Returns true when className matches bg-[addr:<key>] and the Addressable key successfully resolved to a Texture2D.