using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; using ZenFulcrum.EmbeddedBrowser; /// /// 异常Icon /// wumin /// public class Exception3DIcon : MonoBehaviour { public ExceptionType expType;//异常类型 public int expID;//异常编号 private string[] imgPath; private Color[] colorList; private Camera cam; private string expName; private void Awake() { //异常Icon地址,顺序和异常类型保持一致 0:离岗;1:人员聚集;2:防滑设施;3:温度异常;4:工单临期;5:工单逾期 imgPath = new string[] { "UI/ExpIcon/icon-lgyc", "UI/ExpIcon/icon-ryjj", "UI/ExpIcon/icon-fhsswbf", "UI/ExpIcon/icon-twyc", "UI/ExpIcon/icon-gdlq", "UI/ExpIcon/icon-gdyq", "UI/ExpIcon/icon-sbyc" }; colorList = new Color[] { new Color (234/255f,45/255f,19/255f,1), new Color (234/255f,45/255f,19/255f,1), new Color (255/255f,151/255f,30/255f,1), new Color (234/255f,45/255f,19/255f,1), new Color (210/255f,175/255f,22/255f,1), new Color (210/255f,175/255f,22/255f,1), new Color (234/255f,45/255f,19/255f,1) }; } // Start is called before the first frame update void Start() { cam = Camera.main; } // Update is called once per frame void Update() { //Icon永远朝着镜头 if (cam != null) transform.LookAt(cam.transform.position, Vector3.up); } /// /// 初始化3D图标样式 /// public void InitExpIcon(ExceptionType type,int index) { //Debug.Log(imgPath[type.GetHashCode()-1]); expType = type; expID=index; Sprite s = GameObject.Instantiate(Resources.Load(imgPath[type.GetHashCode()-1])); GetComponent().sprite = s; GetComponent().SetNativeSize(); //point颜色 transform.Find("point").GetComponent().color = colorList[type.GetHashCode() - 1]; //动态光圈的颜色 transform.Find("effect").GetComponent().material.SetColor("_Color", colorList[type.GetHashCode() - 1]); } /// /// 点击Icon /// private void OnMouseDown() { if (EventSystem.current.IsPointerOverGameObject()) { Debug.Log("鼠标在UI上"); return; } ShowExpInfo(); //if (expType == ExceptionType.LeavePost) //{ // EmptyPeople(); //} else if (expType == ExceptionType.PeopleGather) //{ // PeopleGather(); //} //else if (expType == ExceptionType.Antislip) { // AntislipTip(); //} //else if (expType == ExceptionType.Temperature) //{ // TemperatureTip(); //} //else if (expType == ExceptionType.GongDanLinQi) //{ // GongDanLinQi(); //} //else if (expType == ExceptionType.GongDanYuQi) //{ // GongDanYuQi(); //} //else if (expType == ExceptionType.DeviceExp) //{ // DeviceExp(); //} } /// /// 空位警告 /// public void ShowExpInfo() { Debug.Log("异常信息!"+ transform.name); Main.intance.m_htmlPanel.CallFunction("showAlarmVideo", transform.name); } /// /// 空位警告 /// public void EmptyPeople() { Debug.Log("离岗异常!"); Main.intance.m_htmlPanel.CallFunction("showAlarmVideo",0); } /// /// 人员聚集 /// public void PeopleGather() { Debug.Log("人员聚集!"); Main.intance.m_htmlPanel.CallFunction("showAlarmVideo",1); } /// /// 防滑设施未摆放 /// public void AntislipTip() { Debug.Log("防滑设施未摆放"); Main.intance.m_htmlPanel.CallFunction("showAlarmVideo",5); } /// /// 温度异常 /// public void TemperatureTip() { Debug.Log("温度异常!"); Main.intance.m_htmlPanel.CallFunction("showAlarmVideo",6); } /// /// 工单临期 /// public void GongDanLinQi() { Debug.Log("工单临期!"); Main.intance.m_htmlPanel.CallFunction("showAlarmVideo",2); } /// /// 工单逾期 /// public void GongDanYuQi() { Debug.Log("工单逾期!"); Main.intance.m_htmlPanel.CallFunction("showAlarmVideo",3); } /// /// 设备异常 /// public void DeviceExp() { Debug.Log("设备异常!"); Main.intance.m_htmlPanel.CallFunction("showAlarmVideo", 7); } } public struct ExceptionDataTest { public ExceptionInfoTest[] infoList; } public struct ExceptionInfoTest { public int ExceptionID; public int ExceptionType; } public struct ExceptionData { public ExceptionInfo[] arr; } /// /// 事件异常数据() /// public struct ExceptionInfo { public string window; public string eventType; public string type; public int status; public string content; public string name; public string jobType; public string time; public string imgUrl; } /// /// 异常类型 /// public enum ExceptionType { NONE,//无异常 LeavePost,//人员离岗 PeopleGather,//人员聚集 Antislip,//防滑设施未摆放 Temperature,//体温异常 GongDanLinQi,//工单临期 GongDanYuQi,//工单逾期 DeviceExp//设备异常 }