CubismUpdateController

[Last update: 10/21/2020]

Summary

By attaching CubismUpdateController to Prefab, you can control the order of execution of each component of Cubism SDK for Unity.

Since the order of execution of each component is important in the OW method, it is essential to use CubismUpdateController to follow the specification.
If you do not use CubismUpdateController, for example, because you do not need to control the order of execution, functions such as Expression may not be processed correctly depending on the order of execution because the order in which components are executed is determined by Unity.

To control the order of execution of user-created components, implement ICubismUpdateable on the component.

 

Implementation of ICubismUpdateable

The ICubismUpdateable interface is inherited by the component that controls the execution order.

If CubismUpdateController is not attached, the OnLateUpdate process will not be executed, so the following snippet allows that component to work by itself.

  • HasUpdateController
    • Sets whether CubismUpdateController is attached to the Prefab.
  • NeedsUpdateOnEditing
    • Returns whether the scene needs to be updated while it is not running in Unity.
      Since CubismUpdateController also runs in editor mode, it returns false if the component does not need to be updated even when it is not running.
  • ExecutionOrder
    • Returns the order of execution of its components.
      The component with the smaller value is called first.
      The execution order of each component in Cubism SDK for Unity is defined in CubismUpdateExecutoinOrder.
    •  If the user has added a component that controls the order of execution, refer to the definition of CubismUpdateExecutoinOrder and note when it is called by the value returned here.
      • Example (if you want to call your own component at a time between CubismLookController and CubismPhysicsController):
        • CubismLookController is set to 700 and CubismPhysicsController is set to 800, so set your own component to return 750.
  • OnLateUpdate()
    • This function is called by CubismUpdateController in a controlled execution order.
      Describe the update process to be performed by that component.

 

Caution when adding or removing components during execution

The component that controls the order of execution by CubismUpdateController does so at the timing of OnEnable().
If all components are pre-attached to the Prefab, there is no problem, but if you dynamically add or remove components during scene execution, you must explicitly call CubismUpdateController.Refresh() to reload them.

© 2010 - 2022 Live2D Inc.