Custom Texture attribute

When creating a custom element and its UxmlTraits, you can use classes such as UxmlStringAttributeDescription to define custom attributes. But the *AttributeDescription classes are limited to a small set of mostly primitive types such as string or int.

How do we define a Texture2D or a Sprite attribute?

Would like to know this as well

Hello, this is not doable at the moment in UXML.

The only workaround is to use custom USS properties and assign them as variables in raw USS (if you were using the UI Builder).

Edit: you can declare a CustomStyle and use it just like the example below.
You can assign a reference with the url(“…”) function.

Any news on when this will be possible?

I guess this is what you are looking for New feature : Drag and drop assets on your custom controls

1 Like