- Home /
Only PostProcess/PreProcess on new assets
I only want to process new art that hasn't been added before. However when I switch platforms, or do something that re-imports everything, it processes everything again! How can I stop this from happening?
In case anyone else is wondering, I temporary solved it by the user defined tag in assetProcessor stored in the meta files. For new assets I store them, and before that I did check before I reprocess them.
Answer by csalzman · Aug 09, 2016 at 07:21 AM
For those who run across this in the future, the following answer really helped me out. The key is to do a check to see if there's an asset currently at the assetPath of the new asset. If not, then you can do you're processing:
http://answers.unity3d.com/answers/468255/view.html
Here's the OnPreprocessTexture function I'm running:
void OnPreprocessTexture () {
//Get the TextureImporter
TextureImporter import = assetImporter as TextureImporter;
Object asset = AssetDatabase.LoadAssetAtPath(import.assetPath, typeof(Texture2D));
if (!asset) {
Debug.Log("NEW");
//Set it to a Sprite
import.textureType = TextureImporterType.Sprite;
//Set to 1 pixel per unit
import.spritePixelsPerUnit = 1;
//etc.
}
else {
Debug.Log("OLD");
}
}