4.3 Asset optimizations
The following list describes asset optimizations:
- Disable Read/Write for static textures
- If you do not dynamically modify a texture, ensure the
Read/Write Enabled option in the
Inspector is disabled.
- Combine meshes to reduce draw calls
- To reduce the number of draw calls required for rendering 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 so it generates a single submesh out
of each mesh in the combine 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
One way to apply this technique is to create an empty game
object in the hierarchy, make it the parent of all the meshes that you want
to combine and then attach it to a script.
For more information on the mesh combine script, see the
Unity documentation at http://unity3d.com
- Do not import animations data on FBX mesh models that do not animate
- When importing an FBX mesh that does not contain any animation data, you
can set the Animation Type to None in the Rig tab of the
import settings. If this is set, placing your mesh into the hierarchy Unity does
not generate an unused animator component.
- Avoid Read/Write Meshes
- If your model is modified at runtime, Unity keeps a second copy of the mesh
data in memory to modify while preserving the original.
- If your model is not modified at run-time, even to be scaled, disable the
Read/Write Enabled option from the
Model tab of the import settings. A second copy is no
longer required so this saves memory.
- Use texture atlases
- You can use a texture atlas to reduce the number of draw calls required for
a set of objects.
- A texture atlas is a group of textures combined into one large
texture. Multiple objects can reuse this texture with an appropriate set of
coordinates. This helps with the automatic batching that Unity applies to
objects sharing the same material.
- When setting the UV texture coordinates of an object, avoid changing the
mainTextureOffset properties of its material. This
creates a new unique material that does not work with batching. Instead, access
the mesh data through the
and change the coordinates per vertex using the
- The following figure shows a texture atlas:
Figure 4-22 Texture atlas