private void DrawUserRule(float x, float y, ref string name, Rule rule) { EditorGUI.LabelField(new Rect(x, y, 45.0f, EditorGUIUtility.singleLineHeight), "Name:"); x += 45.0f; name = EditorGUI.TextField(new Rect(x, y, 90.0f, EditorGUIUtility.singleLineHeight), name); x += 93.0f; GUI.enabled = false; EditorGUI.LabelField(new Rect(x, y, 10.0f, EditorGUIUtility.singleLineHeight), "|"); x += 12.0f; GUI.enabled = true; EditorGUI.LabelField(new Rect(x, y, 60.0f, EditorGUIUtility.singleLineHeight), "Variable:"); x += 60.0f; rule.VariableName = EditorGUI.TextField(new Rect(x, y, 90.0f, EditorGUIUtility.singleLineHeight), rule.VariableName); x += 93.0f; rule.ValueType = (Rule.ValType)EditorGUI.EnumPopup(new Rect(x, y, 60.0f, EditorGUIUtility.singleLineHeight), rule.ValueType); x += 60.0f; if (rule.ValueType == Rule.ValType.Bool) { SA_YesNoBool variable = rule.Value.BoolValue ? SA_YesNoBool.Yes : SA_YesNoBool.No; variable = (SA_YesNoBool)EditorGUI.EnumPopup(new Rect(x + 10.0f, y, 40.0f, EditorGUIUtility.singleLineHeight), variable); x += 40.0f; rule.Value.BoolValue = variable == SA_YesNoBool.Yes ? true : false; } else if (rule.ValueType == Rule.ValType.Integer) { rule.Operation = (Rule.LogicOp)EditorGUI.EnumPopup(new Rect(x + 10.0f, y, 60.0f, EditorGUIUtility.singleLineHeight), rule.Operation); x += 70.0f; rule.Value.IntValue = EditorGUI.IntField(new Rect(x + 10.0f, y, 90.0f, EditorGUIUtility.singleLineHeight), rule.Value.IntValue); x += 90.0f; } else if (rule.ValueType == Rule.ValType.String) { rule.Value.StrValue = EditorGUI.TextField(new Rect(x + 10.0f, y, 200.0f, EditorGUIUtility.singleLineHeight), rule.Value.StrValue); x += 200.0f; } }
public static bool YesNoFiled(GUIContent title, bool value) { SA_YesNoBool initialValue = SA_YesNoBool.Yes; if (!value) { initialValue = SA_YesNoBool.No; } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(title); initialValue = (SA_YesNoBool)EditorGUILayout.EnumPopup(initialValue); if (initialValue == SA_YesNoBool.Yes) { value = true; } else { value = false; } EditorGUILayout.EndHorizontal(); return(value); }