[SOLVED] Get an texture from its id and assign it to an ui image

Trying to get a texture from its id and assing it to a image element. Not sure how to do this and any help is appreciated.

Hi @Granted,

So if you have the id you can get the relevant asset and assign it to an element component like this:

const asset = this.app.assets.get(3532503);
this.entity.element.texture = asset.resource;

Just make sure that asset is loaded (use the preload property, set it to true), otherwise you need to load it before using it.

3 Likes

thank you