public static void Resize(GameDatabase.TextureInfo texture, int width, int height, bool mipmaps, bool convertToNormalFormat)
{
ActiveTextureManagement.DBGLog("Resizing...");
Texture2D tex = texture.texture;
TextureFormat format = tex.format;
if (texture.isNormalMap)
{
format = TextureFormat.ARGB32;
}
else if (format == TextureFormat.DXT1 || format == TextureFormat.RGB24)
{
format = TextureFormat.RGB24;
}
else
{
format = TextureFormat.RGBA32;
}
Color32[] pixels = tex.GetPixels32();
if (convertToNormalFormat)
{
ConvertToUnityNormalMap(pixels);
}
Color32[] newPixels = ResizePixels(pixels, tex.width, tex.height, width, height);
tex.Resize(width, height, format, mipmaps);
tex.SetPixels32(newPixels);
tex.Apply(mipmaps);
}