Esempio n. 1
0
    public static bool EditFsmXpathQueryVariablesProperties(Fsm fsm, FsmXpathQuery target)
    {
        if (target == null)
        {
            target = new FsmXpathQuery();
        }

        bool edited = false;

        int count = 0;

        if (target.xPathVariables != null)
        {
            count = target.xPathVariables.Length;

            for (int i = 0; i < count; i++)
            {
                GUILayout.BeginHorizontal();

                bool fsmVariableChangedFlag;
                target.xPathVariables[i] = PlayMakerInspectorUtils.EditorGUILayout_FsmVarPopup("Variable _" + i + "_", fsm.Variables.GetAllNamedVariables(), target.xPathVariables[i], out fsmVariableChangedFlag);

                // PlayMaker api is now not working on 1.8 and shoudl become private
                //target.xPathVariables[i] = VariableEditor.FsmVarPopup(new GUIContent("Variable _"+i+"_"),fsm,target.xPathVariables[i]);

                edited = edited || fsmVariableChangedFlag;

                if (i + 1 == count)
                {
                    if (FsmEditorGUILayout.DeleteButton())
                    {
                        ArrayUtility.RemoveAt(ref target.xPathVariables, i);
                        return(true);                        // we must not continue, an entry is going to be deleted so the loop is broken here. next OnGui, all will be well.
                    }
                }
                else
                {
                    GUILayout.Space(21);
                }
                GUILayout.EndHorizontal();
            }
        }

        string _addButtonLabel = "Add a variable";

        if (count > 0)
        {
            _addButtonLabel = "Add another variable";
        }

        GUILayout.BeginHorizontal();
        GUILayout.Space(154);

        if (GUILayout.Button(_addButtonLabel))
        {
            if (target.xPathVariables == null)
            {
                target.xPathVariables = new FsmVar[0];
            }


            ArrayUtility.Add <FsmVar>(ref target.xPathVariables, new FsmVar());
            edited = true;
        }
        GUILayout.Space(21);
        GUILayout.EndHorizontal();

        return(edited || GUI.changed);
    }
Esempio n. 2
0
    public static bool EditFsmPropertiesStorage(Fsm fsm, FsmXmlPropertiesStorage target)
    {
        FsmEditorGUILayout.LightDivider();


        bool edited = false;

        int count = 0;

        if (target != null && target.properties != null && target.propertiesVariables != null)
        {
            count = target.properties.Length;


            for (int i = 0; i < count; i++)
            {
                GUILayout.BeginHorizontal();

                GUILayout.Label("Property item " + i);
                GUILayout.FlexibleSpace();


                if (FsmEditorGUILayout.DeleteButton())
                {
                    ArrayUtility.RemoveAt(ref target.properties, i);
                    ArrayUtility.RemoveAt(ref target.propertiesVariables, i);
                    return(true);                            // we must not continue, an entry is going to be deleted so the loop is broken here. next OnGui, all will be well.
                }

                GUILayout.EndHorizontal();

                                #if PLAYMAKER_1_8_OR_NEWER
//				PlayMakerInspectorUtils.SetActionEditorArrayVariableSelectionContext(target,i,target.GetType().GetField("properties").GetType());
                                #endif

                target.properties[i] = VariableEditor.FsmStringField(new GUIContent("Property"), fsm, target.properties[i], null);

                //	target.propertiesVariables[i] = VariableEditor.FsmVarPopup(new GUIContent("Value"),fsm,target.propertiesVariables[i]);
                bool fsmVariableChangedFlag = false;
                target.propertiesVariables[i] = PlayMakerInspectorUtils.EditorGUILayout_FsmVarPopup("Value", fsm.Variables.GetAllNamedVariables(), target.propertiesVariables[i], out fsmVariableChangedFlag);
            }
        }

        string _addButtonLabel = "Get a Property";

        if (count > 0)
        {
            _addButtonLabel = "Get another Property";
        }

        GUILayout.BeginHorizontal();
        GUILayout.Space(154);

        if (GUILayout.Button(_addButtonLabel))
        {
            if (target.properties == null)
            {
                target.properties          = new FsmString[0];
                target.propertiesVariables = new FsmVar[0];
            }


            ArrayUtility.Add <FsmString>(ref target.properties, new FsmString());
            ArrayUtility.Add <FsmVar>(ref target.propertiesVariables, new FsmVar());
            edited = true;
        }
        GUILayout.Space(21);
        GUILayout.EndHorizontal();

        return(edited || GUI.changed);
    }