1178 lines
34 KiB
C#
1178 lines
34 KiB
C#
using Newtonsoft.Json;
|
||
using SimpleJSON;
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.Networking;
|
||
using UnityEngine.UI;
|
||
using static GameManager;
|
||
|
||
public class WebInteraction : MonoBehaviour
|
||
{
|
||
public string s;
|
||
public static WebInteraction Inst;
|
||
|
||
public string current_videoNumber = null;
|
||
|
||
|
||
/// <summary>
|
||
/// 视频监控是否为打开状态
|
||
/// </summary>
|
||
public bool isVideoPlay = false;
|
||
|
||
/// <summary>
|
||
/// 工作票是否为打开状态
|
||
/// </summary>
|
||
public bool isWorkPlay = false;
|
||
|
||
public GameManager gameManager;
|
||
/// <summary>
|
||
/// 机器人网页跳转按钮
|
||
/// </summary>
|
||
public Button btnRobotWebPage;
|
||
/// <summary>
|
||
/// 巡检数据
|
||
/// </summary>
|
||
public string inspectionData;
|
||
[Serializable]
|
||
public class Menu_Struct
|
||
{
|
||
public Toggle toggle;
|
||
public Menu menu;
|
||
|
||
/// <summary>
|
||
/// 菜单初始状态
|
||
/// </summary>
|
||
[Tooltip("菜单初始状态")] public bool isState;
|
||
/// <summary>
|
||
/// 是否为二级菜单
|
||
/// </summary>
|
||
[Tooltip("是否为二级菜单")] public bool isSecond_level;
|
||
/// <summary>
|
||
/// Toggle初始isOn
|
||
/// </summary>
|
||
[Tooltip("Toggle初始isOn")] public bool _ison;
|
||
|
||
|
||
}
|
||
/// <summary>
|
||
/// 所有toogle
|
||
/// </summary>
|
||
public List<Menu_Struct> menu_struct;
|
||
|
||
[Header("菜单权限")]
|
||
public Root root = new Root();
|
||
|
||
//public List<Toggle> toggles;
|
||
/// <summary>
|
||
/// 二级菜单Toggle父物体
|
||
/// </summary>
|
||
public List<Transform> secondary_menu;
|
||
|
||
public GameObject first_level_menu;
|
||
public List<GameObject> second_level_menu;
|
||
/// <summary>
|
||
/// 机器人
|
||
/// </summary>
|
||
public List<RobotPos> robotPos = new List<RobotPos>();
|
||
/// <summary>
|
||
/// 记录权限开放的菜单名
|
||
/// </summary>
|
||
public List<string> menu_name = new List<string>();
|
||
|
||
private void Awake()
|
||
{
|
||
|
||
Inst = this;
|
||
#if UNITY_EDITOR
|
||
// 在编辑器中运行时执行的代码
|
||
StartCoroutine(LoadAddress((ct) =>
|
||
{
|
||
if (ct != null)
|
||
{
|
||
unity_token_value(ct);
|
||
}
|
||
else
|
||
{
|
||
Debug.Log("获取地址错误!");
|
||
}
|
||
}));
|
||
// 在编辑器中运行时执行的代码
|
||
StartCoroutine(Inspection((ct) =>
|
||
{
|
||
if (ct != null)
|
||
{
|
||
unity_Inspection_value(ct);
|
||
}
|
||
else
|
||
{
|
||
Debug.Log("获取地址错误!");
|
||
}
|
||
}));
|
||
// 在编辑器中运行时执行的代码
|
||
StartCoroutine(Track((ct) =>
|
||
{
|
||
if (ct != null)
|
||
{
|
||
robotPos= JsonConvert.DeserializeObject<List<RobotPos>>(ct);
|
||
}
|
||
else
|
||
{
|
||
Debug.Log("获取地址错误!");
|
||
}
|
||
}));
|
||
#endif
|
||
//StartCoroutine(QiangZhi());
|
||
}
|
||
|
||
|
||
|
||
private void Start()
|
||
{
|
||
//Debug.Log("版本号 1.1.1");
|
||
bt.onClick.AddListener(() =>
|
||
{
|
||
//gameManager.token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2OTI2NDMyODksInVzZXJuYW1lIjoiMTgzMTIzNDU2NzgifQ.uMoC7I4SytLEgYTKHxyvOv7Lygeb9zDCmhLDYv1cJrA";
|
||
//gameManager.enabled = true;
|
||
unity_power_value(s);
|
||
});
|
||
//Debug.Log("版本号 1.1.1");
|
||
btnRobotWebPage.onClick.AddListener(() => {
|
||
OpenRobotWebPage();
|
||
});
|
||
}
|
||
|
||
//前端调用Unity 方法逻辑
|
||
//参数1 脚本所挂载的物体名 GameManager
|
||
//参数2 脚本内方法名 unity_token_value
|
||
//参数3 传递的参数 token值
|
||
|
||
/// <summary>
|
||
/// 前端调用此方法传递Token
|
||
/// </summary>
|
||
/// <param name="token"></param>
|
||
public void unity_token_value(string jsonData)
|
||
{
|
||
try
|
||
{
|
||
JSONNode dataNode = JSON.Parse(jsonData);
|
||
gameManager.arguments.token = dataNode["data"]["token"].Value;
|
||
gameManager.arguments.heatThresholdValueMax = dataNode["data"]["heatThresholdValueMax"].Value;
|
||
gameManager.arguments.heatThresholdValueMin = dataNode["data"]["heatThresholdValueMin"].Value;
|
||
gameManager.arguments.humidityThresholdValueMax = dataNode["data"]["humidityThresholdValueMax"].Value;
|
||
gameManager.arguments.humidityThresholdValueMin = dataNode["data"]["humidityThresholdValueMin"].Value;
|
||
Debug.Log("温度最大阈值 " + gameManager.arguments.heatThresholdValueMax);
|
||
Debug.Log("温度最小阈值 " + gameManager.arguments.heatThresholdValueMin);
|
||
Debug.Log("湿度最大阈值 " + gameManager.arguments.humidityThresholdValueMax);
|
||
Debug.Log("湿度最小阈值 " + gameManager.arguments.humidityThresholdValueMin);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
Debug.Log("解析Token错误");
|
||
}
|
||
//yield return null;
|
||
|
||
|
||
StartCoroutine(GameManager.Inst.LoadAddress((ct) =>
|
||
{
|
||
//加载场景
|
||
if (ct != null)
|
||
{
|
||
GameManager.Inst.Jk_URL = new webURL(ct);
|
||
//Application.ExternalCall("OnSceneLoaded", "三维加载完成");
|
||
//Debug.Log("三维加载完成");
|
||
//return;
|
||
StartCoroutine(GameManager.Inst.Initialize((x) =>
|
||
{
|
||
if (!string.IsNullOrEmpty(x))
|
||
{
|
||
#region 循环读取信息
|
||
if (!gameManager.isgonging)
|
||
{
|
||
StartCoroutine(
|
||
CombineJSON.GetJson_POST(GameManager.Inst.Jk_URL.gj_cx, GameManager.Inst.arguments.token, 1800, (jsonResult3) =>
|
||
{
|
||
if (!string.IsNullOrEmpty(jsonResult3))
|
||
{
|
||
try
|
||
{
|
||
gameManager.root_AllAlarm = JsonConvert.DeserializeObject<TmsAlarmQuery.Root>(jsonResult3);
|
||
|
||
Array.ForEach(GameObject.FindObjectsOfType<TmsAlarmQuery>(), itme =>
|
||
{
|
||
itme.tmsAlarmLists.Clear();
|
||
});
|
||
|
||
gameManager.tmsAlarms.Clear();
|
||
|
||
gameManager.Load_TmsAlarm();
|
||
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Debug.Log("序列化-循环告警查询错误:" + e.Message);
|
||
}
|
||
}
|
||
}));
|
||
|
||
StartCoroutine(
|
||
CombineJSON.GetJson_POST(GameManager.Inst.Jk_URL.hj_cx, GameManager.Inst.arguments.token, 1800, (jsonResult2) =>
|
||
{
|
||
if (!string.IsNullOrEmpty(jsonResult2))
|
||
{
|
||
try
|
||
{
|
||
gameManager.root_AllENV = JsonConvert.DeserializeObject<ENVQuery.Root>(jsonResult2);
|
||
|
||
gameManager.ENVs.Clear();
|
||
|
||
gameManager.Load_ENV();
|
||
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Debug.Log("序列化-循环环境查询错误:" + e.Message);
|
||
}
|
||
}
|
||
}));
|
||
}
|
||
#endregion
|
||
|
||
gameManager.isgonging = true;
|
||
}
|
||
else
|
||
{
|
||
SecondConfirmPanel.DeleteConform(null, "进入场景失败");
|
||
Debug.Log("接口获取数据失败(初始化失败)");
|
||
gameManager.LoadScene();
|
||
}
|
||
}));
|
||
}
|
||
else
|
||
{
|
||
SecondConfirmPanel.DeleteConform(null, "接口地址错误");
|
||
Debug.Log("获取地址错误!");
|
||
}
|
||
}));
|
||
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 前端调用此方法传递Token
|
||
/// </summary>
|
||
/// <param name="token"></param>
|
||
public void unity_Inspection_value(string jsonData)
|
||
{
|
||
try
|
||
{
|
||
inspectionData = jsonData;
|
||
}
|
||
catch (Exception)
|
||
{
|
||
Debug.Log("解析Token错误");
|
||
}
|
||
}
|
||
|
||
|
||
|
||
public void unity_power_value(string roleId)
|
||
{
|
||
Debug.Log("roleId:" + roleId);
|
||
Debug.Log("@@QX1");
|
||
#region 权限
|
||
//加载权限
|
||
//bool isgo = false;
|
||
try
|
||
{
|
||
Debug.Log("@@QX2");
|
||
init_menu();
|
||
Debug.Log("@@QX3");
|
||
closeMenu();
|
||
Debug.Log("@@QX4");
|
||
root = JsonConvert.DeserializeObject<Root>(roleId);
|
||
Debug.Log("@@QX5");
|
||
if (root.message == "操作成功")
|
||
{
|
||
Debug.Log("@@QX6");
|
||
menu_name.Clear();
|
||
if (root.data != null && root.data.Count > 0)
|
||
{
|
||
for (int i = 0; i < root.data.Count; i++)
|
||
{
|
||
menu_name.Add(root.data[i].menuName);
|
||
foreach (var item in root.data[i].children)
|
||
{
|
||
menu_name.Add(item.menuName);
|
||
for(int j=0;j< item.children.Count; j++)
|
||
{
|
||
menu_name.Add(item.children[j].menuName);
|
||
}
|
||
}
|
||
|
||
}
|
||
Debug.Log("@@QX7");
|
||
openMenu();
|
||
Debug.Log("@@QX8");
|
||
setMenuIsOn_3();
|
||
setMenuIsOn_2();
|
||
Debug.Log("@@QX9");
|
||
setMenuIsOn_1();
|
||
Debug.Log("权限加载完成");
|
||
}
|
||
else
|
||
{
|
||
SecondConfirmPanel.DeleteConform(null, "暂无权限");
|
||
Debug.Log("@@QX10");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
SecondConfirmPanel.DeleteConform(null, "获取权限失败");
|
||
Debug.Log("@@QX11");
|
||
}
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
SecondConfirmPanel.DeleteConform(null, "权限加载失败");
|
||
Debug.Log("权限加载错误:" + e.Message + "\n" + e.StackTrace);
|
||
}
|
||
Debug.Log("@@QX13");
|
||
//if (!isgo)
|
||
// return;
|
||
for (int i = 0; i < menu_struct.Count; i++)
|
||
{
|
||
Debug.Log(menu_struct[i].toggle.name
|
||
+ "\n物体显隐: " + menu_struct[i].toggle.gameObject.activeSelf
|
||
+ "\n初始显隐: " + menu_struct[i].isState
|
||
+ "\n物体IsOn: " + menu_struct[i].toggle.isOn
|
||
+ "\n初始IsOn:" + menu_struct[i]._ison);
|
||
}
|
||
#endregion
|
||
}
|
||
|
||
/// <summary>
|
||
/// 初始化菜单信息
|
||
/// </summary>
|
||
public void init_menu()
|
||
{
|
||
for (int i = 0; i < menu_struct.Count; i++)
|
||
{
|
||
menu_struct[i]._ison = false;
|
||
menu_struct[i].isState = false;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 设置一级菜单初始IsOn
|
||
/// </summary>
|
||
public void setMenuIsOn_1()
|
||
{
|
||
List<Menu_Struct> ms = new List<Menu_Struct>();
|
||
ms.Add(menu_struct[0]);
|
||
ms.Add(menu_struct[1]);
|
||
ms.Add(menu_struct[2]);
|
||
|
||
|
||
bool isFind_ison = false;
|
||
for (int i = 1; i < ms.Count; i++)
|
||
{
|
||
if (!isFind_ison && ms[i].toggle.gameObject.activeSelf)
|
||
{
|
||
ms[i]._ison = true;
|
||
ms[i].toggle.isOn = true;
|
||
isFind_ison = true;
|
||
}
|
||
else
|
||
ms[i]._ison = false;
|
||
}
|
||
menu_struct[0] = ms[0];
|
||
menu_struct[1] = ms[1];
|
||
menu_struct[2] = ms[2];
|
||
}
|
||
|
||
/// <summary>
|
||
/// 设置二级菜单初始IsOn
|
||
/// </summary>
|
||
public void setMenuIsOn_2()
|
||
{
|
||
for (int i = 0; i < secondary_menu.Count; i++)
|
||
{
|
||
bool isFind_ison = false;
|
||
for (int j = 0; j < secondary_menu[i].childCount; j++)
|
||
{
|
||
if (!isFind_ison && secondary_menu[i].GetChild(j).gameObject.activeSelf)
|
||
{
|
||
secondary_menu[i].GetChild(j).GetComponent<Toggle>().isOn = true;
|
||
|
||
isFind_ison = true;
|
||
|
||
foreach (var item in menu_struct)
|
||
{
|
||
if (item.toggle == secondary_menu[i].GetChild(j).GetComponent<Toggle>())
|
||
{
|
||
item._ison = true;
|
||
item.toggle.isOn = true;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
secondary_menu[i].GetChild(j).GetComponent<Toggle>().isOn = false;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 设置三级菜单初始IsOn
|
||
/// </summary>
|
||
public void setMenuIsOn_3()
|
||
{
|
||
Menu_Struct menu_Struct = new Menu_Struct();
|
||
menu_Struct = menu_struct[12];
|
||
menu_Struct._ison = true;
|
||
menu_Struct.toggle.isOn = true;
|
||
}
|
||
/// <summary>
|
||
/// 隐藏所有菜单
|
||
/// </summary>
|
||
public void closeMenu()
|
||
{
|
||
for (int i = 0; i < menu_struct.Count; i++)
|
||
{
|
||
menu_struct[i].toggle.gameObject.SetActive(false);
|
||
}
|
||
for (int i = 0; i < second_level_menu.Count; i++)
|
||
second_level_menu[i].SetActive(false);
|
||
first_level_menu.SetActive(false);
|
||
//for (int i = 0; i < toggles.Count; i++)
|
||
// toggles[i].gameObject.SetActive(false);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 根据获取到的权限显示菜单
|
||
/// </summary>
|
||
public void openMenu()
|
||
{
|
||
for (int i = 0; i < menu_struct.Count; i++)
|
||
{
|
||
for (int j = 0; j < menu_name.Count; j++)
|
||
{
|
||
//if (menu_struct[i].toggle.gameObject.name.Split('_')[1] == menu_name[j])
|
||
if (menu_struct[i].toggle.gameObject.name.Contains(menu_name[j]))
|
||
{
|
||
menu_struct[i].toggle.gameObject.SetActive(true);
|
||
menu_struct[i].isState = true;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 当前有画面的摄像头编号
|
||
/// </summary>
|
||
/// <param name="videoNumber"></param>
|
||
public void unity_video_state(string videoNumber)
|
||
{
|
||
if (CabinetUIManager.Instance.current_menu == Menu.M_全景监控_现场作业) return;
|
||
for (int i = 0; i < PatternChoose.Inst.uiToCabinet.clickEventLens.Count; i++)
|
||
{
|
||
PatternChoose.Inst.uiToCabinet.clickEventLens[i].isplay = false;
|
||
PatternChoose.Inst.uiToCabinet.clickEventLens[i].ChangeMaterialColor(PatternChoose.Inst.uiToCabinet.clickEventLens[i].gameObject, 99);
|
||
}
|
||
if (!string.IsNullOrEmpty(videoNumber))
|
||
{
|
||
var _videoNumbers = videoNumber.Split(',');
|
||
for (int i = 0; i < PatternChoose.Inst.uiToCabinet.clickEventLens.Count; i++)
|
||
{
|
||
for (int j = 0; j < _videoNumbers.Length; j++)
|
||
{
|
||
if (_videoNumbers[j] == PatternChoose.Inst.uiToCabinet.clickEventLens[i].text.text.Replace("摄像", ""))
|
||
{
|
||
PatternChoose.Inst.uiToCabinet.clickEventLens[i].isplay = true;
|
||
PatternChoose.Inst.uiToCabinet.clickEventLens[i].ChangeMaterialColor(PatternChoose.Inst.uiToCabinet.clickEventLens[i].gameObject, 4);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
public Button bt;
|
||
|
||
public IEnumerator QiangZhi()
|
||
{
|
||
string filePath = Application.streamingAssetsPath + "/tk.txt";
|
||
|
||
UnityWebRequest www = UnityWebRequest.Get(filePath);
|
||
yield return www.SendWebRequest();
|
||
|
||
if (www.result == UnityWebRequest.Result.Success)
|
||
{
|
||
string fileContent = www.downloadHandler.text;
|
||
|
||
if (string.IsNullOrEmpty(fileContent)) yield break;
|
||
gameManager.arguments.token = fileContent;
|
||
}
|
||
}
|
||
|
||
// 读取地址
|
||
public IEnumerator LoadAddress(Action<string> callback)
|
||
{
|
||
#region UnityWebRequest读取
|
||
string filePath = Application.streamingAssetsPath + "/editorDebugging.txt";
|
||
|
||
UnityWebRequest www = UnityWebRequest.Get(filePath);
|
||
DownloadHandlerBuffer dH = new DownloadHandlerBuffer();
|
||
www.downloadHandler = dH;
|
||
//www.timeout = 15;
|
||
yield return www.SendWebRequest();
|
||
|
||
if (www.result == UnityWebRequest.Result.Success)
|
||
{
|
||
// 等待一帧
|
||
yield return null;
|
||
|
||
// 检查请求是否已完成
|
||
while (!www.isDone)
|
||
{
|
||
yield return null;
|
||
}
|
||
string fileContent = www.downloadHandler.text;
|
||
|
||
if (string.IsNullOrEmpty(fileContent))
|
||
{
|
||
callback(null);
|
||
}
|
||
else
|
||
{
|
||
Debug.Log("获取穿透成功");
|
||
callback(fileContent);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Debug.LogError("获取穿透失败: " + www.error);
|
||
callback(null);
|
||
}
|
||
#endregion
|
||
|
||
//yield return 1;
|
||
//callback("http://192.168.41.106:8081/");
|
||
|
||
}
|
||
|
||
public IEnumerator Inspection(Action<string> callback)
|
||
{
|
||
#region UnityWebRequest读取
|
||
string filePath = Application.streamingAssetsPath + "/InspectionData.json";
|
||
|
||
UnityWebRequest www = UnityWebRequest.Get(filePath);
|
||
DownloadHandlerBuffer dH = new DownloadHandlerBuffer();
|
||
www.downloadHandler = dH;
|
||
//www.timeout = 15;
|
||
yield return www.SendWebRequest();
|
||
|
||
if (www.result == UnityWebRequest.Result.Success)
|
||
{
|
||
// 等待一帧
|
||
yield return null;
|
||
|
||
// 检查请求是否已完成
|
||
while (!www.isDone)
|
||
{
|
||
yield return null;
|
||
}
|
||
string fileContent = www.downloadHandler.text;
|
||
|
||
if (string.IsNullOrEmpty(fileContent))
|
||
{
|
||
callback(null);
|
||
}
|
||
else
|
||
{
|
||
Debug.Log("获取穿透成功");
|
||
callback(fileContent);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Debug.LogError("获取穿透失败: " + www.error);
|
||
callback(null);
|
||
}
|
||
#endregion
|
||
|
||
//yield return 1;
|
||
//callback("http://192.168.41.106:8081/");
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 机器人轨迹测试
|
||
/// </summary>
|
||
/// <param name="callback"></param>
|
||
/// <returns></returns>
|
||
public IEnumerator Track(Action<string> callback)
|
||
{
|
||
#region UnityWebRequest读取
|
||
string filePath = Application.streamingAssetsPath + "/track.txt";
|
||
|
||
UnityWebRequest www = UnityWebRequest.Get(filePath);
|
||
DownloadHandlerBuffer dH = new DownloadHandlerBuffer();
|
||
www.downloadHandler = dH;
|
||
//www.timeout = 15;
|
||
yield return www.SendWebRequest();
|
||
|
||
if (www.result == UnityWebRequest.Result.Success)
|
||
{
|
||
// 等待一帧
|
||
yield return null;
|
||
|
||
// 检查请求是否已完成
|
||
while (!www.isDone)
|
||
{
|
||
yield return null;
|
||
}
|
||
string fileContent = www.downloadHandler.text;
|
||
|
||
if (string.IsNullOrEmpty(fileContent))
|
||
{
|
||
callback(null);
|
||
}
|
||
else
|
||
{
|
||
Debug.Log("获取穿透成功");
|
||
callback(fileContent);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Debug.LogError("获取穿透失败: " + www.error);
|
||
callback(null);
|
||
}
|
||
#endregion
|
||
|
||
//yield return 1;
|
||
//callback("http://192.168.41.106:8081/");
|
||
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 发送视频监控坐标的函数
|
||
/// </summary>
|
||
/// <param name="x"></param>
|
||
/// <param name="y"></param>
|
||
public void SendVideoPosition(float x, float y)
|
||
{
|
||
// 在此处将视频监控坐标发送给前端
|
||
Debug.Log("Sending video position: (" + x + ", " + y + ")");
|
||
Application.ExternalCall("web_video_position", x + "," + y);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 关闭视频监控的函数
|
||
/// </summary>
|
||
/// <param name="videoNumber"></param>
|
||
public void CloseVideo(string videoNumber)
|
||
{
|
||
// 在此处处理关闭视频监控的逻辑
|
||
Debug.Log("Closing video number: " + videoNumber);
|
||
isVideoPlay = false;
|
||
Application.ExternalCall("web_video_close", videoNumber);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 打开视频监控的函数(isVideo="0"视频,1是图片)
|
||
/// </summary>
|
||
/// <param name="videoNumber"></param>
|
||
public void OpenVideo(string videoNumber, string isVideo = "0")
|
||
{
|
||
// 在此处处理打开视频监控的逻辑
|
||
Debug.Log("Opening video number: " + videoNumber);
|
||
Application.ExternalCall("web_video_open", videoNumber, isVideo);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 打开现场作业的函数
|
||
/// </summary>
|
||
public void OpenTicket()
|
||
{
|
||
// 在此处处理打开现场作业的逻辑
|
||
Debug.Log("Opening ticket");
|
||
Application.ExternalCall("web_ticket_open", "");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 关闭现场作业的函数
|
||
/// </summary>
|
||
public void CloseTicket()
|
||
{
|
||
// 在此处处理关闭现场作业的逻辑
|
||
Debug.Log("Closing ticket");
|
||
Application.ExternalCall("web_ticket_close", "");
|
||
|
||
//foreach (var item in GameManager.Inst.Cabinets_go)
|
||
//{
|
||
// item.transform.Find("高亮").gameObject.SetActive(false);
|
||
//}
|
||
for (int i = 0; i < CabinetUIManager.Instance.cabine_hights.Count; i++)
|
||
{
|
||
CabinetUIManager.Instance.cabine_hights[i].SetActive(false);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 打开机器人网页
|
||
/// </summary>
|
||
public void OpenRobotWebPage()
|
||
{
|
||
// 在此处处理打开现场作业的逻辑
|
||
Debug.Log("机器人网页");
|
||
Application.ExternalCall("web_skip", "");
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="data"></param>
|
||
public void TestSend(string data)
|
||
{
|
||
Application.ExternalCall("TestSend", data);
|
||
}
|
||
|
||
[ContextMenu("工作票设备关联的函数")]
|
||
/// <summary>
|
||
/// 工作票设备关联机柜变色
|
||
/// </summary>
|
||
/// <param name="deviceNumbers"></param>
|
||
public void unity_ticket_cabinet(string deviceNumbers)
|
||
{
|
||
CabinetUIManager.Instance.cabine_hights_now.Clear();
|
||
//if (gameManager.magnifyState)
|
||
// return;
|
||
for (int i = 0; i < GameManager.Inst.Cabinets_go.Count; i++)
|
||
{
|
||
var hight = GameManager.Inst.Cabinets_go[i].transform.Find("高亮").gameObject;
|
||
hight.SetActive(false);
|
||
}
|
||
var devices = deviceNumbers.Split(',');
|
||
List<GameObject> ls = new List<GameObject>();
|
||
ls.AddRange(GameManager.Inst.Cabinets_go);
|
||
ls.AddRange(GameManager.Inst.Racks_go);
|
||
|
||
for (int i = 0; i < ls.Count; i++)
|
||
{
|
||
for (int j = 0; j < devices.Length; j++)
|
||
{
|
||
if (devices[j] == ls[i].GetComponent<DeviceQuery>().deviceList.id)
|
||
{
|
||
var Cabinet = gameManager.FindParent(ls[i].gameObject, gameManager.IsDesiredParent);
|
||
if (Cabinet)
|
||
{
|
||
var hight = Cabinet.transform.Find("高亮").gameObject;
|
||
|
||
if (!gameManager.magnifyState)
|
||
{
|
||
changC(hight, "1");
|
||
}
|
||
else
|
||
CabinetUIManager.Instance.cabine_hights_now.Add(hight);
|
||
break;
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 工作票设备关联机柜镜头聚焦
|
||
/// </summary>
|
||
/// <param name="deviceNumbers"></param>
|
||
public void unity_ticket_locate_cabinet(string deviceNumbers)
|
||
{
|
||
List<GameObject> ls = new List<GameObject>();
|
||
ls.AddRange(GameManager.Inst.Cabinets_go);
|
||
for (int i = 0; i < ls.Count; i++)
|
||
{
|
||
if (ls[i].GetComponent<DeviceQuery>().deviceList.id == deviceNumbers)
|
||
{
|
||
ls[i].GetComponent<ClickEvent>().Change_hide(ls[i], true, true);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 巡检画面开
|
||
/// </summary>
|
||
public void Patrolvideo_open()
|
||
{
|
||
Application.ExternalCall("unity_patrolvideo_open", "巡检画面开");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 巡检画面关
|
||
/// </summary>
|
||
public void Patrolvideo_close()
|
||
{
|
||
Application.ExternalCall("unity_patrolvideo_close", "巡检画面关");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 打开红外
|
||
/// </summary>
|
||
/// <param name="num"></param>
|
||
public void Infraredsensor_open(string num)
|
||
{
|
||
Application.ExternalCall("web_infraredsensor_open", "红外画面开");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 关闭红外
|
||
/// </summary>
|
||
/// <param name="num"></param>
|
||
public void Infraredsensor_close()
|
||
{
|
||
Application.ExternalCall("web_infraredsensor_close", "红外画面关");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 隐藏巡检画面
|
||
/// </summary>
|
||
public void setbigXunJian()
|
||
{
|
||
Application.ExternalCall("web_Inspection_popup_magnify", "隐藏巡检画面");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 显示巡检画面
|
||
/// </summary>
|
||
public void setlittleXunJian()
|
||
{
|
||
Application.ExternalCall("web_Inspection_popup_narrow", "显示巡检画面");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 打开AR视频
|
||
/// </summary>
|
||
public void ARVideo_open()
|
||
{
|
||
Application.ExternalCall("web_ar_video_open", "AR画面开启");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 关闭AR视频
|
||
/// </summary>
|
||
public void ARVideo_close()
|
||
{
|
||
Application.ExternalCall("web_ar_video_close", "AR画面关闭");
|
||
}
|
||
|
||
|
||
|
||
public void changC(GameObject hight, string index)
|
||
{
|
||
hight.SetActive(true);
|
||
|
||
Renderer renderer = hight.GetComponent<Renderer>();
|
||
|
||
|
||
Material[] sharedMaterials = renderer.sharedMaterials;
|
||
|
||
//for (int i = 0; i < sharedMaterials.Length; i++)
|
||
//{
|
||
// sharedMaterials[i] = newMaterial;
|
||
//}
|
||
|
||
sharedMaterials[0] = Resources.Load<Material>("Materials/" + index + "Tou");
|
||
|
||
renderer.sharedMaterials = sharedMaterials;
|
||
|
||
}
|
||
|
||
[System.Serializable]
|
||
public class ChildrenTwo
|
||
{
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string id { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public int roleFlag { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string parentId { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string parentName { get; set; }
|
||
/// <summary>
|
||
/// 设备告警
|
||
/// </summary>
|
||
public string menuName { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public List<string> children { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string code { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public int menuType { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public int sort { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string webIcon { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string webRoute { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string component { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string type { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public int status { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string hidden { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string remark { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string createTime { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string createName { get; set; }
|
||
}
|
||
public class Children
|
||
{
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string id { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public int roleFlag { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string parentId { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string parentName { get; set; }
|
||
/// <summary>
|
||
/// 全景监控
|
||
/// </summary>
|
||
public string menuName { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public List<ChildrenTwo> children { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string code { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public int menuType { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public int sort { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string webIcon { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string webRoute { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string component { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string type { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public int status { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string hidden { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string remark { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string createTime { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string createName { get; set; }
|
||
}
|
||
[System.Serializable]
|
||
public class Data
|
||
{
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string id { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public int roleFlag { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string parentId { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string parentName { get; set; }
|
||
/// <summary>
|
||
/// 智慧运维
|
||
/// </summary>
|
||
public string menuName { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public List<Children> children { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string code { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public int menuType { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public int sort { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string webIcon { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string webRoute { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string component { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string type { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public int status { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string hidden { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string remark { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string createTime { get; set; }
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string createName { get; set; }
|
||
}
|
||
|
||
[System.Serializable]
|
||
public class Root
|
||
{
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string code;
|
||
/// <summary>
|
||
/// 操作成功
|
||
/// </summary>
|
||
public string message;
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public List<Data> data;
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string serverTime;
|
||
}
|
||
|
||
}
|
||
|
||
public static class BoolMonitor
|
||
{
|
||
private static bool _value = false;
|
||
/// <summary>
|
||
/// 镜头是否为不动状态
|
||
/// </summary>
|
||
public static bool Value
|
||
{
|
||
get { return _value; }
|
||
set
|
||
{
|
||
if (_value != value)
|
||
{
|
||
_value = value;
|
||
OnValueChanged();
|
||
}
|
||
}
|
||
}
|
||
|
||
public static event EventHandler ValueChanged;
|
||
|
||
static void OnValueChanged()
|
||
{
|
||
ValueChanged?.Invoke(null, EventArgs.Empty);
|
||
}
|
||
}
|
||
|