1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System.IO;
- using System.Linq;
- public class UITreeMenuProxy : DataProxy
- {
- List<TreeNodeInfo> treeNodeInfos;
- public override void OnRegister()
- {
- InitData();
- }
- public void InitData()
- {
- //表格读取
- string path = Application.streamingAssetsPath + "/TableData/主页树形.csv";
- treeNodeInfos = ReadOperationFromTable(path);
- }
- public List<TreeNodeInfo> GetUITreeData()
- {
- return treeNodeInfos;
- }
- public override void OnRemove()
- {
-
- }
- /// <summary>
- /// 从表格读取流程信息
- /// </summary>
- /// <param name="path"></param>
- /// <returns></returns>
- private List<TreeNodeInfo> ReadOperationFromTable(string path)
- {
- List<TreeNodeInfo> tmpInfos = new List<TreeNodeInfo>();
- 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;
- }
- }
|