Skip to content

Instantly share code, notes, and snippets.

@Quickz
Created January 7, 2021 17:58
Show Gist options
  • Save Quickz/78bf4a9c43ab44814d7b51e0b4295df5 to your computer and use it in GitHub Desktop.
Save Quickz/78bf4a9c43ab44814d7b51e0b4295df5 to your computer and use it in GitHub Desktop.
Unity singleton example
public class SingletonInstance : MonoBehaviour
{
public static SingletonInstance Instance { get; private set; }
private void Awake()
{
if (Instance != null)
{
Destroy(gameObject);
return;
}
Instance = this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment