private bool DrawStateNamePopUps()
            {
                TimelineState[] states = null;

                switch (_editorLinkType)
                {
                case eType.External:
                {
                    TimelineStateMachine stateMachines = SerializeConverter.FromFile <TimelineStateMachine>(AssetDatabase.GetAssetPath(_file._editorAsset));
                    states = stateMachines._states;
                }
                break;

                case eType.Internal:
                {
                    if (_stateMachine != null)
                    {
                        states = _stateMachine._states;
                    }
                }
                break;
                }

                if (states != null && states.Length > 0)
                {
                    string[] stateNames = new string[states.Length + 1];
                    int      index      = 0;
                    stateNames[0] = "<none>";

                    for (int i = 0; i < states.Length; i++)
                    {
                        stateNames[i + 1] = "State" + states[i]._stateId + " (" + StringUtils.GetFirstLine(states[i].GetDescription()) + ")";

                        if (states[i]._stateId == _stateId)
                        {
                            index = i + 1;
                        }
                    }

                    EditorGUI.BeginChangeCheck();

                    index = EditorGUILayout.Popup("Timeline", index, stateNames);

                    if (EditorGUI.EndChangeCheck())
                    {
                        _stateId         = index == 0 ? -1 : (int)states[index - 1]._stateId;
                        _timelineState   = null;
                        _editorStateName = null;
                        return(true);
                    }
                }

                return(false);
            }
                private void LoadFile(string fileName)
                {
                    _currentFileName = fileName;

                    TimelineStateMachine stateMachine = SerializeConverter.FromFile <TimelineStateMachine>(fileName);

                    if (stateMachine != null)
                    {
                        if (_editorPrefs._fileName != fileName)
                        {
                            _editorPrefs._fileName = fileName;
                            _editorPrefs._stateId  = -1;
                            SaveEditorPrefs();
                        }

                        SetStateMachine(stateMachine);
                        _stateEditor.SetTimeline(null);

                        if (_editorPrefs._stateId != -1)
                        {
                            SwitchToStateView(_editorPrefs._stateId);
                        }
                        else
                        {
                            SwitchToStatemachineView();
                        }
                    }
                    else
                    {
                        _editorPrefs._fileName = null;
                        _editorPrefs._stateId  = -1;
                        SaveEditorPrefs();
                    }

                    GetEditorWindow().DoRepaint();
                }
Beispiel #3
0
                private void LoadFile(string fileName)
                {
                    _currentFileName = fileName;

                    NodeGraph nodeMachine = SerializeConverter.FromFile <NodeGraph>(fileName);

                    if (nodeMachine != null)
                    {
                        if (_editorPrefs._fileName != fileName)
                        {
                            _editorPrefs._fileName = fileName;
                            SaveEditorPrefs();
                        }

                        SetNodeGraph(nodeMachine);
                    }
                    else
                    {
                        _editorPrefs._fileName = null;
                        SaveEditorPrefs();
                    }

                    GetEditorWindow().DoRepaint();
                }