public override void OnInspectorGUI() { if (!_isAssimpAsset) { base.OnInspectorGUI(); return; } GUI.enabled = true; #pragma warning disable 618 EditorGUIUtility.LookLikeInspector(); #pragma warning restore 618 EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); _currentTab = GUILayout.Toggle(_currentTab == 0, "General", "Button") ? 0 : _currentTab; _currentTab = GUILayout.Toggle(_currentTab == 1, "Meshes", "Button") ? 1 : _currentTab; _currentTab = GUILayout.Toggle(_currentTab == 2, "Materials", "Button") ? 2 : _currentTab; _currentTab = GUILayout.Toggle(_currentTab == 3, "Animations", "Button") ? 3 : _currentTab; _currentTab = GUILayout.Toggle(_currentTab == 4, "Misc", "Button") ? 4 : _currentTab; _currentTab = GUILayout.Toggle(_currentTab == 5, "Metadata", "Button") ? 5 : _currentTab; _currentTab = GUILayout.Toggle(_currentTab == 6, "Advanced", "Button") ? 6 : _currentTab; EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); switch (_currentTab) { case 0: EditorGUILayout.LabelField("General", EditorStyles.boldLabel); #if UNITY_2017_3_OR_NEWER _tempAssetLoaderOptions.PostProcessSteps = (AssimpPostProcessSteps)EditorGUILayout.EnumFlagsField("Post Processor Options", _tempAssetLoaderOptions.PostProcessSteps); #else _tempAssetLoaderOptions.PostProcessSteps = (AssimpPostProcessSteps)EditorGUILayout.EnumMaskField("Post Processor Options", _tempAssetLoaderOptions.PostProcessSteps); #endif break; case 1: { EditorGUILayout.LabelField("Meshes", EditorStyles.boldLabel); var dontLoadMeshesProperty = _tempSerializedObject.FindProperty("DontLoadMeshes"); EditorGUILayout.PropertyField(dontLoadMeshesProperty); if (!dontLoadMeshesProperty.boolValue) { EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("CombineMeshes")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("Scale")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("RotationAngles")); #if UNITY_2017_3_OR_NEWER EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("Use32BitsIndexFormat")); #endif var generateMeshCollidersProperty = _tempSerializedObject.FindProperty("GenerateMeshColliders"); EditorGUILayout.PropertyField(generateMeshCollidersProperty); if (generateMeshCollidersProperty.boolValue) { EditorGUI.indentLevel = 1; EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ConvexMeshColliders")); EditorGUI.indentLevel = 0; } } EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("DontLoadSkinning")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("DontLoadBlendShapes")); } break; case 2: { EditorGUILayout.LabelField("Materials", EditorStyles.boldLabel); var dontLoadMaterialsProperty = _tempSerializedObject.FindProperty("DontLoadMaterials"); EditorGUILayout.PropertyField(dontLoadMaterialsProperty); if (!dontLoadMaterialsProperty.boolValue) { var disableAlphaMaterials = _tempSerializedObject.FindProperty("DisableAlphaMaterials"); EditorGUILayout.PropertyField(disableAlphaMaterials); if (!disableAlphaMaterials.boolValue) { EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyColorAlpha")); } EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyDiffuseColor")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyEmissionColor")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplySpecularColor")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyDiffuseTexture")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyEmissionTexture")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplySpecularTexture")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyNormalTexture")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyDisplacementTexture")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyNormalScale")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyGlossiness")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyGlossinessScale")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("GenerateMipMaps")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("UseStandardSpecularMaterial")); if (!disableAlphaMaterials.boolValue) { EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ScanForAlphaMaterials")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("UseCutoutMaterials")); } EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("TextureCompression")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("TextureFilterMode")); } } break; case 3: { EditorGUILayout.LabelField("Animations", EditorStyles.boldLabel); var dontLoadAnimationsProperty = _tempSerializedObject.FindProperty("DontLoadAnimations"); EditorGUILayout.PropertyField(dontLoadAnimationsProperty); if (!dontLoadAnimationsProperty.boolValue) { EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AutoPlayAnimations")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AnimationWrapMode")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("EnsureQuaternionContinuity")); var legacyAnimationProperty = _tempSerializedObject.FindProperty("UseLegacyAnimations"); EditorGUILayout.PropertyField(legacyAnimationProperty); if (!legacyAnimationProperty.boolValue) { EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AnimatorController")); var avatar = _tempSerializedObject.FindProperty("Avatar"); EditorGUILayout.PropertyField(avatar); if (avatar.objectReferenceValue == null) { EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("DontGenerateAvatar")); } } } } break; case 4: { EditorGUILayout.LabelField("Misc", EditorStyles.boldLabel); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AddAssetUnloader")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("DontLoadCameras")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("DontLoadLights")); } break; case 5: { EditorGUILayout.LabelField("Metadata", EditorStyles.boldLabel); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("DontLoadMetadata")); } break; default: { EditorGUILayout.LabelField("Advanced", EditorStyles.boldLabel); var advancedConfigs = _tempSerializedObject.FindProperty("AdvancedConfigs"); var lastGroup = string.Empty; var groupIndex = 0; foreach (var configKey in AssetAdvancedPropertyMetadata.ConfigKeys) { AssetAdvancedConfigType assetAdvancedConfigType; string className; string description; string group; bool hasDefaultValue; bool hasMinValue; bool hasMaxValue; object defaultValue; object minValue; object maxValue; AssetAdvancedPropertyMetadata.GetOptionMetadata(configKey, out assetAdvancedConfigType, out className, out description, out group, out defaultValue, out minValue, out maxValue, out hasDefaultValue, out hasMinValue, out hasMaxValue); SerializedProperty elementSerializedProperty = null; var serializedElementIndex = 0; var recentlyCreated = false; for (var i = 0; i < _tempAssetLoaderOptions.AdvancedConfigs.Count; i++) { var advancedProperty = _tempAssetLoaderOptions.AdvancedConfigs[i]; if (advancedProperty.Key == configKey) { serializedElementIndex = i; elementSerializedProperty = advancedConfigs.GetArrayElementAtIndex(i); break; } } if (group != lastGroup) { lastGroup = group; _groupUnfolded[groupIndex] = EditorGUILayout.Foldout(_groupUnfolded[groupIndex], lastGroup); groupIndex++; } if (_groupUnfolded[groupIndex - 1]) { EditorGUILayout.BeginHorizontal(); var enableProperty = EditorGUILayout.BeginToggleGroup(new GUIContent(className, description), elementSerializedProperty != null); if (elementSerializedProperty == null && enableProperty) { advancedConfigs.InsertArrayElementAtIndex(advancedConfigs.arraySize); _tempSerializedObject.ApplyModifiedProperties(); var elementIndex = Mathf.Max(0, advancedConfigs.arraySize - 1); elementSerializedProperty = advancedConfigs.GetArrayElementAtIndex(elementIndex); elementSerializedProperty.FindPropertyRelative("Key").stringValue = configKey; _tempSerializedObject.ApplyModifiedProperties(); recentlyCreated = true; } else if (elementSerializedProperty != null && !enableProperty) { advancedConfigs.DeleteArrayElementAtIndex(serializedElementIndex); _tempSerializedObject.ApplyModifiedProperties(); return; } SerializedProperty valueSerializedProperty; switch (assetAdvancedConfigType) { case AssetAdvancedConfigType.Bool: var boolDefaultValue = hasDefaultValue && (bool)defaultValue; if (elementSerializedProperty == null) { GUI.enabled = false; EditorGUILayout.Toggle(boolDefaultValue ? "Enabled" : "Disabled", boolDefaultValue); } else { GUI.enabled = true; valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("BoolValue"); if (recentlyCreated) { valueSerializedProperty.boolValue = boolDefaultValue; } EditorGUILayout.PropertyField(valueSerializedProperty, new GUIContent(valueSerializedProperty.boolValue ? "Enabled" : "Disabled")); } break; case AssetAdvancedConfigType.Integer: var intDefaultValue = hasDefaultValue ? (int)defaultValue : 0; if (hasMinValue && hasMaxValue) { if (elementSerializedProperty == null) { GUI.enabled = false; EditorGUILayout.IntSlider(intDefaultValue, (int)minValue, (int)maxValue); } else { GUI.enabled = true; valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue"); if (recentlyCreated) { valueSerializedProperty.intValue = intDefaultValue; } EditorGUILayout.IntSlider(valueSerializedProperty, (int)minValue, (int)maxValue, GUIContent.none); } } else { if (elementSerializedProperty == null) { GUI.enabled = false; EditorGUILayout.IntField(intDefaultValue); } else { GUI.enabled = true; valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue"); if (recentlyCreated) { valueSerializedProperty.intValue = intDefaultValue; } EditorGUILayout.PropertyField(valueSerializedProperty, GUIContent.none); } } break; case AssetAdvancedConfigType.Float: var floatDefaultValue = hasDefaultValue ? (float)defaultValue : 0f; if (hasMinValue && hasMaxValue) { if (elementSerializedProperty == null) { GUI.enabled = false; EditorGUILayout.Slider(floatDefaultValue, (float)minValue, (float)maxValue); } else { GUI.enabled = true; valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("FloatValue"); if (recentlyCreated) { valueSerializedProperty.floatValue = floatDefaultValue; } EditorGUILayout.Slider(valueSerializedProperty, (float)minValue, (float)maxValue, GUIContent.none); } } else { if (elementSerializedProperty == null) { GUI.enabled = false; EditorGUILayout.FloatField(floatDefaultValue); } else { GUI.enabled = true; valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("FloatValue"); if (recentlyCreated) { valueSerializedProperty.floatValue = floatDefaultValue; } EditorGUILayout.PropertyField(valueSerializedProperty, GUIContent.none); } } break; case AssetAdvancedConfigType.String: var stringDefaultValue = hasDefaultValue ? (string)defaultValue : string.Empty; if (elementSerializedProperty == null) { GUI.enabled = false; EditorGUILayout.TextField(stringDefaultValue); } else { GUI.enabled = true; valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("StringValue"); if (recentlyCreated) { valueSerializedProperty.stringValue = stringDefaultValue; } EditorGUILayout.PropertyField(valueSerializedProperty, GUIContent.none); } break; case AssetAdvancedConfigType.AiComponent: var aiComponentDefaultValue = hasDefaultValue ? (AiComponent)defaultValue : AiComponent.Animations; if (elementSerializedProperty == null) { GUI.enabled = false; #if UNITY_2017_3_OR_NEWER EditorGUILayout.EnumFlagsField(aiComponentDefaultValue); #else EditorGUILayout.EnumMaskField(aiComponentDefaultValue); #endif } else { GUI.enabled = true; valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue"); if (recentlyCreated) { valueSerializedProperty.intValue = (int)aiComponentDefaultValue; } PropertyEnumMaskField(valueSerializedProperty, assetAdvancedConfigType, GUIContent.none); } break; case AssetAdvancedConfigType.AiPrimitiveType: var aiPrimitiveTypeDefaultValue = hasDefaultValue ? (AiPrimitiveType)defaultValue : AiPrimitiveType.Line; if (elementSerializedProperty == null) { GUI.enabled = false; #if UNITY_2017_3_OR_NEWER EditorGUILayout.EnumFlagsField(aiPrimitiveTypeDefaultValue); #else EditorGUILayout.EnumMaskField(aiPrimitiveTypeDefaultValue); #endif } else { GUI.enabled = true; valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue"); if (recentlyCreated) { valueSerializedProperty.intValue = (int)aiPrimitiveTypeDefaultValue; } PropertyEnumMaskField(valueSerializedProperty, assetAdvancedConfigType, GUIContent.none); } break; case AssetAdvancedConfigType.AiUVTransform: var aiUvTransformDefaultValue = hasDefaultValue ? (AiUVTransform)defaultValue : AiUVTransform.Rotation; if (elementSerializedProperty == null) { GUI.enabled = false; #if UNITY_2017_3_OR_NEWER EditorGUILayout.EnumFlagsField(aiUvTransformDefaultValue); #else EditorGUILayout.EnumMaskField(aiUvTransformDefaultValue); #endif } else { GUI.enabled = true; valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue"); if (recentlyCreated) { valueSerializedProperty.intValue = (int)aiUvTransformDefaultValue; } PropertyEnumMaskField(valueSerializedProperty, assetAdvancedConfigType, GUIContent.none); } break; case AssetAdvancedConfigType.AiMatrix: if (elementSerializedProperty == null) { GUI.enabled = false; GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("Translation", GUILayout.Width(75)); GUILayout.FlexibleSpace(); EditorGUILayout.Vector3Field(GUIContent.none, Vector3.zero); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Rotation", GUILayout.Width(75)); GUILayout.FlexibleSpace(); EditorGUILayout.Vector3Field(GUIContent.none, Vector3.zero); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Scale", GUILayout.Width(75)); GUILayout.FlexibleSpace(); EditorGUILayout.Vector3Field(GUIContent.none, Vector3.one); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } else { GUI.enabled = true; var valueSerializedProperty1 = elementSerializedProperty.FindPropertyRelative("TranslationValue"); var valueSerializedProperty2 = elementSerializedProperty.FindPropertyRelative("RotationValue"); var valueSerializedProperty3 = elementSerializedProperty.FindPropertyRelative("ScaleValue"); if (recentlyCreated) { valueSerializedProperty1.vector3Value = Vector3.zero; valueSerializedProperty2.vector3Value = Vector3.zero; valueSerializedProperty3.vector3Value = Vector3.one; } GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("Translation", GUILayout.Width(75)); GUILayout.FlexibleSpace(); EditorGUILayout.PropertyField(valueSerializedProperty1, GUIContent.none, true, GUILayout.MinWidth(100)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Rotation", GUILayout.Width(75)); GUILayout.FlexibleSpace(); EditorGUILayout.PropertyField(valueSerializedProperty2, GUIContent.none, true, GUILayout.MinWidth(100)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Scale", GUILayout.Width(75)); GUILayout.FlexibleSpace(); EditorGUILayout.PropertyField(valueSerializedProperty3, GUIContent.none, true, GUILayout.MinWidth(100)); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } break; } GUI.enabled = true; EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndHorizontal(); } } } break; } if (EditorGUI.EndChangeCheck()) { _hasChanged = true; } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUI.enabled = _hasChanged; if (GUILayout.Button("Revert")) { DestroyTempObject(); _tempAssetLoaderOptions = AssetLoaderOptions.CreateInstance(); SaveChanges(); } if (GUILayout.Button("Apply")) { _tempSerializedObject.ApplyModifiedProperties(); SaveChanges(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); }
public override void OnInspectorGUI() { if (!_isAssimpAsset) { base.OnInspectorGUI(); return; } GUI.enabled = true; #pragma warning disable 618 EditorGUIUtility.LookLikeInspector(); #pragma warning restore 618 EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); _currentTab = GUILayout.Toggle(_currentTab == 0, "General", "Button") ? 0 : _currentTab; _currentTab = GUILayout.Toggle(_currentTab == 1, "Meshes", "Button") ? 1 : _currentTab; _currentTab = GUILayout.Toggle(_currentTab == 2, "Materials", "Button") ? 2 : _currentTab; _currentTab = GUILayout.Toggle(_currentTab == 3, "Animations", "Button") ? 3 : _currentTab; _currentTab = GUILayout.Toggle(_currentTab == 4, "Advanced", "Button") ? 4 : _currentTab; EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); switch (_currentTab) { case 0: EditorGUILayout.LabelField("General", EditorStyles.boldLabel); _tempAssetLoaderOptions.PostProcessSteps = (AssimpPostProcessSteps)EditorGUILayout.EnumMaskField("Post Processor Options", _tempAssetLoaderOptions.PostProcessSteps); break; case 1: { EditorGUILayout.LabelField("Meshes", EditorStyles.boldLabel); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("Scale")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("RotationAngles")); var generateMeshCollidersProperty = _tempSerializedObject.FindProperty("GenerateMeshColliders"); EditorGUILayout.PropertyField(generateMeshCollidersProperty); if (generateMeshCollidersProperty.boolValue) { EditorGUI.indentLevel = 1; EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ConvexMeshColliders")); EditorGUI.indentLevel = 0; } } break; case 2: { EditorGUILayout.LabelField("Materials", EditorStyles.boldLabel); var dontLoadMaterialsProperty = _tempSerializedObject.FindProperty("DontLoadMaterials"); EditorGUILayout.PropertyField(dontLoadMaterialsProperty); if (!dontLoadMaterialsProperty.boolValue) { EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("TexturesPathOverride")); EditorGUILayout.Space(); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("MaterialsOverride"), new GUIContent("Material Override"), true); } } break; case 3: { EditorGUILayout.LabelField("Animations", EditorStyles.boldLabel); var dontLoadAnimationsProperty = _tempSerializedObject.FindProperty("DontLoadAnimations"); EditorGUILayout.PropertyField(dontLoadAnimationsProperty); if (!dontLoadAnimationsProperty.boolValue) { EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AutoPlayAnimations")); EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AnimationWrapMode")); var legacyAnimationProperty = _tempSerializedObject.FindProperty("UseLegacyAnimations"); EditorGUILayout.PropertyField(legacyAnimationProperty); if (!legacyAnimationProperty.boolValue) { EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AnimatorController")); } } } break; default: { EditorGUILayout.LabelField("Advanced", EditorStyles.boldLabel); var advancedConfigs = _tempSerializedObject.FindProperty("AdvancedConfigs"); var lastGroup = string.Empty; var groupIndex = 0; foreach (var configKey in AssetAdvancedPropertyMetadata.ConfigKeys) { AssetAdvancedConfigType assetAdvancedConfigType; string className; string description; string @group; bool hasDefaultValue; bool hasMinValue; bool hasMaxValue; object defaultValue; object minValue; object maxValue; AssetAdvancedPropertyMetadata.GetOptionMetadata(configKey, out assetAdvancedConfigType, out className, out description, out @group, out defaultValue, out minValue, out maxValue, out hasDefaultValue, out hasMinValue, out hasMaxValue); SerializedProperty elementSerializedProperty = null; var serializedElementIndex = 0; var recentlyCreated = false; for (var i = 0; i < _tempAssetLoaderOptions.AdvancedConfigs.Count; i++) { var advancedProperty = _tempAssetLoaderOptions.AdvancedConfigs[i]; if (advancedProperty.Key == configKey) { serializedElementIndex = i; elementSerializedProperty = advancedConfigs.GetArrayElementAtIndex(i); break; } } if (@group != lastGroup) { lastGroup = @group; _groupUnfolded[groupIndex] = EditorGUILayout.Foldout(_groupUnfolded[groupIndex], lastGroup); groupIndex++; } if (_groupUnfolded[groupIndex - 1]) { EditorGUILayout.BeginHorizontal(); var enableProperty = EditorGUILayout.BeginToggleGroup(new GUIContent(className, description), elementSerializedProperty != null); if (elementSerializedProperty == null && enableProperty) { advancedConfigs.InsertArrayElementAtIndex(advancedConfigs.arraySize); _tempSerializedObject.ApplyModifiedProperties(); var elementIndex = Mathf.Max(0, advancedConfigs.arraySize - 1); elementSerializedProperty = advancedConfigs.GetArrayElementAtIndex(elementIndex); elementSerializedProperty.FindPropertyRelative("Key").stringValue = configKey; _tempSerializedObject.ApplyModifiedProperties(); recentlyCreated = true; } else if (elementSerializedProperty != null && !enableProperty) { advancedConfigs.DeleteArrayElementAtIndex(serializedElementIndex); _tempSerializedObject.ApplyModifiedProperties(); return; } SerializedProperty valueSerializedProperty; switch (assetAdvancedConfigType) { case AssetAdvancedConfigType.Bool: var boolDefaultValue = hasDefaultValue && (bool)defaultValue; if (elementSerializedProperty == null) { GUI.enabled = false; EditorGUILayout.Toggle(boolDefaultValue ? "Enabled" : "Disabled", boolDefaultValue); } else { GUI.enabled = true; valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("BoolValue"); if (recentlyCreated) { valueSerializedProperty.boolValue = boolDefaultValue; } EditorGUILayout.PropertyField(valueSerializedProperty, new GUIContent(valueSerializedProperty.boolValue ? "Enabled" : "Disabled")); } break; case AssetAdvancedConfigType.Integer: var intDefaultValue = hasDefaultValue ? (int)defaultValue : 0; if (hasMinValue && hasMaxValue) { if (elementSerializedProperty == null) { GUI.enabled = false; EditorGUILayout.IntSlider(intDefaultValue, (int)minValue, (int)maxValue); } else { GUI.enabled = true; valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue"); if (recentlyCreated) { valueSerializedProperty.intValue = intDefaultValue; } EditorGUILayout.IntSlider(valueSerializedProperty, (int)minValue, (int)maxValue, GUIContent.none); } } else { if (elementSerializedProperty == null) { GUI.enabled = false; EditorGUILayout.IntField(intDefaultValue); } else { GUI.enabled = true; valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue"); if (recentlyCreated) { valueSerializedProperty.intValue = intDefaultValue; } EditorGUILayout.PropertyField(valueSerializedProperty, GUIContent.none); } } break; case AssetAdvancedConfigType.Float: var floatDefaultValue = hasDefaultValue ? (float)defaultValue : 0f; if (hasMinValue && hasMaxValue) { if (elementSerializedProperty == null) { GUI.enabled = false; EditorGUILayout.Slider(floatDefaultValue, (float)minValue, (float)maxValue); } else { GUI.enabled = true; valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("FloatValue"); if (recentlyCreated) { valueSerializedProperty.floatValue = floatDefaultValue; } EditorGUILayout.Slider(valueSerializedProperty, (float)minValue, (float)maxValue, GUIContent.none); } } else { if (elementSerializedProperty == null) { GUI.enabled = false; EditorGUILayout.FloatField(floatDefaultValue); } else { GUI.enabled = true; valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("FloatValue"); if (recentlyCreated) { valueSerializedProperty.floatValue = floatDefaultValue; } EditorGUILayout.PropertyField(valueSerializedProperty, GUIContent.none); } } break; case AssetAdvancedConfigType.String: var stringDefaultValue = hasDefaultValue ? (string)defaultValue : string.Empty; if (elementSerializedProperty == null) { GUI.enabled = false; EditorGUILayout.TextField(stringDefaultValue); } else { GUI.enabled = true; valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("StringValue"); if (recentlyCreated) { valueSerializedProperty.stringValue = stringDefaultValue; } EditorGUILayout.PropertyField(valueSerializedProperty, GUIContent.none); } break; case AssetAdvancedConfigType.AiComponent: var aiComponentDefaultValue = hasDefaultValue ? (AiComponent)defaultValue : AiComponent.Animations; if (elementSerializedProperty == null) { GUI.enabled = false; EditorGUILayout.EnumMaskField(aiComponentDefaultValue); } else { GUI.enabled = true; valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue"); if (recentlyCreated) { valueSerializedProperty.intValue = (int)aiComponentDefaultValue; } PropertyEnumMaskField(valueSerializedProperty, assetAdvancedConfigType, GUIContent.none); } break; case AssetAdvancedConfigType.AiPrimitiveType: var aiPrimitiveTypeDefaultValue = hasDefaultValue ? (AiPrimitiveType)defaultValue : AiPrimitiveType.Line; if (elementSerializedProperty == null) { GUI.enabled = false; EditorGUILayout.EnumMaskField(aiPrimitiveTypeDefaultValue); } else { GUI.enabled = true; valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue"); if (recentlyCreated) { valueSerializedProperty.intValue = (int)aiPrimitiveTypeDefaultValue; } PropertyEnumMaskField(valueSerializedProperty, assetAdvancedConfigType, GUIContent.none); } break; case AssetAdvancedConfigType.AiUVTransform: var aiUvTransformDefaultValue = hasDefaultValue ? (AiUVTransform)defaultValue : AiUVTransform.Rotation; if (elementSerializedProperty == null) { GUI.enabled = false; EditorGUILayout.EnumMaskField(aiUvTransformDefaultValue); } else { GUI.enabled = true; valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue"); if (recentlyCreated) { valueSerializedProperty.intValue = (int)aiUvTransformDefaultValue; } PropertyEnumMaskField(valueSerializedProperty, assetAdvancedConfigType, GUIContent.none); } break; } GUI.enabled = true; EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndHorizontal(); } } } break; } if (EditorGUI.EndChangeCheck()) { _hasChanged = true; } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUI.enabled = _hasChanged; if (GUILayout.Button("Revert")) { DestroyTempObject(); _tempAssetLoaderOptions = AssetLoaderOptions.CreateInstance(); SaveChanges(); } if (GUILayout.Button("Apply")) { _tempSerializedObject.ApplyModifiedProperties(); SaveChanges(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); }