Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using UnityEngine;
using UnityEditor;
using System.IO;
// example PostProcessor for adjusting automatic Sprite Import settings
// save this in any "Editor" Folder
public class SpriteImportProcessor : AssetPostprocessor
void OnPostprocessSprites(Texture2D texture, Sprite[] sprites)
TextureImporter importer = assetImporter as TextureImporter;
// only change sprite import settings on first import, so we can change those settings for individual files
string name = importer.assetPath.ToLower();
if (File.Exists(AssetDatabase.GetTextMetaFilePathFromAssetPath(name)))
// adjust values for pixel art
importer.spritePixelsPerUnit = 100;
importer.mipmapEnabled = false;
importer.filterMode = FilterMode.Point;
importer.textureFormat = TextureImporterFormat.AutomaticTruecolor;
// access the TextureImporterSettings to change the spriteAlignment value
TextureImporterSettings textureSettings = new TextureImporterSettings();
textureSettings.spritePivot = new Vector2(0.5f, 0f);
textureSettings.spriteAlignment = (int)SpriteAlignment.BottomCenter;
Copy link

chuckbergeron commented Jul 1, 2016

Slick! Thanks for sharing this Stephan 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment