Advertisement
Jellybit

DontDestroyOnLoad.cs - For manager objects that stick around

Jun 14th, 2014
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.35 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. //This will mark an object as something not to be destroyed when loading a new scene. Good for game/score managers that handle
  5. //game flow, and need to retain the data they have.
  6.  
  7. public class DontDestroyOnLoad : MonoBehaviour {
  8.    
  9.     void Awake () {
  10.         DontDestroyOnLoad( transform.gameObject );
  11.     }
  12.  
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement