Created
February 21, 2017 15:51
-
-
Save ninpl/b75f9febb08584cfd64dd46d8004fb78 to your computer and use it in GitHub Desktop.
Singleton sencillo para 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
// ┌∩┐(◣_◢)┌∩┐ | |
// \\ | |
// Singleton.cs (21/02/2017) \\ | |
// Autor: Antonio Mateo (Moon Pincho) \\ | |
// Descripcion: Singleton basico \\ | |
// Fecha Mod: 21/02/2017 \\ | |
// Ultima Mod: Version inicial \\ | |
//******************************************************************************\\ | |
#region Librerias | |
using UnityEngine; | |
#endregion | |
namespace MoonPincho | |
{ | |
public class Singleton : MonoBehaviour | |
{ | |
public static Singleton instance = null; | |
private void Awake() | |
{ | |
if(instance == null) | |
{ | |
instance = this; | |
}else if (instance != this) | |
{ | |
Destroy(this.gameObject); | |
} | |
DontDestroyOnLoad(this.gameObject); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment