Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

EditorUtility.CompressTexture

static function CompressTexture(texture: Texture2D, format: TextureFormat, quality: int): void;
static void CompressTexture(Texture2D texture, TextureFormat format, int quality);
static def CompressTexture(texture as Texture2D, format as TextureFormat, quality as int) as void
static function CompressTexture(texture: Texture2D, format: TextureFormat, quality: TextureCompressionQuality): void;
static void CompressTexture(Texture2D texture, TextureFormat format, TextureCompressionQuality quality);
static def CompressTexture(texture as Texture2D, format as TextureFormat, quality as TextureCompressionQuality) as void

Description

Compress a texture.

Use this function to explicitly compress a texture into specified format.

If you want to do texture compression in-game, use Texture2D.Compress function, which will use faster but lower quality DXT compression.

	// Automatically Compress all imported textures to the project
	// to RGB24

class MyTexturePostprocessor extends AssetPostprocessor { function OnPostprocessTexture (t : Texture2D) { EditorUtility.CompressTexture(t, TextureFormat.RGB24); } }