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
-
objectStyleBackgroundImageResolver
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
backgroundImagefrom the given Texture2D, ranked below a BackgroundImage.
- Clear(VisualElement)
Withdraws the utilities' background image — the one Apply(VisualElement, Texture2D?) sets, which a gradient utility's bake shares (same gate as Apply): a BackgroundImage shows if the element declares one, else the stylesheet's.
- 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
classNamematchesbg-[addr:<key>]and the Addressable key successfully resolved to a Texture2D.