protected void DrawConditionsBlock() { EditorGUILayout.BeginVertical("Box"); VariantReference vref = EditorHelper.GetTargetObjectOfProperty(this.serializedObject.FindProperty(PROP_TARGET)) as VariantReference; System.Type enumType = vref != null?vref.GetPropertyReturnType() : null; if (enumType != null && !enumType.IsEnum) { enumType = null; } //draw conditions blocks var conditionsArrayProp = this.serializedObject.FindProperty(PROP_CONDITIONS); for (int i = 0; i < conditionsArrayProp.arraySize; i++) { var conditionBlockProp = conditionsArrayProp.GetArrayElementAtIndex(i); var valueProp = conditionBlockProp.FindPropertyRelative(PROP_CONDITIONBLOCK_VALUE); var flagsProp = conditionBlockProp.FindPropertyRelative(PROP_CONDITIONBLOCK_FLAGS); EditorGUILayout.LabelField((enumType != null) ? "Case " + ConvertUtil.ToEnumOfType(enumType, valueProp.intValue).ToString() + ":": "Case " + valueProp.intValue.ToString() + ":", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Value"); if (enumType == null) { valueProp.intValue = EditorGUILayout.IntField(valueProp.intValue); } else { switch ((i_TriggerOnEnumState.EnumFlagTestModes)flagsProp.intValue) { case i_TriggerOnEnumState.EnumFlagTestModes.NoFlag: { valueProp.intValue = ConvertUtil.ToInt(EditorGUILayout.EnumPopup(ConvertUtil.ToEnumOfType(enumType, valueProp.intValue))); } break; default: { //valueProp.intValue = ConvertUtil.ToInt(EditorGUILayout.EnumFlagsField(ConvertUtil.ToEnumOfType(enumType, valueProp.intValue))); valueProp.intValue = SPEditorGUILayout.EnumFlagField(enumType, valueProp.intValue); } break; } } flagsProp.intValue = ConvertUtil.ToInt(EditorGUILayout.EnumPopup((i_TriggerOnEnumState.EnumFlagTestModes)flagsProp.intValue)); EditorGUILayout.EndHorizontal(); var triggerProp = conditionBlockProp.FindPropertyRelative(PROP_CONDITIONBLOCK_TRIGGER); SPEditorGUILayout.PropertyField(triggerProp); EditorGUILayout.Space(); } //draw else EditorGUILayout.LabelField("Default Case:", EditorStyles.boldLabel); SPEditorGUILayout.PropertyField(this.serializedObject.FindProperty(PROP_DEFAULTCONDITION)); EditorGUILayout.Space(); //draw add buttons var fullRect = EditorGUILayout.GetControlRect(); var leftRect = new Rect(fullRect.xMin, fullRect.yMin, fullRect.width / 2f, fullRect.height); var rightRect = new Rect(fullRect.xMin + leftRect.width, fullRect.yMin, fullRect.width / 2f, fullRect.height); if (GUI.Button(leftRect, "Add Condition")) { conditionsArrayProp.arraySize++; } if (GUI.Button(rightRect, "Remove Condition")) { conditionsArrayProp.arraySize--; } EditorGUILayout.EndVertical(); }