Example #1
0
        public float LayoutNodes(EditorAINode node, float alignment, float padding, float verticalPosition, float verticalPadding)
        {
            float halfPadding        = padding / 2;
            float halfVerticalPading = verticalPadding / 2;

            if (node is EditorAICombinationalNode || node is EditorAIDecoratorNode || node is EditorAIRootNode)
            {
                float startAlign = alignment;
                foreach (var child in node.GetChildren())
                {
                    if (child == null)
                    {
                        continue;
                    }
                    alignment = LayoutNodes(child, alignment, padding, verticalPosition + node.size.y + verticalPadding, verticalPadding);
                }
                node.position = new Vector2((startAlign + alignment) / 2, (verticalPosition + halfVerticalPading)) + Vector2.left * (node.size.x / 2);
                return(alignment);
            }
            else
            {
                node.position = Vector2.zero + Vector2.right * (alignment + halfPadding) + Vector2.up * (verticalPosition + halfVerticalPading);
                return(alignment + node.size.x + padding);
            }
        }
Example #2
0
 public void AdjustLayout(EditorAINode node, Vector2 offset)
 {
     node.position += offset;
     foreach (var child in node.GetChildren())
     {
         AdjustLayout(child, offset);
     }
 }