Skip to content

Instantly share code, notes, and snippets.

@sunny352
Created October 30, 2020 03:38
Show Gist options
  • Save sunny352/a1ee93184f890b4633318b89014af0c9 to your computer and use it in GitHub Desktop.
Save sunny352/a1ee93184f890b4633318b89014af0c9 to your computer and use it in GitHub Desktop.
将Unity工程中图片都转换成crunchedCompression
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