Ejemplo n.º 1
0
    private void SetNodePosition(QNode node)
    {
        float halfWidth = flowPanelRect.rect.width / 2;

        node.GetComponent <RectTransform>().localScale = new Vector3(0.1f, 0.1f, 0.1f);

        if (node.GetParent() == null)
        {
            if (instructions.Count > 0)
            {
                node.GetComponent <RectTransform>().localPosition = new Vector2(halfWidth, instructions[instructions.Count - 1].GetComponent <RectTransform>().localPosition.y - _spacing);
            }
            else   // first entry
            {
                node.GetComponent <RectTransform>().localPosition = new Vector2(halfWidth, 0);
            }
        }
        else
        {
            float parentNodeYPosition = ((QNode)node.GetParent()).GetComponent <RectTransform>().localPosition.y;
            if (node.GetParent().GetChild() == node)
            {
                node.GetComponent <RectTransform>().localPosition = new Vector2(halfWidth - _spacing, parentNodeYPosition - _spacing);
            }
            else
            {
                node.GetComponent <RectTransform>().localPosition = new Vector2(halfWidth + _spacing, parentNodeYPosition - _spacing);
            }
        }
    }