// Start is called before the first frame update private void Awake() { menu = GameObject.FindWithTag("menus"); menuScript = menu.GetComponent <mainMenu1>(); populationSize = menuScript.pop; generationLength = menuScript.genLength; }
/// <summary> /// makes sure that there will only ever be one main menu gameobject and first sets up the text /// </summary> void Start() { DontDestroyOnLoad(gameObject); GameObject[] check = GameObject.FindGameObjectsWithTag("menus"); foreach (GameObject newMenu in check) { if (newMenu != gameObject) //makes sure that there will only be one { mainMenu1 other = newMenu.GetComponent <mainMenu1>(); if (lifeTime < other.lifeTime) { Destroy(other.gameObject); } } } generationLengthTimer.text = "Generation timer: " + genLength; population.text = "Population: " + pop; }