How to change texture on a button press?


This is my sample diagram describing the problem

Can you describe the problem please? It isn’t clear from the diagram and the topic title

I control the four pictures on the big screen to switch in turn by clicking the four buttons in the lower right corner
CompanyWeb_format20220621 | Launch (playcanvas.com)
thanks.

It’s hard to tell from the project you’ve just linked to because there is so much going on.

It sounds like you want to press a button and move a camera to look in a specific direction?

In the “Click Here” part, what I want to achieve is to switch the pictures on the big screen by clicking the button in the “POSTER” at the bottom right, so as to achieve an interactive way, not the current way. :thinking:
thanks.

I’m still having trouble following.

Do you want to it so that you can click on any of these buttons

And it changes the image on the poster?

If so, which part are you having trouble with? Input etc?

Make a script where you get the material and the texture as assets (they can be arrays). Then something like this (not sure if you want difusse, emissive, etc)

mat.emissiveMap = texture.resource;
mat.update();

1 Like


Like this.

My coding skills are poor, my entire project is using other people’s code, so I have no clue when trying to implement my own ideas :face_holding_back_tears:

I’m afraid I can’t implement the exact code you are looking for as it’s not a small feature

The way I would do something like the video you posted above is to use the PlayCanvas UI in World Space and use the UI buttons as a toggle group to change between images.

If you don’t need the image transition, you can just use the UI buttons in World Space and when you click on one, change the image/texture on the model

Thank you for your reply.
There is a word in China called “障眼法”
I’m thinking of using “translate3d()” as a trick.