- Home /
How can I apply settings for a TextureImporter during post process?
I've written an importer for TexturePacker atlases for Unity 4.3 sprites. I've managed to nearly get it to where I want it, but I'm running into an issue. Whenever I change the texture/atlas and hop back to Unity, it will reimport the data, and call my OnPostprocessAllAssets.
Everything seems to go smoothly, but the sprites don't show up correctly immediately. If I change any of the importer settings, then change them back and hit apply, the sprites are perfect. (I can also go into the sprite editor, change something, hit undo, then apply.)
Clearly I'm missing something in the script that's happens when I hit apply. Any ideas? Can I force that apply myself in code? I'm hoping this is something easy I've overlooked in the documentation.
The source code for the importer is here.
In case this isn't clear enough, I've recorded a video demonstrating the problem.
Update: It looks like the problem is solved. As GameVortex answered below, I needed to call OnPreprocessTexture, rather than OnPostprocessAllAssets. The updated code is here.
Answer by GameVortex · Dec 03, 2013 at 10:46 AM
I believe your problem might come from the fact that you are using the OnPostprocessAllAssets function which gets called after the assets have been imported and therefore the modifications to the importer will not take effect until you hit apply.
I do not know how to get it to force an apply through code, but maybe you could use: OnPreprocessTexture instead? It gets called just before the asset gets imported so you can change the settings and they will be applied. This will happen to all textures though so remember to check for the correct one.
I think that's it. I switched over and it appears to work perfectly. Thanks!
I confirm that using OnPreprocessTexture works - remember to remove the arguments if you were using OnPostProcessTexture
Your answer
![](https://koobas.hobune.stream/wayback/20220613123306im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Custom texture importer 1 Answer
TextureImporter and AssetDatabase.ImportAsset 0 Answers
How do I change the Mip Bias of a Sprite Atlas? 1 Answer
Override texture import path 0 Answers
How do you change an asset's import settings at creation? 0 Answers