using System.Collections.Generic; using UniRx; using UnityEngine; namespace QFramework { /// /// 树形节点表 /// public class TreeNodeList { //节点表 public ReactiveCollection TreeNodeItems = new ReactiveCollection(); //所有节点字典 public List treeNodeItems = new List(); /// /// 添加节点 /// /// 内容 /// 父节点名称 /// 层级 public void AddTreeNode(TreeNodeItem treeNodeData) { if (string.IsNullOrEmpty(treeNodeData.ParentName.Value)) { treeNodeData.ShowHidden.Value = true; treeNodeItems.Add(treeNodeData); TreeNodeItems.Add(treeNodeData); } else { TreeNodeItem tmpItem = treeNodeItems.Find(t => t.Content.Value == treeNodeData.ParentName.Value); if (tmpItem != null) { tmpItem.ChildTreeNodeList.TreeNodeItems.Add(treeNodeData); treeNodeItems.Add(treeNodeData); } } } } public class TreeNodeItem { /// /// 内容 /// public StringReactiveProperty Content = new StringReactiveProperty(string.Empty); /// /// 父节点名称 /// public StringReactiveProperty ParentName = new StringReactiveProperty(string.Empty); /// /// 子节点列表 /// public TreeNodeList ChildTreeNodeList = new TreeNodeList(); /// /// 层级 /// public IntReactiveProperty Layer = new IntReactiveProperty(0); /// /// 是否展开 /// public BoolReactiveProperty ExPanded = new BoolReactiveProperty(false); /// /// 显示或隐藏 /// public BoolReactiveProperty ShowHidden = new BoolReactiveProperty(true); /// /// 位置 /// public Vector3 position { get; set; } /// /// 转角 /// public Vector3 rotation { get; set; } public int id { get; set; } public string index { get; set; } /// /// 设备唯一编码 /// public int equipmentUniqueID { get; set; } public string gropName { get; set; } } }