A Custom Asset Importer for Unity

It is possible to change the default settings Unity imports assets. You can do so by utilizing the AssetImporter class supplied by the Unity scripting API. Better yet you can use different import settings per asset based on file name which is what I’ve been doing for a long time on many projects and it works great. Below is my custom asset importer, put it under an Editor folder and it will work automagically every time you import an asset, check out the verbose comments to understand what’s going on if you need to. Feel free to contact me for any questions. Enjoy!

 

10 Comments A Custom Asset Importer for Unity

    1. Sarper Soher

      Glad you liked it. Actually I’ve spotted a bug in the code and updated it accordingly.

      “if(!assetPath.Contains(“tex”)) return;”

      This line checks against the whole asset path, not just the filename. Thus even if you don’t prefix them with “tex” if they are under a folder called Textures for example at any point in their path, they will be processed as if they are prefixed.

      The fix is simple, get a substring of the path which represents just the filename and work with it. Check the updated code for the fix!

      Reply
  1. Eric

    Hey, I’ve been doing kind of the same things as you. But I find a bug there, if I set the animationType to Generic, even use EditorUtility.SetDirty(modelImporter). Then I found the model I import still using none in Animation type section. I’m not sure if it is a bug or just unity doesn’t update Inspector yet. Do you have any idea about this?

    Reply
  2. HawkX

    I am getting 4 errors when trying to use this…

    Unexpected symbol `=’ in class, struct

    for all 4 const at the begining…

    as well as 4 other “does not exist in current context” for :
    -webTextureSize
    -standaloneTextureSize
    -iosTextureSize
    -androidTextureSize

    I simply want all my jpg and png to import as sprite, single/clamped without having to change every one of them manually… (cause i have hundreds of them) and i dont have any 3d object with texture in my game so i dont need textures! 😛

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *