void Start() { if (!File.Exists(Path.Combine(Application.persistentDataPath, SceneManager.GetActiveScene().name + ".txt"))) { string jsonString = JsonUtility.ToJson(PlanetInfo); using (StreamWriter streamWriter = File.CreateText(Path.Combine(Application.persistentDataPath, SceneManager.GetActiveScene().name + ".txt"))) { streamWriter.Write(jsonString); } } PlanetInfo = GetComponent <SaveFromWorld>().LoadPlanet(); dispoTool = GetComponent <SaveFromWorld>().LoadTool(); buildId = PlanetInfo.buildId; buildable = GameObject.FindGameObjectsWithTag("Buildable"); choiceMenu = FindObjectOfType <MenuForPiple>().menu; choiceMenuBoutton = GameObject.FindGameObjectsWithTag("Boutton"); foreach (GameObject boutton in choiceMenuBoutton) { GameObject.Find("Button (" + count.ToString() + ")").SetActive(dispoTool.dispoTools[count]); count += 1; } tamp = dispoTool; if (PlanetInfo.win) { GameObject.Destroy(GameObject.FindGameObjectWithTag("Win").gameObject); } win = PlanetInfo.win; count = 0; foreach (GameObject build in buildable) { id = buildId[count]; build.GetComponent <BuildInfo>().id = id; build.GetComponent <BuildInfo>().social = FindObjectOfType <ObjetList>().socialList[id]; build.GetComponent <BuildInfo>().argent = FindObjectOfType <ObjetList>().argentList[id]; build.GetComponent <BuildInfo>().ecologie = FindObjectOfType <ObjetList>().ecologieList[id]; build.GetComponent <SpriteRenderer>().sprite = FindObjectOfType <ObjetList>().imageList[id]; count += 1; } choiceMenu.SetActive(false); }
void Update() { if (run) { run = false; StartCoroutine(waitTime()); } if (FindObjectOfType <GlobalVar>().win&&first) { first = false; foreach (GameObject boutton in bouttons) { boutton.SetActive(true); } count = 1; foreach (GameObject boutton in bouttons) { Debug.Log(count); GameObject.Find("Button (" + count.ToString() + ")").SetActive(FindObjectOfType <GlobalVar>().dispoTool.dispoTools[count]); count += 1; } tamp = FindObjectOfType <GlobalVar>().dispoTool; } }