- Home /
Modify button from another scene
Let's say I have two scenes: MainMenu Scene1
In my Scene1, I have a script, which give a result like that: " if (...){ print(...) and here, I want to modify the text/the availability of a button from MainMenu
That button is actually going to transfer you to Scene2, but that doesn't matter.
Is it possible to do that ?
You can make a GameObject flagged with DontDestroyOnLoad and keep such variables in that.
Answer by jeffreymarkbaldridge · Dec 22, 2014 at 05:59 PM
First, I am not entirely sure what you are asking. So you have a button in the MainMenu scene, and you want to use the same button in the Scene1 scene? You could make the button a prefab, and have a SceneManager object, which is persistant between scenes, that keeps track of what scene you are on and what scene is next, then just have the button's code tell the SceneManager to go to the next scene. The SceneManager would need a function called something like NextScene(), which the button calls, that would progress the game to the next scene. So you don't really change the button between scenes at all. Hope this helps.
Your answer
![](https://koobas.hobune.stream/wayback/20220613174655im_/https://answers.unity.com/themes/thub/images/avi.jpg)