Variable function for a Back-Button -> absolute Newbie

Hello there,

i am new to unity, so excuse me if i dont know exactly how to adress my problems…

I am building my first App with Unity right now. It’s some kind of a guided Meditation App.

Here is a scribble of the Main-Function-Screen:

So the Main-Function is: If you press somewhere on the screen (inside the red field), you will see the Next Meditation-Screen (so only the Text under the red field changes). Also, you will here an Audio-File, where someone is reading the Text. By pressing/touching the red field again, you will see the next Meditation-Screen and so on.
In the bottom left corner is a Back-Button, which will bring you back to the last Meditation-Screen.

Solving the “Switch to next Meditation-Screen” problem was “easy”. The Meditation-Screen (with the Text and the Audio) is a button. So i set the “GameObject.SetActive” in the on Click feature inside the Inspector for the pressed button to “not active” and for the next button to “active”

But for the Back-Button in the bottom left, i want to use a script.
I mean i could place a Back Button for every Meditation-Screen, but i would love to solve this with a script.

So the function of the Back-Button should change, depending on the Meditation-Screen, that is shown right now.

I never done Scripting before, i am totaly new to it. But i “guess”, it sould be something like this:

if (Res_02_Button = active)
onClick.BackButton.setActive.Res_02_Button = false
onClick.BackButton.setActive.Res_01_Button = true

else if (Res_03_Button = active)
onClick.BackButton.setActive.Res_03_Button = false
onClick.BackButton.setActive.Res_02_Button = true

I mean…this code is complete bullshit, but i hope you can understand my thoughts here.
Also, the challenge to descripe something you are new in, is even higher when its not your native language. So sorry for that :smile:

It would be nice if someone could help me with that code. If you can not understand what i mean, i can try to describe it in another way!

thanks in advance for any help!

Check into some UI tutorials. There are ones by Brackeys on Youtube as well as some great ones buy a guy named Ray Wenderlich… both of these people cover the basics really solidly, and there are many other UI tutorials, including those directly from the Unity site.

1 Like

A good package you could try is the free MaterialUI, whose ScreenView component is essential for building a “router,” which is sort of essential for building a navigation.

1 Like

do you know any keywords for which i could search?

For back button, use stack collection. Push every screen onto stack and when user presses back button, hide current sceen and pop previous one from the stack.

2 Likes

https://materialunity.com

1 Like

MaterialUI costs 50$ and is having some bad reviews because of some heavy bugs.