ElectricityBusinessHall_Dig.../Assets/Resources/Scripts/Function/Exception3DIcon.cs

243 lines
5.6 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 UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using ZenFulcrum.EmbeddedBrowser;
/// <summary>
/// 异常Icon
/// wumin
/// </summary>
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);
}
/// <summary>
/// 初始化3D图标样式
/// </summary>
public void InitExpIcon(ExceptionType type,int index) {
//Debug.Log(imgPath[type.GetHashCode()-1]);
expType = type;
expID=index;
Sprite s = GameObject.Instantiate(Resources.Load<Sprite>(imgPath[type.GetHashCode()-1]));
GetComponent<Image>().sprite = s;
GetComponent<Image>().SetNativeSize();
//point颜色
transform.Find("point").GetComponent<Image>().color = colorList[type.GetHashCode() - 1];
//动态光圈的颜色
transform.Find("effect").GetComponent<Renderer>().material.SetColor("_Color", colorList[type.GetHashCode() - 1]);
}
/// <summary>
/// 点击Icon
/// </summary>
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();
//}
}
/// <summary>
/// 空位警告
/// </summary>
public void ShowExpInfo()
{
Debug.Log("异常信息!"+ transform.name);
Main.intance.m_htmlPanel.CallFunction("showAlarmVideo", transform.name);
}
/// <summary>
/// 空位警告
/// </summary>
public void EmptyPeople()
{
Debug.Log("离岗异常!");
Main.intance.m_htmlPanel.CallFunction("showAlarmVideo",0);
}
/// <summary>
/// 人员聚集
/// </summary>
public void PeopleGather()
{
Debug.Log("人员聚集!");
Main.intance.m_htmlPanel.CallFunction("showAlarmVideo",1);
}
/// <summary>
/// 防滑设施未摆放
/// </summary>
public void AntislipTip()
{
Debug.Log("防滑设施未摆放");
Main.intance.m_htmlPanel.CallFunction("showAlarmVideo",5);
}
/// <summary>
/// 温度异常
/// </summary>
public void TemperatureTip()
{
Debug.Log("温度异常!");
Main.intance.m_htmlPanel.CallFunction("showAlarmVideo",6);
}
/// <summary>
/// 工单临期
/// </summary>
public void GongDanLinQi()
{
Debug.Log("工单临期!");
Main.intance.m_htmlPanel.CallFunction("showAlarmVideo",2);
}
/// <summary>
/// 工单逾期
/// </summary>
public void GongDanYuQi()
{
Debug.Log("工单逾期!");
Main.intance.m_htmlPanel.CallFunction("showAlarmVideo",3);
}
/// <summary>
/// 设备异常
/// </summary>
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;
}
/// <summary>
/// 事件异常数据()
/// </summary>
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;
}
/// <summary>
/// 异常类型
/// </summary>
public enum ExceptionType
{
NONE,//无异常
LeavePost,//人员离岗
PeopleGather,//人员聚集
Antislip,//防滑设施未摆放
Temperature,//体温异常
GongDanLinQi,//工单临期
GongDanYuQi,//工单逾期
DeviceExp//设备异常
}