So if you want to keep an object or script that keeps up variables (or for any other reason) when you go from scene to scene, you need to attach a don't destroy on load static function, which goes something like this: function Awake () { DontDestroyOnLoad (transform.gameObject); } The Awake function is call only once, when all the objects in the scene have been created. Read more about it here . DontDestroyOnLoad has what ever is in the ( ) to not be destroyed when creating a new scene. (transform.gameObject) is what will not be destroyed when the new scene is loaded, in this case, it will be the game object and all it's children the script is attached to.
Comments
Post a Comment