/**
* Does two things:
* 1 - Changes the NPOT strategy to "ToNearest";
* 2 - Changes the compression to DXT1 or DXT5 if compression is set to something different than DTX1.
* It only changes the meta file of the texture.
*/
static void DxtCompressTexture(TextureImporter textureImporter)
{
TextureImporterFormat format;
TextureImporterSettings textureImporterSettings = new TextureImporterSettings();
textureImporter.ReadTextureSettings(textureImporterSettings);
format = textureImporterSettings.textureFormat;
if (format != TextureImporterFormat.DXT1)
{
if (textureImporter.DoesSourceTextureHaveAlpha())
format = TextureImporterFormat.DXT5;
else
format = TextureImporterFormat.DXT1;
}
textureImporter.npotScale = TextureImporterNPOTScale.ToNearest;
textureImporterSettings.textureFormat = format;
textureImporter.SetTextureSettings(textureImporterSettings);
}