- Home /
Transport objects between scenes.
Hi there!
So, I've setup a persistent Game Object, and I want that Game Object to store several informations, including Player Informations. One of those informations is the Player Ship, that it's assigned as a Game Object variable.
I've scripted it out, but, the stored Game Object variable will go "Missing", after I load a new scene. Now, I know of DontDestroyOnLoad(GameObject), but that's not exactly what I want, since there's no way to remove that status later, without deleting the object and recreating it (Again, one of the things I don't wanna do).
So, is there a way to store such information (which will include more than numbers and strings)?
Also, I'm using Unity Free.
Thanks in Advance, João Borrego
Thanks for the answer... Will try to apply it and then return to say if it worked or not. (This pretty much means I'm back to the drawing board for that function xD)
Ok, thanks, it worked. Can you please copy the content of your comment into an answer, so I can tag it as the correct answer?
Answer by AlucardJay · Aug 29, 2013 at 10:16 PM
Before changing scene, store your values in PlayerPrefs, then when loading the new scene, read the values back from PlayerPrefs : http://docs.unity3d.com/Documentation/ScriptReference/PlayerPrefs.html
For the PlayerShip GameObject, you can use the Resources folder. Load a prefab, instantiate it and assign it to the GameObject variable : http://docs.unity3d.com/Documentation/ScriptReference/Resources.html