Skip to content

Instantly share code, notes, and snippets.

@RootKiller
Last active October 28, 2022 18:54
Show Gist options
  • Save RootKiller/ba9488e3e981241b2053de361dc7b95c to your computer and use it in GitHub Desktop.
Save RootKiller/ba9488e3e981241b2053de361dc7b95c to your computer and use it in GitHub Desktop.
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