public void SetOutput(BehaviorNodeControl target, int index)
        {
            // Not self
            if (target == this)
            {
                return;
            }

            // Make sure connection does not already exist
            foreach (BehaviorNodeControl o in m_outputs)
            {
                if (o == target)
                {
                    return;
                }
            }

            // Make sure there are no circular references
            foreach (BehaviorNodeControl o in target.m_outputs)
            {
                if (CheckCircularReference(this, o))
                {
                    return;
                }
            }

            if (index < m_outputs.Count)
            {
                // Replace
                m_outputs[index] = target;
            }
            else
            {
                // New connection

                m_outputs.Add(target);
                BezierCurve line = (BezierCurve)m_canvas.AddShape(new BezierCurve(GetOutputConnectorPosition(index), target.GetInputConnectorPosition(), Color.red, 1.0f, BezierCurve.TangentMode.AutoY, Vector2.zero, Vector2.zero));
                m_outputLines.Add(line);

                UpdateOutputs();
            }
        }
        public BehaviorTreeControl( ) : base()
        {
            m_nodes = new List <BehaviorNodeControl>();

            m_nodeCache = new EditorNodeTypeCache();
            m_nodeCache.CacheAvailableNodes();

            AddDecorator(new Scrollbars());
            m_canvas = ( GraphicsCanvas )AddDecorator(new GraphicsCanvas());

            m_linkLine          = ( BezierCurve )m_canvas.AddShape(new BezierCurve(Vector2.zero, Vector2.zero, Color.red, 1.0f, BezierCurve.TangentMode.AutoY, Vector2.zero, Vector2.zero));
            m_linkLine.Tangents = BezierCurve.TangentMode.AutoY;

            ContextMenuControl ctx = new ContextMenuControl();

            foreach (EditorCachedNode node in m_nodeCache.Cache)
            {
                ctx.Menu.AddItem(new GUIContent(node.displayName), false, AddNode, node);
            }
            ctx.Positionless = true;
            AddChild(ctx);
        }