Esempio n. 1
0
    public static bool EditFsmXpathQueryField(Fsm fsm, FsmXpathQuery target)
    {
        bool edited = false;

        target._foldout = FsmEditorGUILayout.BoldFoldout(target._foldout, new GUIContent("xPath Query"));

        if (target.xPathQuery == null)
        {
            target.xPathQuery = new FsmString();
        }

        if (target._foldout)
        {
                        #if PLAYMAKER_1_8_OR_NEWER
            PlayMakerInspectorUtils.SetActionEditorVariableSelectionContext(target, target.GetType().GetField("xPathQuery"));
                        #endif


            target.xPathQuery = VariableEditor.FsmStringField(new GUIContent("xPath Query"), fsm, target.xPathQuery, null);
        }

        if (string.IsNullOrEmpty(target.xPathQuery.Value))
        {
        }
        else
        {
            if (target.xPathVariables == null || target.xPathVariables.Length == 0)
            {
                if (!target._foldout)
                {
                    EditorGUILayout.LabelField("xPath Query", target.xPathQuery.Value);
                }
            }
            else
            {
                EditorGUILayout.LabelField("xPath Query parsed", target.ParseXpathQuery(fsm));
            }
        }
        if (target._foldout)
        {
            edited = edited || EditFsmXpathQueryVariablesProperties(fsm, target);
        }


        return(edited);
    }
    //string SentByFsmAction = "";

    void OnGUI()
    {
        wantsMouseMove = true;


        EditorGUIUtility.labelWidth = 150f;
        EditorGUIUtility.wideMode   = true;

        if (Event.current.type == EventType.MouseMove)
        {
            Repaint();
        }

        GUILayout.BeginHorizontal(EditorStyles.toolbar);
        if (GUILayout.Button("Reset Event Data", EditorStyles.toolbarButton))
        {
            Fsm.EventData = new FsmEventData();

            PlayMakerInspectorUtils.RemoveFocus();

            GUIUtility.ExitGUI();
        }

        GUILayout.FlexibleSpace();
        LiveUpdate = GUILayout.Toggle(LiveUpdate, "Live Update", EditorStyles.toolbarButton);

        GUILayout.EndHorizontal();


        OnGUI_Title("Sender Data");

        if (Fsm.EventData.SentByFsm != null)
        {
            SentByFsmComponent = Fsm.EventData.SentByFsm.FsmComponent;
            SentByFsm          = Fsm.EventData.SentByFsm.Name;
        }
        else
        {
            SentByFsmComponent = null;
            SentByFsm          = "n/a";
        }

        if (Fsm.EventData.SentByState != null)
        {
            SentByFsmState = Fsm.EventData.SentByState.Name;
        }
        else
        {
            SentByFsmState = "n/a";
        }

//		if (Fsm.EventData.SentByAction != null) {
//			SentByFsmAction = Fsm.EventData.SentByAction.Name;
//		} else {
//			SentByFsmAction = "n/a";
//		}


        EditorGUILayout.LabelField("Fsm Name", SentByFsm);
        GUI.enabled = false;
        EditorGUILayout.ObjectField("Fsm Component", SentByFsmComponent, typeof(PlayMakerFSM), true);
        GUI.enabled = true;

        EditorGUILayout.LabelField("Fsm State", SentByFsmState);

        //EditorGUILayout.LabelField ("Fsm Action", SentByFsmAction);

        GUILayout.Space(10f);

        OnGUI_Title("Event Data");

        bool _b = EditorGUILayout.Toggle("Bool", Fsm.EventData.BoolData);

        if (_b != Fsm.EventData.BoolData)
        {
            Fsm.EventData.BoolData = _b;
        }

        int _i = EditorGUILayout.IntField("Int", Fsm.EventData.IntData);

        if (_i != Fsm.EventData.IntData)
        {
            Fsm.EventData.FloatData = _i;
        }

        float _f = EditorGUILayout.FloatField("Float", Fsm.EventData.FloatData);

        if (_f != Fsm.EventData.FloatData)
        {
            Fsm.EventData.FloatData = _f;
        }

        Vector2 _v2 = EditorGUILayout.Vector2Field("Vector2", Fsm.EventData.Vector2Data);

        if (_v2 != Fsm.EventData.Vector2Data)
        {
            Fsm.EventData.Vector2Data = _v2;
        }

        Vector3 _v3 = EditorGUILayout.Vector3Field("Vector3", Fsm.EventData.Vector3Data);

        if (_v3 != Fsm.EventData.Vector3Data)
        {
            Fsm.EventData.Vector3Data = _v3;
        }

        string _s = EditorGUILayout.TextField("String", Fsm.EventData.StringData);

        if (_s != Fsm.EventData.StringData)
        {
            Fsm.EventData.StringData = _s;
        }

        GameObject _go = (GameObject)EditorGUILayout.ObjectField("GameObject", Fsm.EventData.GameObjectData, typeof(GameObject), true);

        if (_go != Fsm.EventData.GameObjectData)
        {
            Fsm.EventData.GameObjectData = _go;
        }

        Rect _r = EditorGUILayout.RectField("Rect", Fsm.EventData.RectData);

        if (_r != Fsm.EventData.RectData)
        {
            Fsm.EventData.RectData = _r;
        }

        GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
        EditorGUILayout.PrefixLabel("Quaternion");
        float _lw = EditorGUIUtility.labelWidth;

        EditorGUIUtility.labelWidth = 12f;
        float x = EditorGUILayout.FloatField("X", Fsm.EventData.QuaternionData.x);
        float y = EditorGUILayout.FloatField("Y", Fsm.EventData.QuaternionData.y);
        float z = EditorGUILayout.FloatField("Z", Fsm.EventData.QuaternionData.z);
        float w = EditorGUILayout.FloatField("W", Fsm.EventData.QuaternionData.w);

        EditorGUIUtility.labelWidth = _lw;
        GUILayout.EndHorizontal();

        if (x != Fsm.EventData.QuaternionData.x ||
            y != Fsm.EventData.QuaternionData.y ||
            z != Fsm.EventData.QuaternionData.z ||
            w != Fsm.EventData.QuaternionData.w)
        {
            Fsm.EventData.QuaternionData = new Quaternion(x, y, z, w);
        }

        Material _m = (Material)EditorGUILayout.ObjectField("Material", Fsm.EventData.MaterialData, typeof(Material), true);

        if (_m != Fsm.EventData.MaterialData)
        {
            Fsm.EventData.MaterialData = _m;
        }

        Texture _t = (Texture)EditorGUILayout.ObjectField("Texture", Fsm.EventData.TextureData, typeof(Texture), true);

        if (_t != Fsm.EventData.TextureData)
        {
            Fsm.EventData.TextureData = _t;
        }

        Color _c = EditorGUILayout.ColorField("Color", Fsm.EventData.ColorData);

        if (_c != Fsm.EventData.ColorData)
        {
            Fsm.EventData.ColorData = _c;
        }

        Object _g = (Object)EditorGUILayout.ObjectField("Object", Fsm.EventData.ObjectData, typeof(Object), true);

        if (_g != Fsm.EventData.ObjectData)
        {
            Fsm.EventData.ObjectData = _g;
        }

//		OnGUI_Title("Send Event");
//
//
//
//		if (_mpes == null)
//		{
//			_mpes =ScriptableObject.CreateInstance<EventDataSenderProxy> ();
//		}
//
//		if (m_serializedObject == null) {
//			m_serializedObject = new UnityEditor.SerializedObject(_mpes);
//			m_EventTargetProperty = m_serializedObject.FindProperty("EventTarget");
//			//window.m_serializedProperty  = m_serializedObject.FindProperty("foobar");
//		}
//
//
//		m_serializedObject.Update();
//
//		EditorGUILayout.PropertyField(m_EventTargetProperty , true);
//
//		m_serializedObject.ApplyModifiedProperties();
    }
Esempio n. 3
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. 4
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);
    }
Esempio n. 5
0
    public static bool EditFsmXmlSourceField(Fsm fsm, FsmXmlSource source)
    {
        source.sourceSelection = EditorGUILayout.Popup("Source selection", source.sourceSelection, source.sourceTypes);

        if (source.sourceString == null)
        {
            source.sourceString = new FsmString();
        }

        source.sourceString.UseVariable = source.sourceSelection == 2;

        bool   showPreview = false;
        string preview     = "";

        if (source.sourceSelection == 0)
        {
            source._sourceEdit = EditorGUILayout.Foldout(source._sourceEdit, new GUIContent("Edit"));
            if (source._sourceEdit)
            {
                source.sourceString.Value = EditorGUILayout.TextArea(source.sourceString.Value, GUILayout.Height(200));
            }
        }
        else if (source.sourceSelection == 1)
        {
            source.sourcetextAsset = (TextAsset)EditorGUILayout.ObjectField("TextAsset Object", source.sourcetextAsset, typeof(TextAsset), false);
            if (source.sourcetextAsset != null)
            {
                source._sourcePreview = EditorGUILayout.Foldout(source._sourcePreview, new GUIContent("Preview"));
                showPreview           = source._sourcePreview;
                preview = source.sourcetextAsset.text;
            }
        }
        else if (source.sourceSelection == 2)
        {
                        #if PLAYMAKER_1_8_OR_NEWER
            PlayMakerInspectorUtils.SetActionEditorVariableSelectionContext(source, source.GetType().GetField("sourceString"));
                        #endif
            source.sourceString = VariableEditor.FsmStringField(new GUIContent("Fsm String"), fsm, source.sourceString, null);

            if (!source.sourceString.UseVariable)
            {
                source.sourceSelection = 0;
                return(true);
            }

            if (!source.sourceString.IsNone)
            {
                source._sourcePreview = EditorGUILayout.Foldout(source._sourcePreview, new GUIContent("Preview"));
                showPreview           = source._sourcePreview;
                preview = source.sourceString.Value;
            }
        }
        else if (source.sourceSelection == 3)
        {
            if (source.sourceProxyGameObject == null)
            {
                source.sourceProxyGameObject = new FsmGameObject();
                source.sourceProxyReference  = new FsmString();
            }

                        #if PLAYMAKER_1_8_OR_NEWER
            PlayMakerInspectorUtils.SetActionEditorVariableSelectionContext(source, source.GetType().GetField("sourceProxyGameObject"));
                        #endif
            source.sourceProxyGameObject = VariableEditor.FsmGameObjectField(new GUIContent("GameObject"), fsm, source.sourceProxyGameObject);

                        #if PLAYMAKER_1_8_OR_NEWER
            PlayMakerInspectorUtils.SetActionEditorVariableSelectionContext(source, source.GetType().GetField("sourceProxyReference"));
                        #endif

            source.sourceProxyReference = VariableEditor.FsmStringField(new GUIContent("Reference"), fsm, source.sourceProxyReference, null);

            if (source.sourceProxyGameObject != null)
            {
                DataMakerXmlProxy proxy = DataMakerCore.GetDataMakerProxyPointer(typeof(DataMakerXmlProxy), source.sourceProxyGameObject.Value, source.sourceProxyReference.Value, true) as DataMakerXmlProxy;
                if (proxy != null)
                {
                    if (proxy.XmlTextAsset != null)
                    {
                        source._sourcePreview = EditorGUILayout.Foldout(source._sourcePreview, new GUIContent("Preview"));
                        showPreview           = source._sourcePreview;
                        preview = proxy.XmlTextAsset.text;
                    }
                    else
                    {
                        //oupss...
                    }
                }
                else
                {
                    //oupss..
                }
            }
        }
        else if (source.sourceSelection == 4)
        {
            if (source.inMemoryReference == null)
            {
                source.inMemoryReference = new FsmString();
            }

                        #if PLAYMAKER_1_8_OR_NEWER
            PlayMakerInspectorUtils.SetActionEditorVariableSelectionContext(source, source.GetType().GetField("inMemoryReference"));
                        #endif
            source.inMemoryReference = VariableEditor.FsmStringField(new GUIContent("Memory Reference"), fsm, source.inMemoryReference, null);

            if (!string.IsNullOrEmpty(source.inMemoryReference.Value))
            {
                source._sourcePreview = EditorGUILayout.Foldout(source._sourcePreview, new GUIContent("Preview"));
                showPreview           = source._sourcePreview;
                preview = DataMakerXmlUtils.XmlNodeToString(DataMakerXmlUtils.XmlRetrieveNode(source.inMemoryReference.Value));
            }
        }

        if (showPreview)
        {
            if (string.IsNullOrEmpty(preview))
            {
                GUILayout.Label("-- empty --");
            }
            else
            {
                source._scroll = DataMakerEditorGUILayoutUtils.StringContentPreview(source._scroll, preview);

                /*
                 * source._scroll = GUILayout.BeginScrollView(source._scroll,"box", GUILayout.Height (200));
                 * GUI.skin.box.alignment = TextAnchor.UpperLeft;
                 * GUILayout.Box(preview,"Label",null);
                 * GUILayout.EndScrollView();
                 */
            }
        }


        return(false);
    }