- Home /
SetActive Button from another scene isn't working in build
Goal: Set an inactive button to active by clicking a button in another scene.
Scene1 - Button A (inactive)
Scene2 - Button B
Scene2 - Button B's inspector, Under button script -> on click () -> Button A Object , GameObject.SetActive, checked true
In-Game view: Button B is clicked
Return to Scene1, Button A is now active, everything is great!
However, after building and running the project this is no longer working, when Button B is clicked Button A remains inactive.
Running this locally it works fine, but in the build, it doesn't?
Am I missing something? Any ideas are appreciated.
I think it's because they are different scenes.. Try using a scriptable object bool to store the state. so in scene 2 you set the bool to true, then when you load scene 1 you set the button active to your bool.
You can achieve this with a static bool through a script that is not in necessary in any scene and when the scene is starting check the status of that bool and make the appropriate actions (enable/disable).
Your answer
Follow this Question
Related Questions
2020 Unity. How do I set children of a parent object to be active? 2 Answers
Distribute terrain in zones 3 Answers
one button to hide and unihed gameobjects 0 Answers
Make a gameobject inactive and active 0 Answers
How to reactivate items ? 4 Answers