using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Accessibility; using UnityEngine.UI; using TMPro; public class DigitalTwinPanel : CabinetUIBase { public static Transform Camera; public Image icon; public Image btn_icon; public Button hold_button; public Button go_to_here_button; public TextMeshProUGUI textMesh; public bool hold; public static DigitalTwinPanel selected_panel; public Image img; // Start is called before the first frame update void Start() { img = PatternChoose.Inst.xunJianImg; Camera = UnityEngine.Camera.main.transform; textMesh.text = transform.parent.name; hold_button.onClick.AddListener(() => { hold = !hold; if (hold) { btn_icon.gameObject.SetActive(true); HandleSelected(); selected_panel = this; } if (!hold && icon.gameObject.activeSelf) { HideUI(); btn_icon.gameObject.SetActive(false); } }); go_to_here_button.onClick.AddListener(() => { Debug.Log("机器人到这里"); btn_icon.gameObject.SetActive(false); if (textMesh.text == "R64") { RobotManager.Instance.DoAnimation(); RobotManager.Instance.ShowVideo(); img.gameObject.SetActive(true); } }); } // Update is called once per frame void Update() { transform.eulerAngles = Camera.eulerAngles; } public void ShowUI() { icon.gameObject.SetActive(true); } public void HideUI() { if (hold) return; icon.gameObject.SetActive(false); } public void HandleSelected() { if (selected_panel && selected_panel != this) { selected_panel.hold = false; selected_panel.btn_icon.gameObject.SetActive(false); selected_panel.HideUI(); } } public override void OnMenuChanged(Menu menu) { base.OnMenuChanged(menu); if (menu == Menu.M_数字机房_智能巡检) { gameObject.SetActive(true); } else { hold = false; gameObject.SetActive(false); HandleSelected(); selected_panel = null; } } }