Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEditor;
- using UnityEngine;
- namespace ManaSeed.Editor
- {
- public class TexturePostProcessor : AssetPostprocessor
- {
- private void OnPostprocessTexture(Texture2D texture)
- {
- TextureImporter importer = assetImporter as TextureImporter;
- importer.spritePixelsPerUnit = 16;
- importer.wrapMode = TextureWrapMode.Clamp;
- importer.filterMode = FilterMode.Point;
- importer.textureCompression = TextureImporterCompression.Uncompressed;
- if (texture.width <= 32 && texture.height <= 32)
- importer.maxTextureSize = 32;
- else if (texture.width <= 64 && texture.height <= 64)
- importer.maxTextureSize = 64;
- else if (texture.width <= 128 && texture.height <= 128)
- importer.maxTextureSize = 128;
- else if (texture.width <= 256 && texture.height <= 256)
- importer.maxTextureSize = 256;
- else if (texture.width <= 512 && texture.height <= 512)
- importer.maxTextureSize = 512;
- else if (texture.width <= 1024 && texture.height <= 1024)
- importer.maxTextureSize = 1024;
- else if (texture.width <= 2048 && texture.height <= 2048)
- importer.maxTextureSize = 2048;
- else if (texture.width <= 4096 && texture.height <= 4096)
- importer.maxTextureSize = 4096;
- else if (texture.height <= 8192 && texture.height <= 8192)
- importer.maxTextureSize = 8192;
- else
- importer.maxTextureSize = 16384;
- Object asset = AssetDatabase.LoadAssetAtPath(importer.assetPath, typeof(Texture2D));
- if (asset)
- {
- EditorUtility.SetDirty(asset);
- }
- else
- {
- texture.anisoLevel = 0;
- texture.filterMode = FilterMode.Point;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement