using System.IO; using UnityEditor; using UnityEngine; public sealed class TexturePostprocessor : AssetPostprocessor { private void OnPreprocessTexture() { var importer = assetImporter as TextureImporter; importer.filterMode = FilterMode.Bilinear; importer.mipmapEnabled = false; importer.textureFormat = TextureImporterFormat.ARGB16; importer.textureType = TextureImporterType.Advanced; importer.wrapMode = TextureWrapMode.Clamp; var filename = Path.GetFileNameWithoutExtension(importer.assetPath); if (filename.EndsWith("_32")) { importer.textureFormat = TextureImporterFormat.ARGB32; } } }
グラデーションを使用しているテクスチャのフォーマットを
「Compressed」や「ARGB 16 bit」にすると綺麗に表示されないので
普段はグラデーションを使用しているテクスチャのフォーマットは
「ARGB 32 bit」で設定するようにデザイナーさんにお願いしているのですが
毎回Inspectorからグラデーションのテクスチャの設定を変更するのが面倒なので
最近は上記のようなクラスをEditorフォルダの階層に入れておいて
テクスチャのファイル名の末尾に「_32」と書いてある場合は
テクスチャのフォーマットを自動で「ARGB 32 bit」に変更するようにしています