Created
October 30, 2020 03:38
-
-
Save sunny352/a1ee93184f890b4633318b89014af0c9 to your computer and use it in GitHub Desktop.
将Unity工程中图片都转换成crunchedCompression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
public class ImageProcessor : AssetPostprocessor | |
{ | |
private void OnPreprocessTexture() | |
{ | |
var importer = assetImporter as TextureImporter; | |
if (null == importer) | |
{ | |
return; | |
} | |
var needReimport = false; | |
if (!importer.crunchedCompression) | |
{ | |
importer.crunchedCompression = true; | |
importer.compressionQuality = 100; | |
needReimport = true; | |
} | |
if (importer.textureCompression != TextureImporterCompression.CompressedHQ) | |
{ | |
importer.textureCompression = TextureImporterCompression.CompressedHQ; | |
needReimport = true; | |
} | |
if (needReimport) | |
{ | |
importer.SaveAndReimport(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment