In a class derived from AssetPostprocessor, I use this code to change some default settings when importing image assets:
void OnPreprocessTexture (){
TextureImporter textureImporter = (TextureImporter)assetImporter;
//This successfully turns off filtering for my pixel art
textureImporter.filterMode = FilterMode.Point;
//This sets alignment to top left for regular sprites (Sprite Mode=Single),
//but not if Sprite Mode = Multiple.
TextureImporterSettings texSettings = new TextureImporterSettings();
textureImporter.ReadTextureSettings(texSettings);
texSettings.spriteAlignment = (int)SpriteAlignment.TopLeft;
textureImporter.SetTextureSettings(texSettings);
}
However, this doesn't work for the sub-images when the sprite mode is "Multiple".
When I open the sprite editor, each sub-image seems to have its own alignment setting but I can't figure out how to access these with code.
↧