public override void DrawCurve(BaseNode b)
        {
            Rect rect = b.windowRect;

            rect.y     += b.windowRect.height * .5f;
            rect.width  = 1;
            rect.height = 1;

            BaseNode e = BehaviorEditor.settings.currentGraph.GetNodeWithIndex(b.enterNode);

            if (e == null)
            {
                BehaviorEditor.settings.currentGraph.DeleteNode(b.id);
            }
            else
            {
                Color targetColor = Color.green;
                if (!b.isAssigned || b.isDuplicate)
                {
                    targetColor = Color.red;
                }

                Rect r = e.windowRect;
                BehaviorEditor.DrawNodeCurve(r, rect, true, targetColor);
            }

            if (b.isDuplicate)
            {
                return;
            }

            if (b.targetNode > 0)
            {
                BaseNode t = BehaviorEditor.settings.currentGraph.GetNodeWithIndex(b.targetNode);
                if (t == null)
                {
                    b.targetNode = -1;
                }
                else
                {
                    rect    = b.windowRect;
                    rect.x += rect.width;
                    Rect endRect = t.windowRect;
                    endRect.x -= endRect.width * .5f;

                    Color targetColor = Color.green;

                    if (t.drawNode is StateNode)
                    {
                        if (!t.isAssigned || t.isDuplicate)
                        {
                            targetColor = Color.red;
                        }
                    }
                    else
                    {
                        if (!t.isAssigned)
                        {
                            targetColor = Color.red;
                        }
                        else
                        {
                            targetColor = Color.yellow;
                        }
                    }

                    BehaviorEditor.DrawNodeCurve(rect, endRect, false, targetColor);
                }
            }
        }
        public override void DrawWindow(BaseNode baseNode)
        {
            if (baseNode.stateReference.currentState == null)
            {
                EditorGUILayout.LabelField("Add state to modify:");
            }
            else
            {
                if (!baseNode.collapse)
                {
                }
                else
                {
                    baseNode.windowRect.height = 100;
                }

                baseNode.collapse = EditorGUILayout.Toggle(" ", baseNode.collapse);
            }

            baseNode.stateReference.currentState = (State)EditorGUILayout.ObjectField(baseNode.stateReference.currentState, typeof(State), false);

            if (baseNode.previousCollapse != baseNode.collapse)
            {
                baseNode.previousCollapse = baseNode.collapse;
            }

            if (baseNode.stateReference.previousState != baseNode.stateReference.currentState)
            {
                //b.serializedState = null;
                baseNode.isDuplicate = BehaviorEditor.settings.currentGraph.IsStateDuplicate(baseNode);
                baseNode.stateReference.previousState = baseNode.stateReference.currentState;

                if (!baseNode.isDuplicate)
                {
                    Vector3 pos = new Vector3(baseNode.windowRect.x, baseNode.windowRect.y, 0);
                    pos.x += baseNode.windowRect.width * 2;

                    SetupReordableLists(baseNode);

                    //Load transitions
                    for (int i = 0; i < baseNode.stateReference.currentState.transitions.Count; i++)
                    {
                        pos.y += i * 100;
                        BehaviorEditor.AddTransitionNodeFromTransition(baseNode.stateReference.currentState.transitions[i], baseNode, pos);
                    }
                    BehaviorEditor.forceSetDirty = true;
                }
            }

            if (baseNode.isDuplicate)
            {
                EditorGUILayout.LabelField("State is a duplicate!");
                baseNode.windowRect.height = 100;
                return;
            }

            if (baseNode.stateReference.currentState != null)
            {
                baseNode.isAssigned = true;

                if (!baseNode.collapse)
                {
                    if (baseNode.stateReference.serializedState == null)
                    {
                        SetupReordableLists(baseNode);

                        //	SerializedObject serializedState = new SerializedObject(b.stateRef.currentState);
                    }

                    float standard = 150;
                    baseNode.stateReference.serializedState.Update();
                    baseNode.showActions = EditorGUILayout.Toggle("Show Actions ", baseNode.showActions);
                    if (baseNode.showActions)
                    {
                        EditorGUILayout.LabelField("");
                        baseNode.stateReference.onFixedList.DoLayoutList();
                        EditorGUILayout.LabelField("");
                        baseNode.stateReference.onUpdateList.DoLayoutList();
                        standard += 100 + 40 + (baseNode.stateReference.onUpdateList.count + baseNode.stateReference.onFixedList.count) * 20;
                    }
                    baseNode.showEnterExit = EditorGUILayout.Toggle("Show Enter/Exit ", baseNode.showEnterExit);
                    if (baseNode.showEnterExit)
                    {
                        EditorGUILayout.LabelField("");
                        baseNode.stateReference.onEnterList.DoLayoutList();
                        EditorGUILayout.LabelField("");
                        baseNode.stateReference.onExitList.DoLayoutList();
                        standard += 100 + 40 + (baseNode.stateReference.onEnterList.count + baseNode.stateReference.onExitList.count) * 20;
                    }

                    baseNode.stateReference.serializedState.ApplyModifiedProperties();
                    baseNode.windowRect.height = standard;
                }
            }
            else
            {
                baseNode.isAssigned = false;
            }
        }
 private static void ShowEditor()
 {
     editor         = EditorWindow.GetWindow <BehaviorEditor> ();
     editor.minSize = new Vector2(800, 600);
 }