void OnGUI_XmlNodeListReferencePreview(string reference) { string preview = DataMakerXmlUtils.XmlNodeListToString(DataMakerXmlUtils.XmlRetrieveNodeList(reference)); if (string.IsNullOrEmpty(preview)) { GUILayout.Label("-- empty --"); } else { if (!xmlNodeListPreviewsScroll.ContainsKey(reference)) { xmlNodeListPreviewsScroll.Add(reference, Vector2.zero); } xmlNodeListPreviewsScroll [reference] = DataMakerEditorGUILayoutUtils.StringContentPreview(xmlNodeListPreviewsScroll [reference], preview); } }
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 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); }
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); }