Skip to content

Instantly share code, notes, and snippets.

@Tymski
Created January 17, 2023 23:58
Show Gist options
  • Save Tymski/9eb2b82b20367840da36ba077d5e358c to your computer and use it in GitHub Desktop.
Save Tymski/9eb2b82b20367840da36ba077d5e358c to your computer and use it in GitHub Desktop.
using UnityEngine;
public static class SingletonInitializer
{
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
static void InitializeSingletons()
{
var singletons = Resources.Load<GameObject>("SINGLETONS");
Object.DontDestroyOnLoad(Object.Instantiate(singletons));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment