private void drawTexFormatControl(TexFormatController control, int index) { GUILayout.BeginVertical(); { drawHeader(); if (showTexControlMap[index]) { GUILayout.BeginVertical("box"); EditorGUI.BeginChangeCheck(); { control.enable = EditorGUILayout.Toggle("Enable", control.enable); UTGUI.splitLine(); EditorGUI.BeginDisabledGroup(!control.enable); { drawCondition(); UTGUI.splitLine(); control.recursive = EditorGUILayout.Toggle("Recursive", control.recursive); drawPresetDisableGroup(); drawOtherTextureSetting(); checkPreset(control); EditorGUI.EndDisabledGroup(); } if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(setting); } } GUILayout.EndVertical(); } GUILayout.EndVertical(); } void drawHeader() { GUILayout.BeginHorizontal("box"); string header = $"Preset:{control.preset}"; if (control.conditionMethod != ConditionMethod.None) { header = header + $", Condition:{control.conditionMethod}({control.conditionText})"; } showTexControlMap[index] = EditorGUILayout.Foldout(showTexControlMap[index], header, true); float width = 30f; using (new EditorGUI.DisabledScope(index <= 0)) { if (GUILayout.Button("↑", GUILayout.Width(width))) { var temp = setting.texFormatControllers[index - 1]; setting.texFormatControllers[index - 1] = control; setting.texFormatControllers[index] = temp; EditorUtility.SetDirty(setting); } } using (new EditorGUI.DisabledScope(index >= setting.texFormatControllers.Count - 1)) { if (GUILayout.Button("↓", GUILayout.Width(width))) { var temp = setting.texFormatControllers[index + 1]; setting.texFormatControllers[index + 1] = control; setting.texFormatControllers[index] = temp; EditorUtility.SetDirty(setting); } } if (GUILayout.Button("X", GUILayout.Width(width))) { willRemoveTexControl = index; } GUILayout.EndHorizontal(); } void drawCondition() { control.conditionMethod = UTGUI.Enum("Condition", control.conditionMethod); if (control.conditionMethod != ConditionMethod.None) { control.conditionContent = UTGUI.Enum("ContentType", control.conditionContent); control.conditionText = UTGUI.Text("ContentText", control.conditionText); control.ignoreCase = UTGUI.Toggle("IgnoreCase", control.ignoreCase); } } void drawPresetDisableGroup() { control.preset = UTGUI.Enum("Preset: ", control.preset); // preset disable group var haspreset = control.preset != PresetSettings.None; EditorGUI.BeginDisabledGroup(haspreset); { control.textureType = UTGUI.Enum("TexType: ", control.textureType); if (control.textureType == TextureImporterType.Default) { control.textureShape = UTGUI.Enum("TexShape: ", control.textureShape); } control.mipMapEnable = EditorGUILayout.Toggle("MipMap?", control.mipMapEnable); control.wrapMode = UTGUI.Enum("Wrap", control.wrapMode); if (control.alphaMode != AlphaMode.Auto) { control.overrideAndroidFormat = UTGUI.Enum("Android", control.overrideAndroidFormat); control.overrideIOSFormat = UTGUI.Enum("IOS", control.overrideIOSFormat); control.overridePCFormat = UTGUI.Enum("PC", control.overridePCFormat); } EditorGUI.EndDisabledGroup(); } } void drawOtherTextureSetting() { // sprite EditorGUI.BeginDisabledGroup(control.textureType != TextureImporterType.Sprite); { control.atlasMode = UTGUI.Enum("AtlasMode: ", control.atlasMode); if (control.atlasMode == AtlasMode.Custom) { control.packingTag = UTGUI.Text("Atlas: ", control.packingTag); } EditorGUI.EndDisabledGroup(); } control.readWriteEnable = EditorGUILayout.Toggle("Readable?", control.readWriteEnable); control.filterMode = UTGUI.Enum("Filter", control.filterMode); control.maxSize = UTGUI.Int("MaxSize", control.maxSize); control.alphaMode = UTGUI.Enum("AlphaMode", control.alphaMode); control.nPOTScale = UTGUI.Enum("NPOT", control.nPOTScale); } }
private void DrawSetting( TexImporterSetting.Settings setting, bool foldout, string header = "Settings" ) { if (foldout) { showMap[setting.GetHashCode()] = EditorGUILayout.Foldout( showMap.GetValueOrDefault(setting.GetHashCode()), header, true ); } if (!foldout || showMap[setting.GetHashCode()]) { EditorGUI.indentLevel++; EditorGUILayout.BeginVertical("box"); setting.PresetSetting = UTGUI.Enum("Preset: ", setting.PresetSetting); var haspreset = setting.PresetSetting != PresetSettings.None; EditorGUI.BeginDisabledGroup(haspreset); setting.TextureType = UTGUI.Enum("TexType: ", setting.TextureType); if (setting.TextureType == TextureImporterType.Default) { setting.TextureShape = UTGUI.Enum("TexShape: ", setting.TextureShape); } // setting.AlphaIsTransparency = MaidEditorGUI.Toggle( // "Alpha Is Transparency?", // setting.AlphaIsTransparency // ); setting.MipMapEnable = UTGUI.Toggle( "MipMap?", setting.MipMapEnable ); setting.WrapMode = UTGUI.Enum("Wrap", setting.WrapMode); if (setting.AlphaMode != AlphaMode.Auto) { setting.OverrideAndroidFormat = UTGUI.Enum( "Android", setting.OverrideAndroidFormat ); setting.OverrideIOSFormat = UTGUI.Enum( "IOS", setting.OverrideIOSFormat ); setting.OverridePCFormat = UTGUI.Enum( "PC", setting.OverridePCFormat ); } EditorGUI.EndDisabledGroup(); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("box"); EditorGUI.BeginDisabledGroup(setting.TextureType != TextureImporterType.Sprite); setting.AtlasMode = UTGUI.Enum("AtlasMode: ", setting.AtlasMode); if (setting.AtlasMode == AtlasMode.Custom) { setting.PackingTag = UTGUI.Text("Atlas: ", setting.PackingTag); } EditorGUI.EndDisabledGroup(); setting.ReadWriteEnable = UTGUI.Toggle( "Readable?", setting.ReadWriteEnable ); // setting.SRGB = MaidEditorGUI.Toggle( // "sRGB?", // setting.SRGB // ); setting.FilterMode = UTGUI.Enum("Filter", setting.FilterMode); setting.MaxSize = UTGUI.Int("MaxSize", setting.MaxSize); setting.AlphaMode = UTGUI.Enum("AlphaMode", setting.AlphaMode); setting.NPOTScale = UTGUI.Enum("NPOT", setting.NPOTScale); // setting.Quality = MaidEditorGUI.Enum("Quality", setting.Quality); EditorGUILayout.EndVertical(); EditorGUI.indentLevel--; CheckPreset(setting); } }