Performance Tuning of Cubism SDK for Unity

Updated: 01/31/2020

Summary

Typically, performance tuning should be done using Unity’s profiler to check for heavy processing areas.

In the Cubism SDK, the structure of the model may affect its performance in the program.
In addition, because the Live2D SDK for Unity prioritizes clarity of structure, performance is intentionally sacrificed in some areas.
The following describes the impact of the SDK on performance.

Model Structure

Click here for details.

Project Structure

Unity event functions

As mentioned above, the Live2D SDK for Unity prioritizes clarity of structure.
Therefore, the update process for each component is handled from Unity event functions such as LateUpdate().
This Unity event function is costly to call.
If multiple models are displayed using the SDK as is, performance may be very poor depending on the execution environment.
If performance is important, it is recommended that the update process for each component be called from a single Controller.
The CubismUpdateController included with the Cubism SDK for Unity performs similar processing to control the order of execution of Cubism SDK components, so the CubismUpdateController implementation can be used as a reference if the above response is desired.

Click here for more information on CubismUpdateController.

Handling textures for masks

Textures for masks used in Cubism models share a single global texture.
In Unity, the reference is set to the CubismMaskController at the time the Prefab is generated.

However, if the model’s Prefab is made an AssetBundle as is, when the Prefab is instantiated, the texture for the mask set in the CubismMaskController changes from a reference to a copy being set.
Therefore, ignoring this specification will result in a memory drain as textures remain each time the model is repeatedly created and destroyed from the AssetBundle.

Click here for more information on this phenomenon and how to prevent it.

Please let us know what you think about this article.