using System.Collections; using System.Collections.Generic; using UnityEngine; using System.IO; using System.Linq; public class UITreeMenuProxy : DataProxy { List treeNodeInfos; public override void OnRegister() { InitData(); } public void InitData() { //表格读取 string path = Application.streamingAssetsPath + "/TableData/主页树形.csv"; treeNodeInfos = ReadOperationFromTable(path); } public List GetUITreeData() { return treeNodeInfos; } public override void OnRemove() { } /// /// 从表格读取流程信息 /// /// /// private List ReadOperationFromTable(string path) { List tmpInfos = new List(); using (StreamReader streamReader = new StreamReader(path, System.Text.Encoding.UTF8)) { string tmpOperationInfo = streamReader.ReadToEnd().TrimEnd(); if (tmpOperationInfo.Contains("\r")) tmpOperationInfo = tmpOperationInfo.Replace("\r", ""); string[] tempOperationInfos = tmpOperationInfo.Split('\n'); for (int i = 2; i < tempOperationInfos.Length; i++) { string operationInfo = tempOperationInfos[i]; string[] operationInfoElements = operationInfo.Split(','); TreeNodeInfo tmpInfo = new TreeNodeInfo(); for (int j = 0; j < operationInfoElements.Length; j++) { if (j == 0) tmpInfo.m_Id = int.Parse(operationInfoElements[0]); if (j == 1) tmpInfo.m_NodeName = operationInfoElements[1]; if (j == 2) tmpInfo.m_NodeParentName = operationInfoElements[2]; if (j == 3) tmpInfo.m_NodeLayer = int.Parse(operationInfoElements[3]); if (j == 4) tmpInfo.m_EquipmentUniqueID = int.Parse(operationInfoElements[4]); if (j == 5) tmpInfo.m_GroupName = operationInfoElements[5]; } tmpInfos.Add(tmpInfo); } } return tmpInfos; } }