Hello guys, I can not understand how to write a script…I’ll explain: I have two scenes, in the first scene I have an object (A) with attached the Don’tdestroy that in the second scene, I make it active. In the second scene, I have a panel(B) that to make it active, I need to recall the object(A) that at this point is in the hierarchy that obviously does not have the public reference. In a nutshell:
if (A) is active, activate (B). Could you help me?
Look into some form of persistent state such as a UI manager or Game Manager. There are tons of tutorials but the key is to store state from scene to scene in some type of construct that does not get destroyed when the scene changes.
I have a package called Datasacks that can handle it, and lots of other stuff with UI.
Datasacks is presently hosted at these locations:
Trying to understand your question. It sounds like you have a DontDestroyOnLoad GameObject you are trying to pass between scenes, but you have it set to inactive and you are having trouble finding it. I don’t know what this has to do with “static variables” in your thread title.
But most of the “find” methods to find GameObjects require the object to be active. I’d suggest just making it active before scene change, and redesign whatever the object is so it can be active without causing whatever problem you are trying to prevent by keeping it inactive. Hard to say specifically what to do without specific information about it though.
In the main menu, there are four characters to choose from. Each character has its own panel with its features. In each of these panels, there is the ‘choose’ option that if pressed, passes to the second scene where, depending on the character chosen in the first scene, a specific object appears in the second scene? I don’t know if I made myself clear?