Skip to content

Instantly share code, notes, and snippets.

@eduardonunesp
Created September 3, 2019 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eduardonunesp/4173856b3a2d16a8426df3fed3929955 to your computer and use it in GitHub Desktop.
Save eduardonunesp/4173856b3a2d16a8426df3fed3929955 to your computer and use it in GitHub Desktop.
Loader
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Loader : MonoBehaviour
{
void Awake()
{
GameObject gameManager = GameObject.Find("GameManager");
if (!gameManager)
{
Debug.LogWarning("You need to add Prefab GameManager");
return;
}
//Check if a GameManager has already been assigned to static variable GameManager.instance or if it's still null
if (GameManager.instance == null)
{
//Instantiate gameManager prefab
Instantiate(gameManager);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment