using HighlightPlus; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; public class ChangeObjMat : MonoBehaviour { public Material m_TM; public List m_RendererList; private List> m_RecordRendererList = new List>(); /// /// 车辆物体 /// public GameObject m_Obj; /// /// 车辆线框 /// public GameObject m_XKObj; /// /// 车牌扫描 /// public GameObject m_CPObj; /// /// 车身扫描 /// public GameObject m_CSSMObj; /// /// 红外扫描 /// public GameObject m_HWSMObj; /// /// 紫外扫描 /// public GameObject m_ZWSMObj; /// /// 声纹检测 /// public GameObject m_SWJCObj; /// /// 电池检测 /// public GameObject m_DCJCObj; /// /// 预约均衡 /// public GameObject m_JHJCObj; public HighlightEffect m_HighlightEffect; void Start() { m_RendererList = GetComponentsInChildren().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(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 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(this, E_UI_Layer.System, (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(this, E_UI_Layer.System, (p) => { p.Init($"检测到车牌号为" + GetawayMqttClient.licensePlateData.LicensePlateNumber + "!", 5); }); yield return new WaitForSeconds(6); #endregion #region 车身外观检测 if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.System, (p) => { p.Init($"现在进入车身外观检测环节1.深度检测已开始!", 5); }); yield return new WaitForSeconds(5); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"车身外观检测"); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.System, (p) => { p.Init($"2.车外观检测开始!", 3); }); yield return new WaitForSeconds(3); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.System, (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(this, E_UI_Layer.System, (p) => { p.Init($"车外观检测已完成!", 5); }); yield return new WaitForSeconds(6); #endregion #region 红外实时探测 if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.System, (p) => { p.Init($"车辆即将进行红外实时探测:1.红外检测已开始!", 3); }); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"红外实时探测"); yield return new WaitForSeconds(3); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.System, (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(this, E_UI_Layer.System, (p) => { p.Init($"3红外检测已完成!", 5); }); yield return new WaitForSeconds(6); #endregion #region 紫外实时探测 if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.System, (p) => { p.Init($"车辆即将进行紫外实时探测:1.紫外检测已开始!", 3); }); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"紫外实时探测"); yield return new WaitForSeconds(3); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.System, (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(this, E_UI_Layer.System, (p) => { p.Init($"3.紫外检测已完成!", 5); }); yield return new WaitForSeconds(6); #endregion #region 声纹检测 if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.System, (p) => { p.Init($"车辆进行声纹检测:1.声纹检测已开始!", 3); }); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"声纹检测"); yield return new WaitForSeconds(3); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.System, (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(this, E_UI_Layer.System, (p) => { p.Init($"3.声纹观检测已完成!", 5); }); yield return new WaitForSeconds(6); #endregion #region 深度检测报告 if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.System, (p) => { p.Init($"均衡一体机检测准备:1.电池检测已开始!", 5); }); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"电池检测"); yield return new WaitForSeconds(5); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.System, (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(this, E_UI_Layer.System, (p) => { p.Init($"3.电池检测已完成!", 3); }); yield return new WaitForSeconds(4); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.System, (p) => { p.Init($"4.深度检测已完成!", 5); }); yield return new WaitForSeconds(6); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.System, (p) => { p.Init($"5.深度检测报告已生成,请扫描屏幕右下角的二维码获取!", 30); }); yield return new WaitForSeconds(31); #endregion #region 预约均衡 if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.System, (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(this, E_UI_Layer.System, (p) => { p.Init($"电池均衡操作已完成,请扫描屏幕右下角的二维码获取均衡报告!感谢您的支持和配合,祝您一路平安!", 0); }); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"电池诊所检测及均衡全流程已完成"); m_XKObj.SetActive(false); m_Obj.SetActive(true); #endregion } private void OnDisable() { if (Bootstrap.Instance != null) { Bootstrap.Instance.eventCenter.RemoveEventListener(Enum_EventType.ChangeChildrenMat, ChangeChildrenMat); Bootstrap.Instance.eventCenter.RemoveEventListener(Enum_EventType.StepSwitching, StepSwitching); } } }