using System.Collections; using System.Collections.Generic; using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI; public class ChooseBle : MonoBehaviour { private UIManager manager; public Image[] LeftHands; public Image[] Righthands; public string LeftChoice { get; private set; } public string RightChoice { get; private set; } private Color ImgOriginal; private Color TextOriginal; // Start is called before the first frame update void Start() { manager = transform.root.GetComponent(); ImgOriginal = LeftHands[0].color; TextOriginal = manager.DisconnectColor; int cnt = 0; foreach(var img in LeftHands) { if(img.gameObject.activeInHierarchy) { cnt++; } } if (cnt == 1) { LeftHands[0].color = Color.white; var DeviceNameText = LeftHands[0].transform.parent.Find("DeviceName").GetComponent(); var Icon = LeftHands[0].transform.parent.Find("HandIcon").GetComponent(); LeftChoice = DeviceNameText.text; DeviceNameText.color = Color.white; Icon.sprite = manager.HandsIconsSet[1]; } cnt = 0; foreach (var img in Righthands) { if (img.gameObject.activeInHierarchy) { cnt++; } } if (cnt == 1) { Righthands[0].color = Color.white; var DeviceNameText = Righthands[0].transform.parent.Find("DeviceName").GetComponent(); var Icon = Righthands[0].transform.parent.Find("HandIcon").GetComponent(); RightChoice = DeviceNameText.text; DeviceNameText.color = Color.white; Icon.sprite = manager.HandsIconsSet[3]; } } // Update is called once per frame void Update() { } public void SelectLeftHand(int index) { foreach (var img in LeftHands) { img.color = ImgOriginal; img.transform.parent.Find("DeviceName").GetComponent().color = TextOriginal; img.transform.parent.Find("HandIcon").GetComponent().sprite = manager.HandsIconsSet[0]; } LeftHands[index].color = Color.white; LeftHands[index].transform.parent.Find("DeviceName").GetComponent().color = Color.white; LeftChoice = LeftHands[index].transform.parent.Find("DeviceName").GetComponent().text; LeftHands[index].transform.parent.Find("HandIcon").GetComponent().sprite = manager.HandsIconsSet[1]; } public void SelectRightHand(int index) { foreach (var img in Righthands) { img.color = ImgOriginal; img.transform.parent.Find("DeviceName").GetComponent().color = TextOriginal; img.transform.parent.Find("HandIcon").GetComponent().sprite = manager.HandsIconsSet[2]; } Righthands[index].color = Color.white; Righthands[index].transform.parent.Find("DeviceName").GetComponent().color = Color.white; RightChoice = Righthands[index].transform.parent.Find("DeviceName").GetComponent().text; Righthands[index].transform.parent.Find("HandIcon").GetComponent().sprite = manager.HandsIconsSet[3]; } }