Asset optimizations

This section of the guide describes some asset optimizations that you can use in Unity as a game developer. Other asset optimizations are reviewed in the artists guides (see the Related information section).

 

Disable read or write for static textures

If you do not dynamically modify a texture, uncheck the Read or Write Enabled option in the Inspector window.

 

Combine meshes to reduce draw calls

You can combine several meshes into one with the Mesh.CombineMeshes()method. If the meshes all share the same material, set the mergeSubMeshes argument to true. The mergeSubMeshes argument then generates a single sub-mesh out of each mesh in the combined group.

Combining several meshes into a single larger mesh helps:

  • Create more effective occluders.
  • Turn tile-based assets into a single, large, seamless, solid asset.

The mesh combine script can be useful for performance optimization, but this depends on the makeup of your scene. Large meshes tend to stay in view longer than smaller meshes, so experiment to get the correct size.

You can combine some meshes directly, if they do not need to stay separate for programming or while the game is played. If you have meshes that need to stay separate, you can group the meshes rather than combine them:

  1. Create an empty game object in the hierarchy.
  2. Make the object the parent of all the meshes that you want to combine.
  3. Attach the parent to a script that includes the Mesh.CombineMeshes()method.

 

Do not import animations data on FBX mesh models unnecessarily

By default, when importing an FBX mesh Unity creates animation data, which increases the size of the imported object. If your object isn’t animated, it does not need this data. In Import Settings > Rag tab, for Animation Type select None so Unity doesn’t generate the animation data.

Another way that you can stop the animation is in the Animation tab, where you can clear the Import Animation checkbox.

 

Avoid read or write meshes

By default, Unity keeps a second copy of a model’s mesh data in memory to modify while preserving the original. Unity does this because it assumes that all models are modified at runtime. If your model is not modified at runtime, even to be scaled, in Import Settings > Model tab clear the Read or Write Enabled checkbox. Unity will not save a second copy, so memory use will be lower.

 

Use profiling to focus your optimizations

Profiling lets you focus your asset optimizations and compromises on the places that matter.

It may not be obvious which part of your scene needs optimization. For example, look at the following image from Spellsouls (by Nordeus), reviewed in a case study we published:

Example frame to profile 

The heaviest fragment shading is the terrain, because it covers the whole screen. We can see what optimizations make the most difference to this frame, for example a lower resolution lightmap, rendering the whole terrain at 720p instead of 1080p and blitting it in before the characters. The characters could continue to have high-resolution visuals because they were not using most of the frame time.

Previous Next