Automating Unity3D assets import.

Gamedev involve several devs, who are people akin to making mistakes,that in turn increase dev cost time. Importing assets is no joke. Let's see if we can write tools to prevent common, costly errors.

Originally posted at my blog


Games aren’t always made by a one-man-team but involve several developers, who are people akin to making mistakes,that in turn increase dev cost time. Importing assets is no joke, with the default settings and different rules for different parts of your project, let’s start with this premise and ask ourselves: “can we write tools to prevent common, costly mistakes ?”

the answer is yes and let’s discover one cool Unity3D Class.


the AssetPostProcessor class receive callbacks on importing something. it implements OnPreProcess* and OnPostProcess* methods and apply your rules to the assetImporter instance. therefore we can write rules that prevent some common mistakes, let’s take textures for instance, we can ensure:

  • setting the texture type (default, sprite, etc..)
  • making sure Read/Write is disabled.
  • disabling mipmaps for anything that is 2D or UI (it is enabled by default).
  • forcing a max texture size
public class AssetImportSample : AssetPostprocessor {

    void OnPreprocessTexture()
        if (assetPath.Contains("_UI") || assetPath.Contains("_Sprite"))
            TextureImporter textureImporter = (TextureImporter)assetImporter;
            textureImporter.textureType = TextureImporterType.Sprite;
            textureImporter.spriteImportMode = SpriteImportMode.Multiple;
            textureImporter.mipmapEnabled = false; // we don't need mipmaps for 2D/UI Atlases

            if (textureImporter.isReadable)
                textureImporter.isReadable = false; // make sure Read/Write is disabled
            textureImporter.maxTextureSize = 1024; // force a max texture size
            Debug.Log("UI/Sprite Audit Complete");

Now with the above script, is it easier for the team to comply to naming conventions rather than cherrypick settings for different parts of a project.

we can also implement the same OnPreprocessModel() method for meshes to audit some common errors:

• Make sure Read/Write is disabled

• Disabling rig on non-character models (it fixes the auto added Animator component)

• Copy avatars for characters with shared rigs

• Enable mesh compression

and of course, also applies for Audio.



Latest Jobs

Cryptic Studios

Senior Producer

Night School Studio

Los Angeles, CA, USA
Level Designer / Scripter, Games Studio

Fast Travel Games

Hybrid (Stockholm, Sweden)
Social Media / Community Manager
More Jobs   


Explore the
Subscribe to
Follow us

Game Developer Job Board

Game Developer Newsletter


Explore the

Game Developer Job Board

Browse open positions across the game industry or recruit new talent for your studio

Subscribe to

Game Developer Newsletter

Get daily Game Developer top stories every morning straight into your inbox

Follow us


Follow us @gamedevdotcom to stay up-to-date with the latest news & insider information about events & more