diff --git a/Editor/Scripts/GLTFImporter.cs b/Editor/Scripts/GLTFImporter.cs index 88112dd68..f82eb6472 100644 --- a/Editor/Scripts/GLTFImporter.cs +++ b/Editor/Scripts/GLTFImporter.cs @@ -84,7 +84,8 @@ private static void EnsureShadersAreLoaded() [SerializeField] internal bool _importMaterials = true; [Tooltip("Enable this to get the same main asset identifiers as glTFast uses. This is recommended for new asset imports. Note that changing this for already imported assets will break their scene references and require manually re-adding the affected assets.")] [SerializeField] internal bool _useSceneNameIdentifier = false; - + [SerializeField] internal GLTFImporterTextureCompressionQuality _textureCompression = GLTFImporterTextureCompressionQuality.Best; + // for humanoid importer [SerializeField] internal bool m_OptimizeGameObjects = false; [SerializeField] internal HumanDescription m_HumanDescription = new HumanDescription(); @@ -114,6 +115,15 @@ internal class ExtensionInfo public bool used; public bool required; } + + // Matches TextureCompressionQuality and adds "None" as option + internal enum GLTFImporterTextureCompressionQuality + { + None = -50, + Fast = 0, + Normal = 50, + Best = 100 + } [Serializable] public class TextureInfo @@ -585,20 +595,24 @@ string GetUniqueName(string desiredName) } else { - ctx.AddObjectToAsset(GetUniqueName(tex.name), tex); if (invalidTextures.Contains(tex)) - tex.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector; + tex.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector; - // platform-dependant texture compression - var buildTargetName = BuildPipeline.GetBuildTargetName(ctx.selectedBuildTarget); - var format = TextureImporterHelper.GetAutomaticFormat(tex, buildTargetName); - var convertedFormat = (TextureFormat) (int) format; - if ((int) convertedFormat > -1) + if (_textureCompression != GLTFImporterTextureCompressionQuality.None) { - // Debug.Log("Compressing texture " + tex.name + "(format: " + tex.format + ", mips: " + tex.mipmapCount + ") to: " + convertedFormat); - EditorUtility.CompressTexture(tex, convertedFormat, TextureCompressionQuality.Best); - // Debug.Log("Mips now: " + tex.mipmapCount); // TODO figure out why mipmaps disappear here + // platform-dependant texture compression + var buildTargetName = BuildPipeline.GetBuildTargetName(ctx.selectedBuildTarget); + var format = TextureImporterHelper.GetAutomaticFormat(tex, buildTargetName); + var convertedFormat = (TextureFormat)(int)format; + if ((int)convertedFormat > -1) + { + // Debug.Log("Compressing texture " + tex.name + "(format: " + tex.format + ", mips: " + tex.mipmapCount + ") to: " + convertedFormat); + EditorUtility.CompressTexture(tex, convertedFormat, (TextureCompressionQuality) (int) _textureCompression); + // Debug.Log("Mips now: " + tex.mipmapCount); // TODO figure out why mipmaps disappear here + } } + + ctx.AddObjectToAsset(GetUniqueName(tex.name), tex); } } } diff --git a/Editor/Scripts/GLTFImporterInspector.cs b/Editor/Scripts/GLTFImporterInspector.cs index e94d4be70..56a392357 100644 --- a/Editor/Scripts/GLTFImporterInspector.cs +++ b/Editor/Scripts/GLTFImporterInspector.cs @@ -59,8 +59,6 @@ private void TextureWarningsGUI(GLTFImporter t) private void ModelInspectorGUI() { var t = target as GLTFImporter; - if (!t) EditorGUILayout.LabelField("NOOOO"); - if (!t) return; // serializedObject.Update(); @@ -75,10 +73,12 @@ private void ModelInspectorGUI() EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(GLTFImporter._scaleFactor))); // EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(GLTFImporter._maximumLod)), new GUIContent("Maximum Shader LOD")); EditorGUILayout.Separator(); + EditorGUILayout.LabelField("Meshes", EditorStyles.boldLabel); EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(GLTFImporter._readWriteEnabled)), new GUIContent("Read/Write")); EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(GLTFImporter._generateColliders))); EditorGUILayout.Separator(); + EditorGUILayout.LabelField("Geometry", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); var importNormalsProp = serializedObject.FindProperty(nameof(GLTFImporter._importNormals)); @@ -98,6 +98,8 @@ private void ModelInspectorGUI() EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(GLTFImporter._generateLightmapUVs)), new GUIContent("Generate Lightmap UVs")); EditorGUILayout.Separator(); + EditorGUILayout.LabelField("Compression", EditorStyles.boldLabel); + EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(GLTFImporter._textureCompression))); TextureWarningsGUI(t); }