hi everyone!!!
in a scene i have a UI menu and i need transfer 3 variable from this menu to another scene.
i am noob in unity and i don’t know if this is possible.
if this isn’t possible… give me a recommedation pls.
i read some post and the people said i need to create a prefab, but i don’t understand why. and i don’t know if is any prefab or a prefab o my menu.
but my menu is dynamic, and i don’t know if this afect a prefab of my menu.
the variables that i need is a array and 2 int variables.
Either use static variables, a script that is set to dontdestroyonload, or playerprefs. There are many ways of transferring data between scenes.(these are the more common ones) Since you are doing an array, the first two may be the better choice, depending on what is in the array.
1 Like
There are so many ways you can do this.
But for very basic one I would say look in to how to make singleton in Unity. This would be one ok way to have object that is alive between different scenes and use it for some config data for game that you need to carry, or music playing between different scenes without interruption, many things.
If you just want to transfer simple variables between scenes (like current health and things of that nature) you can create a java script or C# file and call it game manager and put the variables in that script. If you attach the script to the UI in each scene the variables should show up in each scene.