68 lines
2.0 KiB
C#
68 lines
2.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
[AddComponentMenu("IssueInspectionInstructions/下发巡检指令")]
|
|
/// <summary>
|
|
/// 下发巡检指令
|
|
/// </summary>
|
|
public class IssueInspectionInstructions : MonoBehaviour
|
|
{
|
|
public static IssueInspectionInstructions Inst;
|
|
/// <summary>
|
|
/// 是否初始化数据
|
|
/// </summary>
|
|
[HideInInspector] public bool init_data = false;
|
|
public List<Button> buttons;
|
|
|
|
private void Awake()
|
|
{
|
|
Inst = this;
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
public void init()
|
|
{
|
|
if (GameManager.Inst.isLoading &&
|
|
RobotDataManager.Inst.RobotObject.robotClass != null &&
|
|
RobotDataManager.Inst &&
|
|
RobotDataManager.Inst.obtainListening &&
|
|
RobotDataManager.Inst.rootCabinDictionary.cabinDictionaries != null)
|
|
{
|
|
RobotDataManager.Inst.obtainListening = false;
|
|
foreach (var item in RobotDataManager.Inst.rootCabinDictionary.cabinDictionaries)
|
|
{
|
|
for (int i = 0; i < GameManager.Inst.Cabinets_go.Count; i++)
|
|
{
|
|
var index = i;
|
|
var pos = item.pointNos;
|
|
if (item.name.Contains(GameManager.Inst.Cabinets_go[index].name))
|
|
{
|
|
Debug.Log($"添加{GameManager.Inst.Cabinets_go[index].name}巡检点位成功,点位{pos.Count}个");
|
|
buttons[index].onClick.AddListener(() =>
|
|
{
|
|
Debug.Log($"巡检点击{GameManager.Inst.Cabinets_go[index].name}点位,点位{pos.Count}个");
|
|
RobotDataManager.Inst.UsageExample(pos);
|
|
});
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
init();
|
|
}
|
|
}
|