batteryDiagnosis/Assets/Scripts/ChangeObjMat.cs

277 lines
11 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 HighlightPlus;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class ChangeObjMat : MonoBehaviour
{
public Material m_TM;
public List<MeshRenderer> m_RendererList;
private List<List<Material>> m_RecordRendererList = new List<List<Material>>();
/// <summary>
/// 车辆物体
/// </summary>
public GameObject m_Obj;
/// <summary>
/// 车辆线框
/// </summary>
public GameObject m_XKObj;
/// <summary>
/// 车牌扫描
/// </summary>
public GameObject m_CPObj;
/// <summary>
/// 车身扫描
/// </summary>
public GameObject m_CSSMObj;
/// <summary>
/// 红外扫描
/// </summary>
public GameObject m_HWSMObj;
/// <summary>
/// 紫外扫描
/// </summary>
public GameObject m_ZWSMObj;
/// <summary>
/// 声纹检测
/// </summary>
public GameObject m_SWJCObj;
/// <summary>
/// 电池检测
/// </summary>
public GameObject m_DCJCObj;
/// <summary>
/// 预约均衡
/// </summary>
public GameObject m_JHJCObj;
/// <summary>
/// 电池高亮
/// </summary>
public HighlightEffect m_HighlightEffect;
void Start()
{
m_RendererList = GetComponentsInChildren<MeshRenderer>().ToList();
m_RecordRendererList.Clear();
for (int i = 0; i < m_RendererList.Count; i++)
{
m_RecordRendererList.Add(m_RendererList[i].materials.ToList());
}
if (Bootstrap.Instance != null) Bootstrap.Instance.eventCenter.AddEventListener<bool>(Enum_EventType.ChangeChildrenMat, ChangeChildrenMat);
if (Bootstrap.Instance != null) Bootstrap.Instance.eventCenter.AddEventListener(Enum_EventType.StepSwitching, StepSwitching);
ChangeChildrenMat(true);
}
public void ChangeChildrenMat(bool Change)
{
if (Change)
{
for (int i = 0; i < m_RendererList.Count; i++)
{
int len = m_RendererList[i].materials.Length;
Material[] matArr = new Material[len];
for (int j = 0; j < len; j++)
{
matArr[j] = m_TM;
}
for (int j = 0; j < len; j++)
{
m_RendererList[i].materials = matArr;
}
}
}
else
{
for (int i = 0; i < m_RecordRendererList.Count; i++)
{
List<Material> materialList = m_RecordRendererList[i];
m_RendererList[i].materials = materialList.ToArray();
}
}
}
public void StepSwitching()
{
StartCoroutine(StepSwitchingCoroutine());
}
IEnumerator StepSwitchingCoroutine()
{
Debug.Log("StepSwitchingCoroutine");
#region
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"您的爱车已入场!", 3);
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"车辆入场");
});
yield return new WaitForSeconds(3);
#endregion
#region
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"车牌识别");
m_XKObj.SetActive(true);
m_CPObj.SetActive(true);
m_Obj.SetActive(false);
yield return new WaitForSeconds(5);
m_CPObj.SetActive(false);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"检测到车牌号为" + GetawayMqttClient.licensePlateData.LicensePlateNumber + "", 5);
});
yield return new WaitForSeconds(6);
#endregion
#region
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"现在进入车身外观检测环节1.深度检测已开始!", 5);
});
yield return new WaitForSeconds(5);
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"车身外观检测");
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"2.车外观检测开始!", 3);
});
yield return new WaitForSeconds(3);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"3.您的爱车正进行车外观检测...", 10);
});
m_CSSMObj.SetActive(true);
yield return new WaitForSeconds(11);
m_CSSMObj.SetActive(false);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"车外观检测已完成!", 5);
});
yield return new WaitForSeconds(6);
#endregion
#region
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"车辆即将进行红外实时探测1.红外检测已开始!", 3);
});
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"红外实时探测");
yield return new WaitForSeconds(3);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"2.您的爱车正进行红外检测...", 10);
});
m_HighlightEffect.SetHighlighted(true);
m_HWSMObj.SetActive(true);////
yield return new WaitForSeconds(11);
m_HWSMObj.SetActive(false);////
m_HighlightEffect.SetHighlighted(false);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"3红外检测已完成", 5);
});
yield return new WaitForSeconds(6);
#endregion
#region
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"车辆即将进行紫外实时探测1.紫外检测已开始!", 3);
});
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"紫外实时探测");
yield return new WaitForSeconds(3);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"2.您的爱车正进行紫外检测...", 10);
});
m_HighlightEffect.SetHighlighted(true);
m_ZWSMObj.SetActive(true);////
yield return new WaitForSeconds(11);
m_ZWSMObj.SetActive(false);////
m_HighlightEffect.SetHighlighted(false);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"3.紫外检测已完成!", 5);
});
yield return new WaitForSeconds(6);
#endregion
#region
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"车辆进行声纹检测1.声纹检测已开始!", 3);
});
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"声纹检测");
yield return new WaitForSeconds(3);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"2.您的爱车正进行声纹检测...", 10);
});
m_SWJCObj.SetActive(true);////
yield return new WaitForSeconds(11);
m_SWJCObj.SetActive(false);////
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"3.声纹观检测已完成!", 5);
});
yield return new WaitForSeconds(6);
#endregion
#region
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"均衡一体机检测准备1.电池检测已开始!", 5);
});
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"电池检测");
yield return new WaitForSeconds(5);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"2.您的爱车正进行电池检测...", 10);
});
m_HighlightEffect.SetHighlighted(true);
m_DCJCObj.SetActive(true);////
yield return new WaitForSeconds(11);
m_DCJCObj.SetActive(false);////
m_HighlightEffect.SetHighlighted(false);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"3.电池检测已完成!", 3);
});
yield return new WaitForSeconds(4);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"4.深度检测已完成!", 5);
});
yield return new WaitForSeconds(6);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"5.深度检测报告已生成,请扫描屏幕右下角的二维码获取!", 30);
});
UI_BGPanel.btn_h51.gameObject.SetActive(true);
yield return new WaitForSeconds(31);
#endregion
#region
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"您已预约电池均衡操作,请稍等...", 30);
});
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"预约均衡");
m_HighlightEffect.SetHighlighted(true);
m_JHJCObj.SetActive(true);
yield return new WaitForSeconds(31);
m_JHJCObj.SetActive(false);
m_HighlightEffect.SetHighlighted(false);
#endregion
#region
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.Top, (p) =>
{
p.Init($"电池均衡操作已完成,请扫描屏幕右下角的二维码获取\n均衡报告感谢您的支持和配合祝您一路平安", 0);
});
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"电池诊所检测及均衡全流程已完成");
m_XKObj.SetActive(false);
m_Obj.SetActive(true);
UI_BGPanel.btn_h52.gameObject.SetActive(true);
#endregion
}
private void OnDisable()
{
if (Bootstrap.Instance != null)
{
Bootstrap.Instance.eventCenter.RemoveEventListener<bool>(Enum_EventType.ChangeChildrenMat, ChangeChildrenMat);
Bootstrap.Instance.eventCenter.RemoveEventListener(Enum_EventType.StepSwitching, StepSwitching);
}
}
}