public void execute() { if (!executed) { executed = true; m_new_ui = (m_node == null ? m_layout_mng.CurEditLayout.Root.AddChildNode() : (m_node.DataKey as UIElement).AddChildNode()); m_new_node = TreeNodeFactory.CreateNewUITreeNode(m_new_ui.Name); m_new_node.DataKey = m_new_ui; } else { (m_new_node.DataKey as UIElement).Removed = false; } if (m_node == null) { m_tree.AddRootNode(m_new_node); } else { m_node.AddChild(m_new_node); } LayoutEditorWindow.RequestRepaint(); }
private void buildUITreeRev(UIElement element, TreeNode node) { for (int i = 0; i < element.ChildrenCount; i++) { UIElement child = element.GetChild(i); TreeNode subnode = TreeNodeFactory.CreateNewUITreeNode(child.Name, child.Hide, child.Freeze, child.Lock); subnode.DataKey = child; subnode.CanRenameByUI = !LayoutTool.HasUI(child.gameObject, false); subnode.Hide = element.Lock; if (LayoutTool.HasUI(child.gameObject, false)) { subnode.SetColor(new Color(0.8f, 0.35f, 0.0f)); } node.AddChild(subnode); buildUITreeRev(child, subnode); } }
private void buildUITree(UIElement element) { uiTree = new EditorTreeView(); //uiTree.OnDrag += onDragNode; //uiTree.OnDrop += onDropNode; uiTree.OnNodeToggleChange += onUINodeToggleChange; uiTree.OnNodeNameChange += onUINodeNameChange; uiTree.OnNodeSelChange += onUINodeSelChange; uiTree.AddMenuItem("添加节点", AddNode); uiTree.AddMenuItem("删除节点", RemoveNode); TreeNode node = TreeNodeFactory.CreateNewUITreeNode(element.Name, element.Hide, element.Freeze, element.Lock); node.DataKey = element; node.CanRenameByUI = !LayoutTool.HasUI(element.gameObject, false); uiTree.AddRootNode(node); buildUITreeRev(element, node); }