Reference asset in UXML

Hi,

I have a custom visual element, which has a custom attribute. This works fine.

I wish to reference an asset (in this case a scriptable object) to pull data from, for example set the label to some text stored in the scriptableObject.
Is it possible to reference an asset from UXML? If not I think it would be neat :slight_smile:

I could put the asset path/asset name as the value, and load the asset, but this isn’t fool proof as paths and names change

Thanks in advance

1 Like

You can’t directly refer to and instance of the Scriptable object directly from uxml for now. You can however, set the binding-path attribute of your label to the name of the serialized property you want to display, then in c# bind the scriptable object to the cloned uxml hierarchy:

myUxmlElements.Bind(new SerializedObject(myAsset));

Hope that helps

Thanks for your reply, I hope that referencing assets in UXML can be considered as a feature request then :slight_smile:

Unfortunately binding does not suit my needs, if I had access to myAsset I could (as per my example) set the label text directly, I do not need it to update or any of that jazz.