Exemple #1
0
    public override Vector2 GetRenderSize()
    {
        Vector2 TotalRenderSize = new Vector2();

        foreach (BTNode ChildNode in ChildNodes)
        {
            Vector2 ChildRenderSize = ChildNode.GetRenderSize();
            TotalRenderSize.x += ChildRenderSize.x + ChildNodeOffset.x;
            TotalRenderSize.y  = Mathf.Max(TotalRenderSize.y, ChildRenderSize.y + NodeSize.y + ChildNodeOffset.y);
        }
        TotalRenderSize.x -= ChildNodeOffset.x;

        return(new Vector2(Mathf.Max(NodeSize.x, TotalRenderSize.x), Mathf.Max(NodeSize.y, TotalRenderSize.y)));
    }
Exemple #2
0
    public override void RenderNode(Vector2 aFrom)
    {
        if (BoxStyle == null)
        {
            BoxStyle          = new GUIStyle();
            BoxStyle.padding  = new RectOffset(8, 8, 8, 8);
            BoxStyle.overflow = new RectOffset(-2, -2, -2, -2);
        }
        BoxStyle.normal.background = BoxTexture;
        GUI.Box(new Rect(aFrom - ChildNodeOffset / 2, GetRenderSize() + ChildNodeOffset), GUIContent.none, BoxStyle);

        base.RenderNode(new Vector2(GetRenderSize().x / 2 - NodeSize.x / 2, 0) + aFrom);
        //UnityEditor.EditorGUI.DrawRect(new Rect(aFrom, NodeSize), Color.gray);

        float CoordXAdd = 0;

        foreach (BTNode ChildNode in ChildNodes)
        {
            ChildNode.RenderNode(aFrom + new Vector2(CoordXAdd, NodeSize.y + ChildNodeOffset.y));

            CoordXAdd += ChildNode.GetRenderSize().x + ChildNodeOffset.x;
        }
    }