101 lines
2.4 KiB
C#
101 lines
2.4 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;
|
||
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;
|
||
}
|
||
}
|
||
}
|