Last active
October 28, 2022 18:54
-
-
Save RootKiller/ba9488e3e981241b2053de361dc7b95c to your computer and use it in GitHub Desktop.
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
using UnityEngine; | |
class GameManager : MonoBehaviour | |
{ | |
public static GameManager instance; | |
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] | |
private static Initialize() | |
{ | |
if (instance == null) | |
{ | |
instance = new GameObject(nameof(GameManager), typeof(GameManager)).GetComponent<GameManager>(); | |
} | |
} | |
private void Awake() | |
{ | |
Debug.Log("GameManager has been created!"); | |
DontDestroyOnLoad(this); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment