How to add multiple "pointerdown" scripts to one object


I’m not a professional developer and can’t completely write complex scripts, but was successfully using those that were described in the tutorial videos, but even some very simple actions won’t work.

For example, I have a button which changes the state of the object from visible to not visible. How can I add more complex actions to the same button? For example, I want a disappeared object to appear back again by tapping on it one more time?

I tried adding an additional script to the same object or to the same script, but nothing seems to work. Need help!

Video Play in front of Photosphere

I’m afraid you will need some scripting! :wink:

One way is to use a variable and execute things depending on its value.
For example:

var isVisible = true;
parent.on("pointerdown", (e) => {

	if(isVisible == true){
	    isVisible = false;
	    isVisible = true;

Of course, instead of true/false, you can use a simple integer (0,1,2,3…) to have any number of states you want…

Menu system: pushing button twice