Skip to content

Instantly share code, notes, and snippets.

@AlexMeesters
Last active May 2, 2019 12:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexMeesters/5375562a63a9661b263caa46d6cc0b06 to your computer and use it in GitHub Desktop.
Save AlexMeesters/5375562a63a9661b263caa46d6cc0b06 to your computer and use it in GitHub Desktop.
public class Main : MonoBehaviour
{
// Runs before a scene gets loaded
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
public static void LoadMain()
{
GameObject main = GameObject.Instantiate(Resources.Load("Main")) as GameObject;
GameObject.DontDestroyOnLoad(main);
}
// You can choose to add any "Service" component to the Main prefab.
// Examples are: Input, Saving, Sound, Config, Asset Bundles, Advertisements
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment