Created
January 17, 2014 02:42
-
-
Save yuseinishiyama/8467576 to your computer and use it in GitHub Desktop.
Attaching this script to a object, the object survives in all scenes. (For Unity3d)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class DontDestroyObject : MonoBehaviour | |
{ | |
static DontDestroyObject instance; | |
void Awake () | |
{ | |
if (!instance) { | |
instance = this; | |
DontDestroyOnLoad (gameObject); | |
} else { | |
Destroy (gameObject); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment