public BehaviorNodeDrawer(BehaviorTreeWindow behaviorTreeWindow, BehaviorNodeDrawer parentNode, INode nodeToDraw, float xPos, float yPos) { this._originalPos = new Vector2(xPos, yPos); this._behaviorTreeWindow = behaviorTreeWindow; this._parentNode = parentNode; var regionDecoratorNode = nodeToDraw as EditorRegionDecoratorNode; if (regionDecoratorNode != null) { _groupDrawer = new BehaviorGroupDrawer(behaviorTreeWindow, this, regionDecoratorNode, this); nodeToDraw = regionDecoratorNode.getChildNode(); } _windowRect = new Rect(xPos, yPos, MIN_WIDTH, MIN_HEIGHT + nodeToDraw.GetGUIPropertyHeight()); _nodeToDraw = nodeToDraw; var leafNode = nodeToDraw as ILeafNode; if (leafNode != null) { type = VisualNodeType.LeafNode; _childrenNodes = new BehaviorNodeDrawer[0]; } var decoratorNode = nodeToDraw as IDecoratorNode; if (decoratorNode != null) { type = VisualNodeType.DecoratorNode; _childrenNodes = new BehaviorNodeDrawer[1] { new BehaviorNodeDrawer(behaviorTreeWindow, this, decoratorNode.getChildNode(), _windowRect.x + INITIAL_HORIZONTAL_SPACING + MIN_WIDTH, _windowRect.y) }; } var compositeNode = nodeToDraw as ICompositeNode; if (compositeNode != null) { type = VisualNodeType.CompositeNode; var compositeChilds = compositeNode.getChildNodes(); _childrenNodes = new BehaviorNodeDrawer[compositeChilds.Length]; for (int i = 0; i < compositeChilds.Length; i++) { _childrenNodes[i] = new BehaviorNodeDrawer(behaviorTreeWindow, this, compositeChilds[i], _windowRect.x + INITIAL_HORIZONTAL_SPACING + MIN_WIDTH, _windowRect.y); } } if (_groupDrawer != null) _groupDrawer.Init(); var aggregatedHeight = 0f; for (int i = 0; i < _childrenNodes.Length; i++) { _childrenNodes[i].MoveVertical(aggregatedHeight); aggregatedHeight += _childrenNodes[i].GetCombinedHeight(); } _windowTitle = _nodeToDraw.GetType().Name.Replace("Node", "").Replace("Decorator", "").Replace("Composite", ""); }