using QFramework; using System.Collections.Generic; using System.IO; using UnityEngine; using static RestoreObjectPathHelper; public class DeviceOfPartDataProxy : DataProxy { public string m_TableName; public List m_PartInfos; public List m_CustomInfos; public List objects = new List(); public override void OnRegister() { } public PartDataInfo GetPartInfoByPartName(string partName) { return m_PartInfos.Find(t => t.partName == partName); } /// /// 从Excel文件读取流程信息 /// /// 表名 /// 表头 /// public List ReadStepMsgInfoFromTable(string tableName) { m_TableName = tableName + GlobalConfig.excelSuffix; m_PartInfos = new List(); string tmpPath = System.IO.Path.Combine(GlobalConfig.partTablePath, m_TableName); if (File.Exists(tmpPath)) { m_PartInfos = ExcelHelper.ReadInfoFromExcel(tmpPath, 1); } return m_PartInfos; } public List ReadCustomInfoFromTable(string tableName) { m_TableName = tableName + GlobalConfig.excelSuffix; m_CustomInfos = new List(); string tmpPath = System.IO.Path.Combine(GlobalConfig.partEditTablePath, m_TableName); if (File.Exists(tmpPath)) { m_CustomInfos = ExcelHelper.ReadInfoFromExcel(tmpPath, 1); } return m_CustomInfos; } public CustomPartData GetCustomByEditPartName(string partName) { return m_CustomInfos.Find(t => t.editName == partName); } public CustomPartData GetCustomByPartName(string partName) { return m_CustomInfos.Find(t => t.partName == partName); } public CustomPartData GetCustomByIdName(string id) { return m_CustomInfos.Find(t => t.id == id); } public void CoverTableInfos() { for (int i = 0; i < m_CustomInfos.Count; i++) { PartDataInfo tmpInfo = GetPartInfoByPartName(m_CustomInfos[i].partName); if(tmpInfo != null) { if (!string.IsNullOrEmpty(m_CustomInfos[i].editName)) tmpInfo.partName = m_CustomInfos[i].editName; tmpInfo.audioClipName = m_CustomInfos[i].audioClipName; } } } public void endTableEditInfos(bool first = false) { List datas = new List(); for (int i = 0; i < m_CustomInfos.Count; i++) { int j = i; GameObject tmpObj = GameObject.Find(m_CustomInfos[j].AbsolutePath); objects.Add(tmpObj); datas.Add(new RestoreData(tmpObj.transform, m_CustomInfos[j].EditPath)); } PartMark[] allObjs = DeviceController.instance.GetComponentsInChildren(true); new RestoreObjectPathHelper().RestoreHierarchy(datas, allObjs); for (int i = 0; i < m_CustomInfos.Count; i++) { objects[i].name = m_CustomInfos[i].editName; } foreach(PartMark tmpPark in allObjs) { tmpPark.InitData(); } } public void returnBackTable() { for (int i = 0; i < objects.Count; i++) { PartDataInfo tmpInfo = GetPartInfoByPartName(m_CustomInfos[i].partName); if (tmpInfo != null ) { objects[i].name = tmpInfo.partName; } } m_CustomInfos.Clear(); } }