Let your own components control the order of execution.

[Last updated: 01/22/2020]

This section describes the procedure for controlling the order of execution among other Cubism components for a user's own component.
The following explanation is based on the assumption that the model will be added to the project in which the [Importing SDK - Deploying Models] step was performed.



Some components in the Original Workflow of the Cubism SDK for Unity have restrictions on the order in which they are executed.

In Cubism SDK for Unity, this can be controlled by using CubismUpdateController, which controls the order of execution of the above components.
The component controlled by CubismUpdateController will be the component attached to the root of the Prefab of the Cubism model.

With CubismUpdateController, the user's own components can be controlled in the same order of execution.

As an example, this section describes the procedure for setting up execution order control for the following components.



1. Attach components to Prefab

Attach CubismExampleController to the GameObject at the root of the Prefab placed in the Hierarchy.
If Prefab is not imported in OW format, CubismUpdateController is also attached.



2. ICubismUpdatable is implemented in the component

Implement the ICubismUpdatable interface in the component that controls the execution order.

CubismUpdateController retrieves components that implement ICubismUpdatable at runtime and controls the order in which they are executed.


The ICubismUpdatable interface implemented here is as follows.


ExecutionOrder is the value that determines the order of execution for this component.
The smaller this value, the earlier it is called before other components.
The values set for the components included with the SDK are described in the CubismUpdateExecutionOrder.

HasUpdateController is a flag that allows components implementing ICubismUpdatable to be called from Unity event functions if the CubismUpdateController is not attached.




3. Make the component compatible with CubismUpdateController

Modify CubismExampleController as follows.


The update process performed by LateUpdate() is moved to OnLateUpdate(), which is called by CubismUpdateController.


This completes the setup for controlling the order of execution.
When this script is attached to the Prefab of the Cubism model and the scene is executed, the update process of this script is called by the CubismUpdateController.


© 2010 - 2022 Live2D Inc.