100 lines
2.9 KiB
C#
100 lines
2.9 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class CheckDeviceButtonPanel : MonoBehaviour
|
|
{
|
|
string deviceName;
|
|
public static GameObject prefb;
|
|
|
|
public static CheckDeviceButtonPanel instance;
|
|
public static void Show(string deviceName)
|
|
{
|
|
|
|
if (prefb == null)
|
|
{
|
|
prefb = Resources.Load<GameObject>("UI/UI_Tip/CheckDeviceButtonPanel");
|
|
}
|
|
|
|
GameObject btn = Instantiate<GameObject>(prefb, GameManager.UIMgr.canvas.transform);
|
|
btn.GetComponent<CheckDeviceButtonPanel>().Init(deviceName);
|
|
}
|
|
|
|
private void Init(string deviceName)
|
|
{
|
|
instance = this;
|
|
this.deviceName = deviceName;
|
|
|
|
if (GameManager.RunModelMgr?.ModeType == E_ModeType.Study)
|
|
GameManager.EventMgr.AddEventListener<string>(Enum_EventType.SwitchSubProcessStepTriggerID, SwitchSubProcessStepTriggerID);
|
|
|
|
//刷新
|
|
SwitchSubProcessStepTriggerID(GameManager.ProcessMgr.subProcessStepTriggerID);
|
|
|
|
EventCenter.Instance?.AddEventListener<GameObject>(Enum_EventType.TakeOutAndRetrievingTheTools, OnHandTool);
|
|
|
|
}
|
|
public void MyEnter(BaseEventData baseEvent)
|
|
{
|
|
transform.localScale = Vector3.one * 1.2f;
|
|
}
|
|
public void MyExit(BaseEventData baseEvent)
|
|
{
|
|
transform.localScale = Vector3.one;
|
|
}
|
|
public void MyClick(BaseEventData baseEvent)
|
|
{
|
|
if (GameManager.ProcessMgr == null || GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID("核对设备铭牌按钮", true) == 0)
|
|
{
|
|
//打开核对页面
|
|
GameManager.UIMgr.ShowPanel<UI_CheckDevicePanel>(E_UI_Layer.Mid, (panel) =>
|
|
{
|
|
panel.Init(deviceName);
|
|
});
|
|
}
|
|
}
|
|
public void MyDesTroy()
|
|
{
|
|
instance = null;
|
|
Destroy(gameObject);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
if (GameManager.RunModelMgr.ModeType == E_ModeType.Study)
|
|
GameManager.EventMgr.RemoveEventListener<string>(Enum_EventType.SwitchSubProcessStepTriggerID, SwitchSubProcessStepTriggerID);
|
|
|
|
EventCenter.Instance?.RemoveEventListener<GameObject>(Enum_EventType.TakeOutAndRetrievingTheTools, OnHandTool);
|
|
}
|
|
|
|
private void SwitchSubProcessStepTriggerID(string arg0)
|
|
{
|
|
try
|
|
{
|
|
if (arg0 == "核对设备铭牌按钮")
|
|
{
|
|
transform.GetComponentInChildren<ImageTips>(true).gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
transform.GetComponentInChildren<ImageTips>(true).gameObject.SetActive(false);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Debug.LogError(e.Message + " " + arg0);
|
|
}
|
|
}
|
|
private void OnHandTool(GameObject obj)
|
|
{
|
|
if (obj == null)
|
|
{
|
|
MyDesTroy();
|
|
}
|
|
}
|
|
}
|