120 lines
3.1 KiB
C#
120 lines
3.1 KiB
C#
using Newtonsoft.Json;
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using Unity.VisualScripting;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
|
||
public class IRPopup : MonoBehaviour
|
||
{
|
||
public Root myroot = new Root();
|
||
public static IRPopup Inst;
|
||
public Transform content;
|
||
public RectTransform content_ret;
|
||
public GridLayoutGroup content_grid;
|
||
public GameObject prefab;
|
||
public Button cls_bt;
|
||
|
||
public GameObject popup;
|
||
|
||
float x;
|
||
float y;
|
||
|
||
private void Awake()
|
||
{
|
||
Inst = this;
|
||
x = content_ret.sizeDelta.x;
|
||
popup.SetActive(false);
|
||
}
|
||
// Start is called before the first frame update
|
||
void Start()
|
||
{
|
||
cls_bt.onClick.AddListener(() =>
|
||
{
|
||
popup.SetActive(false);
|
||
});
|
||
}
|
||
|
||
// Update is called once per frame
|
||
void Update()
|
||
{
|
||
if (popup.activeSelf)
|
||
{
|
||
y = content_grid.padding.top + content.childCount * content_grid.cellSize.y + (content.childCount - 1) * content_grid.spacing.y;
|
||
content_ret.sizeDelta = new Vector2(x, y);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 加载红外检测详情
|
||
/// </summary>
|
||
public void LoadmoreDetails()
|
||
{
|
||
StartCoroutine(CombineJSON.GetJson_GET(GameManager.Inst.Jk_URL.hwjc_cx, GameManager.Inst.arguments.token, (jsonResult) =>
|
||
{
|
||
if (jsonResult != null)
|
||
{
|
||
try
|
||
{
|
||
myroot = JsonConvert.DeserializeObject<Root>(jsonResult);
|
||
if (myroot.message == "操作成功")
|
||
{
|
||
//for (int i = 0; i < myroot.data.Count; i++)
|
||
{
|
||
var go = GameObject.Instantiate(prefab, content);
|
||
var t = go.GetComponent<calendarIcon>();
|
||
var txt = myroot.data.personFlag;
|
||
if (txt == "1") t.text1.text = "有人";
|
||
else if (txt == "0") t.text1.text = "无人";
|
||
//t.text1.text = myroot.data[i].personFlag;
|
||
//t.text2.text = myroot.data[i].particulars;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
SecondConfirmPanel.DeleteConform(null, myroot.message);
|
||
}
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
SecondConfirmPanel.DeleteConform(null, "红外检测序列化错误");
|
||
}
|
||
}
|
||
}));
|
||
}
|
||
|
||
[System.Serializable]
|
||
public class Data
|
||
{
|
||
/// <summary>
|
||
/// 1-有人;0-无人
|
||
/// </summary>
|
||
public string personFlag;
|
||
}
|
||
|
||
[System.Serializable]
|
||
public class Root
|
||
{
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string code;
|
||
/// <summary>
|
||
/// 操作成功
|
||
/// </summary>
|
||
public string message;
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public Data data;
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string serverTime;
|
||
}
|
||
}
|