Exemple #1
0
 protected void Awake()
 {
     m_myTreeNode      = GetComponent <TreeNodeUI>();
     m_originalExpand  = m_expandToggle.navigation;
     m_originalName    = m_nameField.navigation;
     m_originalVisible = m_VisibleToggle.navigation;
 }
Exemple #2
0
 public void RemoveChild(TreeNodeUI data)
 {
     m_subElements.Remove(data);
     ToggleExpandable();
     if (OnChildRemoved != null)
     {
         OnChildRemoved(data);
     }
 }
Exemple #3
0
 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]);
         }
     }
 }
Exemple #4
0
 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);
     }
 }
Exemple #5
0
    private void Awake()
    {
        m_myNode = GetComponentInParent <TreeNodeUI>();
        if (m_myNode != null)
        {
            m_myNode.OnChildAdded   += AddChild;
            m_myNode.OnChildRemoved += RemoveChild;
        }

        Toggle.onValueChanged.AddListener(UpdateChildren);
    }
Exemple #6
0
 public void AddElement(TreeNodeUI data, TreeNodeUI parent)
 {
     if (parent == null)
     {
         data.transform.SetParent(m_contentPanel, false);
     }
     else
     {
         parent.AddChild(data);
     }
 }
Exemple #7
0
    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));
    }
Exemple #8
0
    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);
                }
            }
        }
    }