using DG.Tweening; 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>(); #region 车辆物体 /// /// 车辆物体 /// 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_SWSMObj; /// /// 声纹检测 /// public GameObject m_SWJCObj; /// /// 电池检测 /// public GameObject m_DCJCObj; /// /// 预约均衡 /// public GameObject m_JHJCObj; /// /// 电池高亮 /// public HighlightEffect m_HighlightEffect; /// /// 充电口高亮 /// public HighlightEffect m_Highlight; /// /// 充电特效 /// public GameObject[] m_effectObj; /// /// 充电枪 /// public GameObject m_gunObj; #endregion private bool isPlay; private Config config = new Config(); 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); Bootstrap.Instance.eventCenter.AddEventListener(Enum_EventType.StepSwitching, StepSwitching); Bootstrap.Instance.eventCenter.AddEventListener(Enum_EventType.OnPlay, OnPlay); } ChangeChildrenMat(true); config = Bootstrap.LoadData("DataConfig"); if (config.PlayBack.Contains("true")) { isPlay = false; } else { isPlay = true; } } public void OnPlay() { isPlay = 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(StepCoroutine()); } IEnumerator StepCoroutine() { Debug.Log("StepSwitching"); #region 车辆入场 if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"待检车辆已入场!", 5); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"待检车辆已入场"); }); yield return new WaitForSeconds(6); #endregion #region 车牌识别 if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"智能预检开始!", 5); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"智能预检开始"); }); m_XKObj.SetActive(true); m_Obj.SetActive(false); m_CPObj.SetActive(true); yield return new WaitForSeconds(6); m_CPObj.SetActive(false); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"检测到车牌号为" + GetawayMqttClient.licensePlateData.LicensePlateNumber + "!", 5); }); WebViewController.Instance.CallGetButtonClickWithCode("车牌识别"); yield return new WaitForSeconds(6); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"智能预检已完成!", 0); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"智能预检已完成"); }); yield return new WaitForSeconds(3); #endregion #region 插枪操作 m_Highlight.SetHighlighted(true); transform.parent.DOLocalRotate(new Vector3(-90, 0, -320), 5); yield return new WaitForSeconds(5); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"车辆驶入检测区", 0); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"车辆驶入检测区"); }); Material[] tmpMat = m_gunObj.GetComponent().materials; for (int i = 0; i < tmpMat.Length; i++) { tmpMat[i].DOFade(1, 2); } yield return new WaitForSeconds(2); m_gunObj.transform.GetChild(0).gameObject.SetActive(true); yield return new WaitForSeconds(2); m_gunObj.GetComponent().DOPlayById("Gun"); yield return new WaitForSeconds(5); m_Highlight.SetHighlighted(false); for (int i = 0; i < m_effectObj.Length; i++) { m_effectObj[i].SetActive(true); } yield return new WaitForSeconds(2); m_gunObj.transform.GetChild(0).gameObject.SetActive(false); for (int i = 0; i < tmpMat.Length; i++) { tmpMat[i].DOFade(0, 3); } yield return new WaitForSeconds(3); yield return new WaitUntil(() => isPlay == true); //WebViewController.Instance.CallGetButtonClickWithCode("电池检测"); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.CanRotate); yield return new WaitForSeconds(3); #endregion #region 360°车体探伤 if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"360°车体探伤开始!", 0); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"车体探伤开始"); }); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.GetPanel().OnLoadCSVideo(); m_CSSMObj.SetActive(true); yield return new WaitForSeconds(15); m_CSSMObj.SetActive(false); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"360°车体探伤已完成!", 5); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"车体探伤已完成"); }); yield return new WaitForSeconds(6); #endregion #region 电池健康度检测 if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"电池健康度检测开始!", 5); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"电池健康检测开始"); WebViewController.Instance.CallGetButtonClickWithCode("电池检测"); }); m_HighlightEffect.SetHighlighted(true); m_DCJCObj.SetActive(true); yield return new WaitForSeconds(6); //m_HighlightEffect.SetHighlighted(false); m_DCJCObj.SetActive(false); #endregion #region 多光谱探测 if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"底盘多光谱热失控探测开始!", 5); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"多光谱探测开始"); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.GetPanel().OnLoadHWVideo(); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.GetPanel().OnLoadZWVideo(); }); //m_HWSMObj.SetActive(true); m_ZWSMObj.SetActive(true); m_HighlightEffect.SetHighlighted(true); m_HWSMObj.SetActive(true); m_ZWSMObj.SetActive(true); yield return new WaitForSeconds(6); //m_HWSMObj.SetActive(false); m_ZWSMObj.SetActive(false); m_HighlightEffect.SetHighlighted(false); #endregion #region 声纹检测 if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"声纹异常振动检测开始!", 5); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"声纹检测开始"); WebViewController.Instance.CallGetButtonClickWithCode("声纹检测"); }); m_SWSMObj.SetActive(true); m_SWJCObj.SetActive(true); yield return new WaitForSeconds(config.WaitingTime); //m_SWJCObj.SetActive(false); m_SWSMObj.SetActive(false); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"电池健康检测已完成!", 5); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"电池健康检测已完成"); }); m_DCJCObj.SetActive(false); yield return new WaitForSeconds(6); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"底盘多光谱热失控探测已完成!", 5); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"多光谱探测已完成"); }); m_HWSMObj.SetActive(false); m_ZWSMObj.SetActive(false); yield return new WaitForSeconds(6); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"声纹异常振动检测已完成!", 5); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"声纹检测已完成"); }); m_SWJCObj.SetActive(false); m_SWSMObj.SetActive(false); yield return new WaitForSeconds(6); #endregion #region 深度检测报告 if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"车辆安全检测已全部完成!", 0); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"车辆安全检测已全部完成"); WebViewController.Instance.CallGetButtonClickWithCode("二维码"); }); m_XKObj.SetActive(false); m_Obj.SetActive(true); m_HighlightEffect.SetHighlighted(false); yield return new WaitForSeconds(5); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"检测报告已生成,请扫描屏幕右下角的二维码获取报告!", 0); }); #endregion } IEnumerator StepSwitchingCoroutine() { Debug.Log("StepSwitchingCoroutine"); #region 车辆入场 if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(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_Obj.SetActive(false); m_CPObj.SetActive(true); yield return new WaitForSeconds(5); m_CPObj.SetActive(false); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"检测到车牌号为" + GetawayMqttClient.licensePlateData.LicensePlateNumber + "!", 5); }); WebViewController.Instance.CallGetButtonClickWithCode("车牌识别"); yield return new WaitForSeconds(6); #endregion #region 插枪操作 m_Highlight.SetHighlighted(true); transform.parent.DOLocalRotate(new Vector3(-90, 0, -320), 5); yield return new WaitForSeconds(5); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"插枪操作"); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"请插入充电枪!", 0); }); Material[] tmpMat = m_gunObj.GetComponent().materials; for (int i = 0; i < tmpMat.Length; i++) { tmpMat[i].DOFade(1, 2); } yield return new WaitForSeconds(2); m_gunObj.GetComponent().DOPlayById("Gun"); yield return new WaitForSeconds(5); m_Highlight.SetHighlighted(false); for (int i = 0; i < m_effectObj.Length; i++) { m_effectObj[i].SetActive(true); } yield return new WaitForSeconds(2); for (int i = 0; i < tmpMat.Length; i++) { tmpMat[i].DOFade(0, 3); } yield return new WaitForSeconds(3); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"一键检测"); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"您的爱车现已进行充电检测,请进行一键检测操作并在大屏幕上查看检测情况!", 0); }); yield return new WaitUntil(() => isPlay == true); yield return new WaitForSeconds(5); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.CanRotate); #endregion #region 车身外观检测 if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"现在进入车身外观检测环节:深度检测已开始!", 5); }); yield return new WaitForSeconds(5); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"车身外观检测"); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"车身外观检测开始!", 3); }); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.GetPanel().OnLoadCSVideo(); yield return new WaitForSeconds(3); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"您的爱车正在进行车辆外观检测...", 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.Top, (p) => { p.Init($"车外观检测已完成!", 5); }); yield return new WaitForSeconds(6); #endregion #region 电池检测 if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"均衡一体机检测准备:电池检测已开始!", 5); }); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"电池检测"); yield return new WaitForSeconds(5); WebViewController.Instance.CallGetButtonClickWithCode("电池检测"); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"您的爱车正进行电池检测...", 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.Top, (p) => { p.Init($"电池检测已完成!", 3); }); yield return new WaitForSeconds(4); #endregion #region 红外实时探测 if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"车辆即将进行红外实时探测:红外检测已开始!", 3); }); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"红外实时探测"); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.GetPanel().OnLoadHWVideo(); yield return new WaitForSeconds(3); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"您的爱车正进行红外检测...", 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.Top, (p) => { p.Init($"红外检测已完成!", 5); }); yield return new WaitForSeconds(6); #endregion #region 紫外实时探测 if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"车辆即将进行紫外实时探测:紫外检测已开始!", 3); }); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.GetPanel().OnLoadZWVideo(); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"紫外实时探测"); yield return new WaitForSeconds(3); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"您的爱车正进行紫外检测...", 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.Top, (p) => { p.Init($"紫外检测已完成!", 5); }); yield return new WaitForSeconds(6); #endregion #region 声纹检测 if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"车辆进行声纹检测:声纹检测已开始!", 3); }); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"声纹检测"); yield return new WaitForSeconds(3); WebViewController.Instance.CallGetButtonClickWithCode("声纹检测"); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"您的爱车正进行声纹检测...", 10); }); m_SWSMObj.SetActive(true);//// m_SWJCObj.SetActive(true);//// yield return new WaitForSeconds(11); m_SWJCObj.SetActive(false);//// m_SWSMObj.SetActive(false);//// if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"声纹观检测已完成!", 5); }); yield return new WaitForSeconds(6); #endregion #region 深度检测报告 if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"深度检测已完成!", 5); }); yield return new WaitForSeconds(6); if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(this, E_UI_Layer.Top, (p) => { p.Init($"深度检测报告已生成,请扫描屏幕右下角的二维码获取!", 0); }); Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"电池诊所检测全流程已完成"); m_XKObj.SetActive(false); m_Obj.SetActive(true); WebViewController.Instance.CallGetButtonClickWithCode("二维码"); //UI_BGPanel.btn_h5gameObject.SetActive(true); yield return new WaitForSeconds(31); #endregion #region 预约均衡 /* if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel(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(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_h5gameObject.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); Bootstrap.Instance.eventCenter.RemoveEventListener(Enum_EventType.OnPlay, OnPlay); } } }