- Home /
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,
Answer by ScienceIsAwesome · Jul 24, 2015 at 06:29 AM
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;
}
}
Answer by markv12 · Aug 23, 2020 at 06:40 AM
As of 2018.1 you can now specify default import settings for all sorts of assets using the Unity preset system: https://www.youtube.com/watch?v=RXDS0mAhtKw
Your answer
Follow this Question
Related Questions
How to create a GUI like Zombieville? 1 Answer
Texture input: changing format 1 Answer
Assigning UV Map to model at runtime 0 Answers
Sprite editor and texture 1 Answer