Skip to content

Instantly share code, notes, and snippets.

@andyman
Created January 20, 2017 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andyman/4ff2dc2ab9e1b6807244aff698d0747b to your computer and use it in GitHub Desktop.
Save andyman/4ff2dc2ab9e1b6807244aff698d0747b to your computer and use it in GitHub Desktop.
Converts textures that end in _n or _normal to normal textures. Add this to your /Editor folder.
using UnityEditor;
using UnityEngine;
using System.Collections;
public class NormalTextureTextureProcessor : AssetPostprocessor {
void OnPostprocessTexture(Texture2D texture) {
string lowerCaseAssetPath = assetPath.ToLower();
if (lowerCaseAssetPath.IndexOf("_n.") >= 0
|| lowerCaseAssetPath.IndexOf("_n_pad.") >= 0
|| lowerCaseAssetPath.IndexOf("_normal.") >= 0
)
{
Debug.Log ("Recognizing normal image: " + assetPath);
TextureImporter importer = assetImporter as TextureImporter;
if (importer.textureType != TextureImporterType.NormalMap)
{
Debug.Log ("Fixing texture type to be normal");
importer.textureType = TextureImporterType.NormalMap;
importer.SaveAndReimport();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment