public void ResetChildIndices()
    {
        while (this.invalidChildIndices == true)
        {
            this.invalidChildIndices = false;
            for (int i = 0; i < this.childConnectors.Count - 1; ++i)
            {
                btInterfaceConnection connection1 = this.childConnectors[i];
                btInterfaceConnection connection2 = this.childConnectors[i + 1];

                float angle1 = connection1.GetAngleFromParentToChild();
                float angle2 = connection2.GetAngleFromParentToChild();

                if (angle1 > angle2)
                {
                    SwapChildrenIndices(i, i + 1);
                    this.invalidChildIndices = true;
                }
            }
        }

        for (int i = 0; i < this.childConnectors.Count; ++i)
        {
            this.childConnectors[i].child.indexDisplay.SetIndex(i);
        }
    }
    public void SwapChildrenIndices(int _index1, int _index2)
    {
        btInterfaceConnection connection1 = this.childConnectors[_index1];
        btInterfaceConnection connection2 = this.childConnectors[_index2];

        this.childConnectors[_index1] = connection2;
        this.childConnectors[_index2] = connection1;
    }
Exemple #3
0
    public void RemoveParent()
    {
        if (this.parentConnector == null)
        {
            return;
        }

        this.parentConnector.parent.invalidChildIndices = true;
        this.parentConnector.parent.childConnectors.Remove(this.parentConnector);
        GameObject.Destroy(this.parentConnector.gameObject);
        this.parentConnector = null;

        this.indexDisplay.SetIndex(-1);
    }
    public void AddChildNode(btInterfaceNode _node)
    {
        GameObject connectionObj = GameObject.Instantiate(connectionPrefab) as GameObject;

        btInterfaceConnection connectionScript = connectionObj.GetComponent <btInterfaceConnection>();

        connectionScript.parent = this.attachedNode;
        connectionScript.child  = _node;
        this.attachedNode.childConnectors.Add(connectionScript);
        _node.parentConnector = connectionScript;

        connectionObj.transform.parent = this.transform;
        // connectionObj.transform.parent = btInterfaceTreeManager.instance.transform;
        connectionObj.transform.localScale    = Vector3.one;
        connectionObj.transform.localPosition = Vector3.zero;

        this.dragWidget.currentChild = null;

        this.attachedNode.invalidChildIndices = true;
        _node.indexDisplay.SetIndex(this.attachedNode.childConnectors.Count);
    }