You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
3.3 KiB
96 lines
3.3 KiB
|
1 month ago
|
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<UIManager>();
|
||
|
|
|
||
|
|
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<Text>();
|
||
|
|
var Icon = LeftHands[0].transform.parent.Find("HandIcon").GetComponent<Image>();
|
||
|
|
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<Text>();
|
||
|
|
var Icon = Righthands[0].transform.parent.Find("HandIcon").GetComponent<Image>();
|
||
|
|
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<Text>().color = TextOriginal;
|
||
|
|
img.transform.parent.Find("HandIcon").GetComponent<Image>().sprite = manager.HandsIconsSet[0];
|
||
|
|
}
|
||
|
|
LeftHands[index].color = Color.white;
|
||
|
|
LeftHands[index].transform.parent.Find("DeviceName").GetComponent<Text>().color = Color.white;
|
||
|
|
LeftChoice = LeftHands[index].transform.parent.Find("DeviceName").GetComponent<Text>().text;
|
||
|
|
LeftHands[index].transform.parent.Find("HandIcon").GetComponent<Image>().sprite = manager.HandsIconsSet[1];
|
||
|
|
}
|
||
|
|
|
||
|
|
public void SelectRightHand(int index)
|
||
|
|
{
|
||
|
|
foreach (var img in Righthands)
|
||
|
|
{
|
||
|
|
img.color = ImgOriginal;
|
||
|
|
img.transform.parent.Find("DeviceName").GetComponent<Text>().color = TextOriginal;
|
||
|
|
img.transform.parent.Find("HandIcon").GetComponent<Image>().sprite = manager.HandsIconsSet[2];
|
||
|
|
}
|
||
|
|
Righthands[index].color = Color.white;
|
||
|
|
Righthands[index].transform.parent.Find("DeviceName").GetComponent<Text>().color = Color.white;
|
||
|
|
RightChoice = Righthands[index].transform.parent.Find("DeviceName").GetComponent<Text>().text;
|
||
|
|
Righthands[index].transform.parent.Find("HandIcon").GetComponent<Image>().sprite = manager.HandsIconsSet[3];
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|