public override void OnInspectorGUI() { DrawDefaultInspector(); DataMakerXmlNodeListProxy _target = target as DataMakerXmlNodeListProxy; if (_target._FsmXmlNodeList != null) { if (!_target._FsmXmlNodeList.Value.Equals(nodeListCache)) { nodeListCache = _target._FsmXmlNodeList.Value; content = DataMakerXmlUtils.XmlNodeListToString(nodeListCache); } DataMakerEditorGUILayoutUtils.feedbackLabel("Xml Source Valid", DataMakerEditorGUILayoutUtils.labelFeedbacks.OK); _scroll = DataMakerEditorGUILayoutUtils.StringContentPreview(_scroll, content); } else { DataMakerEditorGUILayoutUtils.feedbackLabel("Xml Source Invalid", DataMakerEditorGUILayoutUtils.labelFeedbacks.ERROR); } }
public override void OnInspectorGUI() { //DrawDefaultInspector(); DataMakerXmlProxy _target = target as DataMakerXmlProxy; _target.referenceName = EditorGUILayout.TextField(new GUIContent("Reference"), _target.referenceName); _target.FsmEventTarget = EditorGUILayout.ObjectField(new GUIContent("Fsm Event Target"), _target.FsmEventTarget, typeof(PlayMakerFSM), true) as PlayMakerFSM; if (_target.isDirty) { Refresh(); } if (!Application.isPlaying) { if (_target.useSource) { if (GUILayout.Button("Don't use Text Asset")) { _target.content = null; node = null; empty = true; _target.XmlTextAsset = null; _target.useSource = false; } TextAsset _asset = (TextAsset)EditorGUILayout.ObjectField(new GUIContent("Text Asset"), _target.XmlTextAsset, typeof(TextAsset), false); if (_asset != _target.XmlTextAsset) { _target.XmlTextAsset = _asset; Refresh(); } GUILayout.Label("This proxy also accepts runtime xml results."); GUILayout.Label("i.e Use actions like XMlSaveInProxy"); } else { GUILayout.Label("This proxy accepts runtime xml results"); GUILayout.Label("i.e Use actions like XMlSaveInProxy"); GUILayout.Label("But you can also use this proxy as a source"); if (GUILayout.Button("Use Text Asset")) { _target.content = null; node = null; empty = true; _target.useSource = true; } } } else { if (_target.useSource) { TextAsset _asset = (TextAsset)EditorGUILayout.ObjectField(new GUIContent("Text Asset"), _target.XmlTextAsset, typeof(TextAsset), false); if (_asset != _target.XmlTextAsset) { _target.XmlTextAsset = _asset; Refresh(); } } else { empty = _target.xmlNode == null; } } if (empty) { DataMakerEditorGUILayoutUtils.feedbackLabel("No XML data", DataMakerEditorGUILayoutUtils.labelFeedbacks.WARNING); } else { if (!valid) { DataMakerEditorGUILayoutUtils.feedbackLabel("Xml Invalid", DataMakerEditorGUILayoutUtils.labelFeedbacks.ERROR); } else { DataMakerEditorGUILayoutUtils.feedbackLabel("Xml Valid", DataMakerEditorGUILayoutUtils.labelFeedbacks.OK); } _scroll = DataMakerEditorGUILayoutUtils.StringContentPreview(_scroll, _target.content); if (GUILayout.Button("Refresh")) { _target.RefreshStringVersion(); } if (_target.XmlTextAsset != null) { if (GUILayout.Button("Save back to Text Asset file: " + _target.XmlTextAsset.name)) { string assetPath = AssetDatabase.GetAssetPath(_target.XmlTextAsset.GetInstanceID()); string path = Application.dataPath + assetPath.Substring(6); Debug.Log(path + "/n" + _target.content); File.WriteAllText(path, _target.content); AssetDatabase.LoadAssetAtPath(assetPath, typeof(TextAsset)); AssetDatabase.Refresh(); } } } if (GUI.changed) { EditorUtility.SetDirty(target); } }
public override void OnInspectorGUI() { //DrawDefaultInspector(); DataMakerXmlProxy _target = target as DataMakerXmlProxy; _target.referenceName = EditorGUILayout.TextField(new GUIContent("Reference"), _target.referenceName); if (!Application.isPlaying) { if (_target.useSource) { if (GUILayout.Button("Don't use Text Asset")) { content = null; node = null; empty = true; _target.XmlTextAsset = null; _target.useSource = false; } _target.XmlTextAsset = (TextAsset)EditorGUILayout.ObjectField(new GUIContent("Text Asset"), _target.XmlTextAsset, typeof(TextAsset), false); GUILayout.Label("This proxy also accepts runtime xml results."); GUILayout.Label("i.e Use actions like XMlSaveInProxy"); } else { GUILayout.Label("This proxy accepts runtime xml results"); GUILayout.Label("i.e Use actions like XMlSaveInProxy"); GUILayout.Label("But you can also use this proxy as a source"); if (GUILayout.Button("Use Text Asset")) { content = null; node = null; empty = true; _target.useSource = true; } } } else { if (_target.useSource) { _target.XmlTextAsset = (TextAsset)EditorGUILayout.ObjectField(new GUIContent("Text Asset"), _target.XmlTextAsset, typeof(TextAsset), false); } } if (_target.xmlNode != null) { /* * if (_target.XmlTextAsset!=null) * { * DataMakerEditorGUILayoutUtils.feedbackLabel("XML DATA CHANGED.",DataMakerEditorGUILayoutUtils.labelFeedbacks.WARNING); * } */ if (node == null || (!node.Equals(_target.xmlNode))) { node = _target.xmlNode; content = DataMakerXmlUtils.XmlNodeToString(_target.xmlNode); empty = string.IsNullOrEmpty(content); Debug.Log("PARSING XML NODE"); valid = DataMakerXmlUtils.StringToXmlNode(content) != null; } } else if (_target.XmlTextAsset != null) { if (content == null || !content.Equals(_target.XmlTextAsset.text)) { content = _target.XmlTextAsset.text; empty = string.IsNullOrEmpty(content); //Debug.Log("PARSING TEXT ASSET"); valid = DataMakerXmlUtils.StringToXmlNode(content) != null; } } if (empty) { DataMakerEditorGUILayoutUtils.feedbackLabel("No XML data", DataMakerEditorGUILayoutUtils.labelFeedbacks.WARNING); } else { if (!valid) { DataMakerEditorGUILayoutUtils.feedbackLabel("Xml Invalid", DataMakerEditorGUILayoutUtils.labelFeedbacks.ERROR); } else { DataMakerEditorGUILayoutUtils.feedbackLabel("Xml Valid", DataMakerEditorGUILayoutUtils.labelFeedbacks.OK); } _scroll = DataMakerEditorGUILayoutUtils.StringContentPreview(_scroll, content); } if (GUI.changed) { EditorUtility.SetDirty(target); } }
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); if (target.properties[i].UseVariable) { DataMakerEditorGUILayoutUtils.feedbackLabel("Using variables not supported, Check changeLog for infos", DataMakerEditorGUILayoutUtils.labelFeedbacks.ERROR); } // 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); }