void Start() { if (!Menu) { if (SceneManager.GetActiveScene().name == "Level01") { FindObjectOfType <TileMap> ().BuildMesh(1); FindObjectOfType <TileMap> ().BuildMesh(1); } else if (SceneManager.GetActiveScene().name == "Level02") { FindObjectOfType <TileMap> ().BuildMesh(2); FindObjectOfType <TileMap> ().BuildMesh(2); } resetMngr = FindObjectOfType(typeof(ResetManager)) as ResetManager; score = GameObject.Find("ScoreText"); scoreT = score.GetComponent <ScoreText> (); rstpp = player.GetComponent <ResetPlayerParameters> () as ResetPlayerParameters; GameOver = gmOver.GetComponent <Image> () as Image; newbst = newBest.GetComponent <Image> () as Image; LevelComplete = lvlcomplete.GetComponent <Text> () as Text; lvlcmpOverlay = lvlcompoverlay.GetComponent <Text> () as Text; cmpRe = compRe.GetComponent <Button> () as Button; cpRe = cpRestart.GetComponent <Button> () as Button; _comp = compRe.GetComponent <Image> () as Image; _checkp = cpRestart.GetComponent <Image> () as Image; } }
public void ResetScene() { rp = player.GetComponent <ResetPlayerParameters> () as ResetPlayerParameters; Debug.Log("Is rp null? = " + (rp == null)); spawnIndex = rp.GetSpawnPoint(); dontReset = new List <GameObject> (); if (spawnIndex == "SpawnPos") { spawn0 = true; dontReset.Add(new GameObject()); } else if (spawnIndex == "Checkpoint1") { dontReset.AddRange(GameObject.Find("Checkpoint1").GetComponent <Cpoint>().GetNonResettable()); } else if (spawnIndex == "Checkpoint2") { dontReset.AddRange(GameObject.Find("Checkpoint2").GetComponent <Cpoint>().GetNonResettable()); } dr = dontReset.ToArray(); resetscrobj = FindObjectsOfType(typeof(ResetObject)) as ResetObject[]; for (int i = 0; i < resetscrobj.Length; i++) { allDiff = true; for (int j = 0; j < dr.Length; j++) { if (resetscrobj[i].gameObject.name == dr[j].name) { allDiff = false; break; } } if (allDiff) { resetscrobj [i].Reset(); } } for (int i = 0; i < _resetScripts.Length; i++) { if (resetscrobj[i].gameObject.tag == "Button") { resetscrobj [i].gameObject.GetComponent <GameButton> ().OnResetting(); if (resetscrobj[i].gameObject.tag == "Player") { resetscrobj [i].gameObject.GetComponent <PlayerMovement> ().OnResetting(); } } } }