Last active
January 15, 2019 02:38
-
-
Save DataGreed/c9febc82691fa10ce1a9251d3570c200 to your computer and use it in GitHub Desktop.
Unity Singleton implementation for GameController, based on Flappy Bird Tutorial.
This file contains hidden or 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 System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class GameController : MonoBehaviour | |
{ | |
public static GameController instance; | |
// Singleton Initialization | |
void Awake() | |
{ | |
if (!GameController.instance) | |
{ | |
GameController.instance = this; | |
} | |
else | |
{ | |
Destroy(this.gameObject); | |
} | |
} | |
// Start is called before the first frame update | |
void Start() | |
{ | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment