protected override void CreateTreeNode(TreeViewNodeInfor item, string parentPath, char splitchar = '/') { TreeViewNodeInfor_ActionNode nodeInfor = item as TreeViewNodeInfor_ActionNode; TreeNodeBase parentNode = null; if (string.IsNullOrEmpty(parentPath)) { parentNode = m_Root; } else { parentNode = GetGroupNodeByName(parentPath); //获取当前节点所属于的父级分类节点 } string[] segment = nodeInfor.m_Arrangement.Split(splitchar); //分割字符串判断层级目录 if (segment.Length == 1) { //Debug.Log("CreateNode2 .... " + segment[0]); TreeViewNodeInfor_ActionNode newNodeInfor = new TreeViewNodeInfor_ActionNode(segment[0], nodeInfor.m_ActionScriptType, nodeInfor.m_Attribute); CreateLeafNode(parentPath, newNodeInfor, parentNode, splitchar); } //当前字符串层级关系确定完 else { parentPath = CreateGroupNode(parentPath, segment[0], parentNode, splitchar); //更新新的父节点路径 string path = nodeInfor.m_Arrangement.Remove(0, (segment[0] + splitchar).Length); //去掉一个层级目录后的路径 TreeViewNodeInfor_ActionNode newNodeInfor = new TreeViewNodeInfor_ActionNode(path, nodeInfor.m_ActionScriptType, nodeInfor.m_Attribute); CreateTreeNode(newNodeInfor, parentPath, splitchar); } }
protected override void CreateLeafNode(string parentPath, TreeViewNodeInfor item, TreeNodeBase parentNode, char splitchar) { TreeViewNodeInfor_ActionNode nodeInfor = item as TreeViewNodeInfor_ActionNode; parentPath = parentPath + nodeInfor.m_Arrangement + splitchar; //当前需要创建的树节点的完整路径 TreeNodeBase node = GetGroupNodeByName(parentPath); //判断是否存在这个路径的节点 if (node == null) { node = new ActionTreeNode(nodeInfor.m_Arrangement, parentNode, nodeInfor.m_Attribute, nodeInfor.m_ActionScriptType); //创建当前节点 RecordGroupNodeInfor(parentPath, node); //记录当前创建的节点 }//当前子目录不存在 }
public static List <object> GetAllActionNode2() { List <object> m_AllActionAttribute = new List <object>(); //*******遍历获取程序集并获得所有标有指定特性的类 //**这里获得所有标记由BehaviorActionAttribute 的Action 类 IEnumerable <Type> availableTypes = AppDomain.CurrentDomain.GetAssemblies().ToList().SelectMany(type => type.GetTypes()); foreach (Type type in availableTypes) { foreach (BehaviorActionAttribute attribute in Attribute.GetCustomAttributes(type).OfType <BehaviorActionAttribute>()) { // Debug.Log(attribute.ActionArrangement); Debug.Log("GetAllActionNode : " + type.Name); TreeViewNodeInfor_ActionNode nodeInfor = new TreeViewNodeInfor_ActionNode(attribute.ActionArrangement, type, attribute); m_AllActionAttribute.Add(nodeInfor); } } return(m_AllActionAttribute); }