Hi, I’m trying to create an asset processor to make it much smoother when importing sprites (found at: https://unity3d.com/learn/tutorials/temas/scripting/ji-ben-edeitaturunozuo-cheng [page seems to be in Japanese]).
According to Unity, textureImporter.textureFormat is obsolete. Does anyone know how to change the texture format via script?
Thanks
This works :
using UnityEngine;
using UnityEditor;
public class DefaultImageImportSettings : AssetPostprocessor
{
public void OnPreprocessTexture ()
{
TextureImporter textureImporter = (TextureImporter) assetImporter;
if (assetPath.Contains("_bump"))
{
textureImporter.textureType = TextureImporterType.NormalMap;
textureImporter.convertToNormalmap = true;
// textureImporter.heightmapScale = 0.02f;
}
if (assetPath.Contains("_normal"))
{
textureImporter.textureType = TextureImporterType.NormalMap;
textureImporter.convertToNormalmap = false;
}
if (assetPath.Contains("_sprite"))
{
textureImporter.textureType = TextureImporterType.Sprite;
textureImporter.spritePackingTag = "TEST";
textureImporter.spriteImportMode = SpriteImportMode.Multiple;
}
if (assetPath.Contains("_gui"))
{
textureImporter.textureType = TextureImporterType.GUI;
}
if (assetPath.Contains("_cube"))
{
textureImporter.textureShape = TextureImporterShape.TextureCube;
}
if (assetPath.Contains("_diffuse"))
{
textureImporter.textureType = TextureImporterType.Default;
}
}
// public void OnPostprocessTexture (texture : Texture2D)
// {
//
// }
}