- Home /
OnPostprocessTexture TextureImporter.spritePivot doesn't seem to work.
Hi,
I am trying to set all sprites that are imported into my project as having a pivot in the bottom left corner of the sprite. This is trivial to do on the inspector and is a simple drop down 'Pivot' which has a selection dropdown of pivot points i.e. bottom left and top right.
In the OnPostprocessTexture funciton in a custom AssetPostprocessor, I am setting TextureImporter.spritePivot to Vector2.zero, assuming this to be bottom left but regardless all sprites still import with their pivot point set to center.
Am I doing something wrong?
Cheers
it sounds right. Judy edged to check if you increased the version number of the importer. if you didn't code everything in one go the importer is probably just not working right now
Answer by IshikiGames · Mar 05, 2017 at 02:18 PM
What I've asked for is done like this:
TextureImporterSettings texSettings = new TextureImporterSettings();
textureImporter.ReadTextureSettings(texSettings);
texSettings.spriteAlignment = (int)SpriteAlignment.Custom;
textureImporter.SetTextureSettings(texSettings);
Thanks again Unity for the trash API!