How to make ui only activate once
I have a scene with a home ui and a respawn ui. The goal is when I click the start button it takes me into the game(which I already did). Then when I die the respawn ui pops up with a retry button when you click the button it takes you back into the game. Pretty simple. The problem is I don't know how to restart the game without using scene management, but if I reset the scene the home ui comes back. How would I solve this problem?
Answer by xxmariofer · Feb 05, 2019 at 10:23 PM
you need to use scene management, but you can create an static var that can be marked to true when you have already clicked it, and compare in the awake the bool value, and activate one or another depending of the var.
Do you mean like for example homeUI.SetActive(true). I tried this and it didn't work. I'm a complete beginner so I don't quite understand what you're saying but i think this is what you're talking about.
you can create a var like
public static bool hasButtonBeingPressed = false;
and set it to true when it gets pressed(just whennyou are clicking the button and changing of scene)
and in the awake or start compare if hasButtonBeingPressed is false and desplay with the SetActive method to true or false.
I tried but had no luck. I don't think I'm doing anything wrong.