Skip to content

Instantly share code, notes, and snippets.

@rumanwork
Created December 12, 2012 06:48
Show Gist options
  • Save rumanwork/4265602 to your computer and use it in GitHub Desktop.
Save rumanwork/4265602 to your computer and use it in GitHub Desktop.
Unity3d C# Singleton. Use: SingletonName.Instance.propertyName = 5;
public class SingletonName : MonoBehaviour {
private static SingletonName instance = null;
public static SingletonName Instance {
get {
if (instance == null)
{
GameObject go = new GameObject();
instance = go.AddComponent<SingletonName>();
go.name = "SingletonName";
}
return instance;
}
}
public int propertyName;
public void Init () {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment