- Home /
Texture input: changing format
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 :D
Answer by UnityCoach · Feb 15, 2017 at 11:02 PM
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)
// {
//
// }
}
Hi, I'm asking how to change the Format option shown here, I've tried all of your code and none of it seems to target this field.
][1]
Ah, it's all here in the TextureImporterPlatformSettings
You then pass it to SetPlatformTextureSettings(TextureImporterPlatformSettings platformSettings);
Your answer
Follow this Question
Related Questions
Combine Array of Sprites to Form One Sprite 0 Answers
3 general questions about sprite/texture 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers