94 lines
2.1 KiB
C#
94 lines
2.1 KiB
C#
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;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
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("机器人到这里");
|
|
if (textMesh.text == "R64")
|
|
{
|
|
RobotManager.Instance.DoAnimation();
|
|
}
|
|
});
|
|
}
|
|
|
|
// 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.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
|
|
{
|
|
gameObject.SetActive(false);
|
|
HandleSelected();
|
|
}
|
|
}
|
|
}
|