Makes the object target not be destroyed automatically when loading a new scene.
// Make this game object and all its transform children
// survive when loading a new scene.
function Awake () {
DontDestroyOnLoad (transform.gameObject);
}
using UnityEngine; using System.Collections; public class Example : MonoBehaviour { void Awake() { DontDestroyOnLoad(transform.gameObject); } }
import UnityEngine import System.Collections public class Example(MonoBehaviour): def Awake() as void: DontDestroyOnLoad(transform.gameObject)