Last active
May 23, 2023 05:12
-
-
Save GregLukosek/a4d859cd84ecb442fb21 to your computer and use it in GitHub Desktop.
Custom Texture Importer for Unity
This file contains hidden or 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
//Greg Lukosek 2015 | |
//[email protected] | |
using UnityEngine; | |
using UnityEditor; | |
public class TexturePostProcessor : AssetPostprocessor | |
{ | |
void OnPostprocessTexture(Texture2D texture) | |
{ | |
TextureImporter importer = assetImporter as TextureImporter; | |
importer.anisoLevel = 0; | |
importer.filterMode = FilterMode.Bilinear; | |
importer.mipmapEnabled = false; | |
importer.spritePixelsPerUnit = 1f; | |
importer.textureFormat = TextureImporterFormat.AutomaticTruecolor; | |
Object asset = AssetDatabase.LoadAssetAtPath(importer.assetPath, typeof(Texture2D)); | |
if (asset) { | |
EditorUtility.SetDirty(asset); | |
} | |
else { | |
texture.anisoLevel = 0; | |
texture.filterMode = FilterMode.Trilinear; | |
} | |
} | |
} |
This file contains hidden or 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
To use place it in Assets/Editor forlder in Unity. All imported textures will pick up the settings from the code automatically. | |
CDDL Licence, free to use, edit and share | |
Greg Lukosek | |
[email protected] | |
Twitter: @lukos86 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment