protected void Awake() { m_myTreeNode = GetComponent <TreeNodeUI>(); m_originalExpand = m_expandToggle.navigation; m_originalName = m_nameField.navigation; m_originalVisible = m_VisibleToggle.navigation; }
public void RemoveChild(TreeNodeUI data) { m_subElements.Remove(data); ToggleExpandable(); if (OnChildRemoved != null) { OnChildRemoved(data); } }
private void RemoveChild(TreeNodeUI child) { TreeNodeToggle[] childtoggles = child.GetComponentsInChildren <TreeNodeToggle>(true); for (int i = 0; i < childtoggles.Length; i++) { if (!m_children.Contains(childtoggles[i])) { m_children.Remove(childtoggles[i]); } } }
public void AddChild(TreeNodeUI data) { m_subElements.Add(data); data.transform.SetParent(m_childElementsPanel, false); data.Depth = Depth + 1; ToggleExpandable(); if (OnChildAdded != null) { OnChildAdded(data); } }
private void Awake() { m_myNode = GetComponentInParent <TreeNodeUI>(); if (m_myNode != null) { m_myNode.OnChildAdded += AddChild; m_myNode.OnChildRemoved += RemoveChild; } Toggle.onValueChanged.AddListener(UpdateChildren); }
public void AddElement(TreeNodeUI data, TreeNodeUI parent) { if (parent == null) { data.transform.SetParent(m_contentPanel, false); } else { parent.AddChild(data); } }
private void AddChild(TreeNodeUI child) { int counter = 0; TreeNodeToggle[] childtoggles = child.GetComponentsInChildren <TreeNodeToggle>(true); for (int i = 0; i < childtoggles.Length; i++) { if (!m_children.Contains(childtoggles[i]) && childtoggles[i].ListName == ListName) { m_children.Add(childtoggles[i]); counter++; } } //Debug.Log(string.Format("{0} is adding {1} children from {2} found toggleables.", name, counter, childtoggles.Length)); }
private void InstantiateTree(ITreeNode root, TreeNodeUI parent) { if (root == null) { return; } TreeNodeUI instance = m_pool.NextObject.GetComponent <TreeNodeUI>(); instance.gameObject.SetActive(true); instance.Set(root); AddElement(instance, parent); foreach (ITreeNode child in root.Children) { InstantiateTree(child, instance); } }
private void Update() { m_name = "Blah - " + counter; if (counter % 2 == 0) { m_name = "Bleh - " + counter; } if (Input.GetKeyDown(KeyCode.Alpha1)) { var selected = EventSystem.current.currentSelectedGameObject; if (selected != null) { TreeNodeUI current = selected.GetComponentInParent <TreeNodeUI>(); if (current != null) { TreeNodeUI element = Instantiate(prefab); //element.SetName(m_name); testTarget.AddElement(element, current); counter++; } } } else if (Input.GetKeyDown(KeyCode.Alpha2)) { var selected = EventSystem.current.currentSelectedGameObject; if (selected != null) { TreeNodeUI current = selected.GetComponentInParent <TreeNodeUI>(); if (current != null) { //testTarget.RemoveElement(current); } } } }