public void Render()
    {
        ProcessDrag();


        if (DraggedState != null)
        {
            FSMEditorState hoverState = MyFSMStatesControl.FindStateUnderMouse();
            if (hoverState != null)
            {
                FSMLineRender.DrawTransition(DraggedState.GetEventRect(DraggedTransitionIndex, null), hoverState.GetHeaderRect(DraggedState));
            }
            else
            {
                Vector2 position = FSMEditorEvent.Instance.MousePosition;
                position.y += MyFSMStatesControl.ScrollPos.y - MyFSMStatesControl.Position.y;
                position.x += MyFSMStatesControl.ScrollPos.x;
                FSMLineRender.DrawTransition(DraggedState.GetEventRect(DraggedTransitionIndex, null), new Rect(position.x, position.y, 1, 1));
            }

            if (FSMEditorEvent.Instance.EditorEventType == FSMEditorEventType.MouseUp)
            {
                if (hoverState != null && hoverState != DraggedState)
                {
                    DraggedState.State.Transitions[DraggedTransitionIndex].ToState = hoverState.State.StateName;
                }
                DraggedState = null;
            }
        }
    }
    public void Render()
    {
        Vector2 viewport = CalculateViewport();

        GUI.Box(new Rect(0, Position.y, MyFSMEditor.position.width, this.MyFSMEditor.position.height - Position.y), "");
        ScrollPos = GUI.BeginScrollView(new Rect(0, Position.y, MyFSMEditor.position.width, this.MyFSMEditor.position.height - Position.y),
                                        ScrollPos, new Rect(0, 0, viewport.x + Position.y + 100, viewport.y + Position.y + 100));

        MyFSMEditor.BeginWindows();
        foreach (FSMEditorState editorState in MyFSMEditor.EditorStates)
        {
            editorState.Render();
        }

        MyFSMEditor.EndWindows();



        foreach (var fromEditorState in MyFSMEditor.EditorStates)
        {
            int i = 0;
            foreach (var transition in fromEditorState.State.Transitions)
            {
                if (transition.ToState != "")
                {
                    if (MyFSMEditor.EditorStatesIndex.ContainsKey(transition.ToState))
                    {
                        var toEditorState = MyFSMEditor.EditorStatesIndex[transition.ToState];
                        FSMLineRender.DrawTransition(fromEditorState.GetEventRect(i, toEditorState), toEditorState.GetHeaderRect(fromEditorState));
                    }
                }
                i++;
            }
        }

        FSMDragStateControl.Render();
        GUI.EndScrollView();
    }