Created
January 20, 2017 22:22
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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