GQ_Communicate/GQ_URP/GQ/Assets/script/红外监测/Infraredsensor.cs

90 lines
2.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using Newtonsoft.Json.Linq;
using static IRPopup;
using Newtonsoft.Json;
using System;
public class Infraredsensor : MonoBehaviour, IPointerDownHandler
{
//public static Infraredsensor Inst;
//public Menu current_menu;
//public List<CabinetUIBase> cabinet_ui_base_list;
public Text text;
private void Awake()
{
//Inst = this;
text = GetComponent<Text>();
}
void Start()
{
//cabinet_ui_base_list = GetComponentsInChildren<CabinetUIBase>(true).ToList();
}
// Update is called once per frame
void Update()
{
}
public void OnPointerDown(PointerEventData eventData)
{
//if (text)
// WebInteraction.Inst.Infraredsensor_open(text.text.Replace("红外", ""));
try
{
IRPopup.Inst.msg = JObject.Parse(IRPopup.Inst.myroot.data.ToString());
// 0无异物 1有异物
if (IRPopup.Inst && IRPopup.Inst.msg["personFlag"].ToString() == "1")
{
var data = IRPopup.Inst.data.Where(x => x.devname.Contains(text.text.Split('-')[1])).ToList();
for (int i = IRPopup.Inst.content.childCount - 1; i >= 0; i--)
DestroyImmediate(IRPopup.Inst.content.GetChild(i).gameObject);
for (int i = 0; i < data.Count; i++)
{
var go = GameObject.Instantiate(IRPopup.Inst.prefab, IRPopup.Inst.content);
var t = go.GetComponent<calendarIcon>();
t.text1.text = data[i].alarmtime.ToString();
t.text2.text = "有异物";
}
IRPopup.Inst.popup.SetActive(true);
}
}
catch (System.Exception e)
{
Debug.Log("红外赋值错误:" + e.Message + ",行次:" + e.StackTrace);
}
}
//public static void ChangeMenu(Menu menu)
//{
// Inst.current_menu = menu;
// foreach (var item in Inst.cabinet_ui_base_list)
// {
// item.OnMenuChanged(menu);
// }
//}
//public void op(Toggle t)
//{
// foreach (var item in Inst.cabinet_ui_base_list)
// {
// item.gameObject.SetActive(t.isOn);
// }
//}
}