Skip to content

Instantly share code, notes, and snippets.

@ninpl
Created February 21, 2017 15:51
Show Gist options
  • Save ninpl/b75f9febb08584cfd64dd46d8004fb78 to your computer and use it in GitHub Desktop.
Save ninpl/b75f9febb08584cfd64dd46d8004fb78 to your computer and use it in GitHub Desktop.
Singleton sencillo para Unity3D
// ┌∩┐(◣_◢)┌∩┐
// \\
// 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