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(); target.xPathVariables[i] = VariableEditor.FsmVarPopup(new GUIContent("Variable _" + i + "_"), fsm, target.xPathVariables[i]); 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); }
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(); 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]); } } 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); }