Setting Sprite pixel per unit on importation

Hey guys,

I need to set my Texture pixel per unit to 1 on importation so that all my imported texture has it set to 1 but I can’t seem to find a way to access it via the AssetPostprocessor and set it. On the sprite itself, there is only a getter on the property. Does anybody has an idea ?

Thanks a lot,

I couldn’t find a setting for this in the Unity Editor so I guess you have to do it through scripting. This script will force spritePixelsPerUnit = 1 for all textures on import, in case they are ever turned into sprites:

using UnityEngine;
using UnityEditor;

public class SpritePixelsPerUnitChanger : AssetPostprocessor
{
	void OnPreprocessTexture ()
	{
		TextureImporter textureImporter  = (TextureImporter) assetImporter;
		textureImporter.spritePixelsPerUnit = 1;
	}
}

As of 2018.1 you can now specify default import settings for all sorts of assets using the Unity preset system: