10+ UI Buttons enable/disable

So here is the thing. I am working on a walkthrough project where the camera is on some kind of rail track. When the camera comes to a certain point there will 2 buttons pop up. You can go to “Room X” or “Room Y” and then when you select one of those you will move to that position. Then 2 new UI buttons will pop up wether you want to go back or go to “Room Z” for example.

In my project I will have a lot of UI buttons that will de disabled and enabled. What would be the most efficient way to accomplish this? I can create a lot of scripts and place them on the buttons. But I don’t think that is the best option?

Best,
Maarten

You can tag each button entity, then using ‘findByTag’ (https://developer.playcanvas.com/en/api/pc.Entity.html#findByTag), you can get an array of all entities with that tag and enable/disable them for a for loop.

eg

var entities = this.app.root.findByTag('someTag');
for (var i = 0; i < entities.length; i++) {
    entities[i].enabled = false;
}

You don’t need to create multiple UI.

Just create a simple UI with 2 button and change the text in the text field. If the number of filed will change. Then add a scroll view to handle you view and add a Layout group to the content so its arranges the element automatically. (Don’t show the horizontal and vertical handler if you don’t need them.)

Just changed enabled state after each time the user picks an answer and the train or what ever the object has moved.

So you would basically move the player Object in the game and show the same UI with different context.