예제 #1
0
                private void RenderLinksForState(StateEditorGUI state)
                {
                    StateMachineEditorLink[] links = state.GetEditableObject().GetEditorLinks();

                    if (links != null)
                    {
                        float fraction = 1.0f / (links.Length + 1.0f);
                        float current  = fraction;

                        foreach (StateMachineEditorLink link in links)
                        {
                            StateRef stateRef = link.GetStateRef();

                            if (stateRef.IsInternal())
                            {
                                StateEditorGUI toState = FindStateForLink(stateRef);

                                if (toState != null)
                                {
                                    RenderLink(link.GetDescription(), state, toState, current);
                                }
                            }
                            else
                            {
                                RenderExternalLink(link, state, current);
                            }

                            current += fraction;
                        }
                    }
                }
                private void RenderLinksForState(StateEditorGUI state)
                {
                    StateMachineEditorLink[] links = state.GetEditableObject().GetEditorLinks();

                    if (links != null)
                    {
                        for (int j = 0; j < links.Length; j++)
                        {
                            StateRef stateRef = links[j].GetStateRef();

                            if (stateRef.IsInternal())
                            {
                                StateEditorGUI toState = FindStateForLink(stateRef);
                                RenderLink(links[j].GetDescription(), state, toState, j);
                            }
                            else
                            {
                                RenderExternalLink(links[j], state, j);
                            }
                        }
                    }
                }
예제 #3
0
                public static object PropertyField(object obj, GUIContent label, ref bool dataChanged, GUIStyle style, params GUILayoutOption[] options)
                {
                    StateRef state = (StateRef)obj;

                    if (label == null)
                    {
                        label = new GUIContent();
                    }

                    label.text += " (" + state + ")";

                    bool editorCollapsed = !EditorGUILayout.Foldout(!state._editorCollapsed, label);

                    if (editorCollapsed != state._editorCollapsed)
                    {
                        state._editorCollapsed = editorCollapsed;
                        dataChanged            = true;
                    }

                    if (!editorCollapsed)
                    {
                        int origIndent = EditorGUI.indentLevel;
                        EditorGUI.indentLevel++;


                        EditorGUI.BeginChangeCheck();
                        eType type = (eType)EditorGUILayout.EnumPopup("Link Type", state.IsInternal() ? eType.Internal : eType.External);
                        if (EditorGUI.EndChangeCheck())
                        {
                            //If type has changed create a new ref with file set to null if internal or a blank asset ref if external.
                            state       = new StateRef(type == eType.External ? -1 : 0, state.GetParentStateMachine());
                            dataChanged = true;
                        }

                        switch (type)
                        {
                        case eType.Internal:
                        {
                            StateMachine stateMachine = state.GetParentStateMachine();
                            if (stateMachine != null)
                            {
                                int stateId = state.GetStateID();

                                //If changed state id create new state ref
                                if (DrawStateNamePopUps(stateMachine._states, ref stateId))
                                {
                                    state       = new StateRef(stateId, stateMachine);
                                    dataChanged = true;
                                }
                            }
                        }
                        break;

                        case eType.External:
                        {
                            TextAsset asset = EditorGUILayout.ObjectField("File", state.GetExternalFile()._editorAsset, typeof(TextAsset), false) as TextAsset;

                            //If asset changed update GUIDS
                            if (state.GetExternalFile()._editorAsset != asset)
                            {
                                state       = new StateRef(asset, -1, state.GetParentStateMachine());
                                dataChanged = true;
                            }

                            if (asset != null)
                            {
                                StateMachine stateMachines = Serializer.FromFile <StateMachine>(AssetDatabase.GetAssetPath(asset));
                                int          stateId       = state.GetStateID();

                                if (DrawStateNamePopUps(stateMachines._states, ref stateId))
                                {
                                    state       = new StateRef(asset, stateId, state.GetParentStateMachine());
                                    dataChanged = true;
                                }
                            }
                        }
                        break;
                        }

                        EditorGUI.indentLevel = origIndent;
                    }

                    return(state);
                }