Created
January 7, 2021 17:58
-
-
Save Quickz/78bf4a9c43ab44814d7b51e0b4295df5 to your computer and use it in GitHub Desktop.
Unity singleton example
This file contains hidden or 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
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