// Use this for initialization void Awake() { //enforce MenuGM singleton status. if (instance == null) { instance = this; //if there's no game mgr yet, this is the one } else if (instance != this) { Destroy(gameObject); //if there is, and it's not us, scrub. } //do setup //kludgy way to show counter stickers with no counter - they come up blank digits counterShoes = (GameObject)Instantiate(CounterPrefab, new Vector3(transform.position.x - 3.4f, transform.position.y + 0.7f, transform.position.z - 0.2f), Quaternion.identity); counterShoesScriptInstance = (CounterScript)counterShoes.GetComponent(typeof(CounterScript)); counterShoesScriptInstance.setSticker(1, 0.599f, -0.886f); counterScore = (GameObject)Instantiate(CounterPrefab, new Vector3(transform.position.x - 3.4f, transform.position.y + 2.0f, transform.position.z - 0.2f), Quaternion.identity); counterScoreScriptInstance = (CounterScript)counterScore.GetComponent(typeof(CounterScript)); counterScoreScriptInstance.setSticker(0, -0.028f, -0.609f); //if on mobile, set up explicit buttons for fire and exit #if (UNITY_ANDROID || UNITY_IPHONE) droidButtonsClone = (GameObject)Instantiate(DroidButtonsPrefab, new Vector3(0.0f, 0.0f, -1.0f), Quaternion.identity); //fireButtonBounds = droidButtonsClone.transform.Find("Fire").gameObject.GetComponent<SpriteRenderer>().bounds; //exitButtonBounds = droidButtonsClone.transform.Find("Exit").gameObject.GetComponent<SpriteRenderer>().bounds; exitCollider = droidButtonsClone.transform.Find("Exit").gameObject.GetComponent <Collider2D>(); fireCollider = droidButtonsClone.transform.Find("Fire").gameObject.GetComponent <Collider2D>(); #endif }
void StartGame() { //I'm assuming this destroys everything including Instance - is it so? I don't think so. See if this helps instance = null; UnityEngine.SceneManagement.SceneManager.LoadScene("MainScene"); }