public void LoadExternalState(StateMachineExternalStateEditorGUI state)
 {
     if (ShowOnLoadSaveChangesDialog())
     {
         StateRef stateRef = state.ExternalStateRef.GetStateRef();
         string   fileName = AssetDatabase.GetAssetPath(stateRef.GetExternalFile()._editorAsset);
         LoadFile(fileName);
     }
 }
                private void SetupExternalState()
                {
                    foreach (StateEditorGUI state in _editableObjects)
                    {
                        StateMachineExternalStateEditorGUI extState = state as StateMachineExternalStateEditorGUI;

                        if (extState != null)
                        {
                            extState.ExternalHasRendered = false;
                        }
                    }
                }
                private void RenderExternalLink(StateMachineEditorLink link, StateEditorGUI fromState, int linkIndex)
                {
                    StateMachineExternalStateEditorGUI externalState = null;

                    StateRef stateRef = link.GetStateRef();

                    //Find external link for this state
                    foreach (StateEditorGUI state in _editableObjects)
                    {
                        StateMachineExternalStateEditorGUI extState = state as StateMachineExternalStateEditorGUI;

                        if (extState != null)
                        {
                            StateRef extStateRef = extState.ExternalStateRef.GetStateRef();

                            if (extStateRef.GetStateID() == stateRef.GetStateID() && extStateRef.GetExternalFile().GetFileGUID() == stateRef.GetExternalFile().GetFileGUID())
                            {
                                externalState = extState;
                                break;
                            }
                        }
                    }

                    //If none exists, create a new one
                    if (externalState == null)
                    {
                        externalState = (StateMachineExternalStateEditorGUI)AddNewObject(new StateMachineExternalState());
                        externalState.ExternalStateRef = link;
                        _editableObjects.Add(externalState);
                    }

                    if (!externalState.ExternalHasRendered)
                    {
                        externalState.CalcBounds(_style);
                        bool  selected     = _selectedObjects.Contains(externalState);
                        Color borderColor  = selected ? _style._stateBackgroundSelected : _style._stateBackground;
                        Rect  renderedRect = GetScreenRect(externalState.GetBounds());
                        externalState.Render(renderedRect, borderColor, _style._externalStateColor, _style, selected ? 2.0f : 1.0f);
                        externalState.ExternalHasRendered = true;
                    }

                    RenderLink(link.GetDescription(), fromState, externalState, linkIndex);
                }
                private void CleanupExternalState()
                {
                    List <StateEditorGUI> states = new List <StateEditorGUI>();

                    foreach (StateEditorGUI editorGUI in _editableObjects)
                    {
                        states.Add(editorGUI);
                    }

                    foreach (StateEditorGUI editorGUI in states)
                    {
                        StateMachineExternalStateEditorGUI extState = editorGUI as StateMachineExternalStateEditorGUI;

                        if (extState != null && !extState.ExternalHasRendered)
                        {
                            RemoveObject(editorGUI);
                        }
                    }
                }