Slide button based on "User Interface - Stats Counter"

So for this I need to insert names of button into progress bar code!?

I think you don’t need the old buttons anymore.

I will have to see the code of your current switch bar to give a useful answer.

I think you need to insert the name (or id’s) of the scènes into progressBar. After the player click the middle button you can switch to that scene.

this is what I have…
image

I don’t understand what you are trying to achieve with this progress bar script. If you want to switch between scènes you better can use this tutorial: https://developer.playcanvas.com/en/tutorials/ui-elements-stats-counter/

You can change 1/10 for scene1, 2/10 for scene2, etc.

I see your progressBar is a part of that tutorial but I don’t think you need that. You need a button instead. You only adjust the function and text of the middle button with the left and right buttons.

Understood, let me check it…

Since I don’t know how to do it correctly I would do something like this when the right button is pressed:

if (buttonScene1) {
    buttonScene2;
}
else if (buttonScene2) {
    buttonScene3;
}
else if (buttonScene3) {
    buttonScene1;
}

And with the left button the same but descending.

This is not an exact code but just to give you an idea.

smth like this…

image

Yes. Just change the text of the button when clicking left or right. And if the middle button is clicked, check the text of the button and switch to that scene.

you mean this!?

I assume that each scene has a name recognizable to the player, so that the player knows which scene he chooses?

Yes

Do you already create a button in the middle instead of the progress bar?

You mean a simple button that I used for changing scenes in previous topic!?

Yes. You place the button in the middle instead of the progress bar.

Step 1: Find out how to change the text inside a button by script.
Step 2: Create a function to change the text of the button to the previous scene name when the player pressed the left button or to the next scene name when the player pressed the right button.
Step 3: Create a function to check the text of the middle button when the player pressed it and switch to that scene.

Can I add this tasks at the end of the code, or I need to find the right place for it!?

Yes, I think that is a good place to create that functions.

Are you succeeding?

I will go on tomorrow, 50% of task is done, I know what tasks I need to solve…

1 Like

Hi,

If I want to insert a set names of scenes in slide button from “Change Scene Script” to “Slide Button Script” how do I need to write it correctly!?

As far as I’m aware, names are something you’ll have to type yourself using the text elements. You can then enable and disable required text elements by using findByName.