[SOLVED] Swap texture of image element

I am working on a Casino Table game. In that game we have a different bet amount like 1$, 5$, 10$, 25$, 50$, 100$.
Right now, I am creating the Amount Entity with Image Element Component as a hidden Entity.
We just show the Entity of Amount on a Mouse Click.
I want to create a Custom Entity which is loaded on Script Load.
Also i want to update that default Element Amount with other Textures.
Basically i want to update the Texture of Amount Entity Image Texture component. On the click on specifies entities.
Customize Texture image Element for single entity.
The game is like a Casino Table game with spinner.

Please look at this project:

https://playcanvas.com/project/624998/overview/forum-change-texture

1 Like

Thanks a lot @will. This will give me a lot of Help.

Hey. He is asking to change the texture of an element not of a model. Is there any scene that serves as an example? thanks

Hi @fsg,

You can easily edit a texture of an element by changing its texture property:

this.entity.element.texture

Once you have your texture object or asset, just set the above property on the element to the desired image, and it will change.

For more information on the properties available to you on ElementComponents, check out this page:
https://developer.playcanvas.com/api/pc.ElementComponent.html#texture

I hope this is helpful.

1 Like