using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class MicroOption : MonoBehaviour { string nameMicro = ""; int thisIndexMicro; public static int chosenMic; public static MicroOption optionChosen; bool thisChosen = false; public void SetInfo(string name, int thisIndex) { nameMicro = name; thisIndexMicro = thisIndex; Text txt = GetComponentInChildren(); txt.text = nameMicro; } public void ClickOnThis() { SetThis(true, false); } public void SetThis(bool chosen, bool firstTime = false) { MicroPhoneChoose_Contorl microPhoneChoose_Contorl = MicroPhoneChoose_Contorl.instance; if (chosen) { if (!thisChosen) { Text txt = GetComponentInChildren(); txt.color = microPhoneChoose_Contorl.chosenColor; Image img = GetComponent(); img.sprite = microPhoneChoose_Contorl.chosen; chosenMic = thisIndexMicro; if (!firstTime) { optionChosen.SetThis(false); } optionChosen = this; thisChosen = true; MicroPhoneChoose_Contorl.instance.UpdateFile(thisIndexMicro.ToString()); } } else { Text txt = GetComponentInChildren(); txt.color = Color.white; Image img = GetComponent(); img.sprite = microPhoneChoose_Contorl.notChosen; thisChosen = false; } } }