ZoeRobotIngles/Assets/Scripts/Config/Micro/MicroOption.cs

66 lines
1.6 KiB
C#

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<Text>();
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<Text>();
txt.color = microPhoneChoose_Contorl.chosenColor;
Image img = GetComponent<Image>();
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<Text>();
txt.color = Color.white;
Image img = GetComponent<Image>();
img.sprite = microPhoneChoose_Contorl.notChosen;
thisChosen = false;
}
}
}