페이드를 유효화하여 모션을 반복 재생(Animator)
업데이트: 2020/02/07
개요
Cubism Viewer for OW에서 모션을 루프 재생할 때, 「루프 재생 시의 페이드 인」에 체크가 되어 있었을 경우 모션이 종단으로부터 선두로 돌아올 때에 Cubism의 모션 페이드, 파라미터 페이드가 발생합니다.
참고: 「모션 설정」
그러나 Unity의 Animator에서 하나의 상태 머신 내에서 모션을 반복 재생하는 경우 MotionFade를 사용해도 끝에서 시작으로 돌아갈 때 페이드가 발생하지 않습니다.

AnimationClip을 루프 재생하는 경우 두 상태 머신을 왕복하도록 구성하여 루프 시에 페이드를 발생시킬 수 있습니다.
다음은 [SDK 가져오기]를 수행한 프로젝트에 대해 수행하는 것을 전제로 한 절차의 설명입니다.
- 모델에 CubismFadeController를 연결
- AnimationClip의 Loop Time의 체크를 해제
- AnimatorController 구축
1. 모델에 CubismFadeController를 연결
Scene에 배치한 Cubism의 Prefab의 루트가 되는 GameObject에 CubismFadeController를 연결합니다.
이미 연결되어 있으면 새로 연결할 필요가 없습니다.
CubismFadeController.CubismFadeMotion에 루프 재생할 AnimationClip의 ID가 등록된 .fadeMotionList를 설정합니다.

2. AnimationClip의 Loop Time 체크를 해제
루프 재생할 AnimationClip을 선택 상태로 하고 Inspector 창에서 「Loop Time」의 체크를 해제합니다.

3. AnimatorController를 구축
AnimatorController를 만들고 모델의 Animator 구성 요소에 설정합니다.

Animator 창에서 AnimatorController를 열고 그래프의 공란을 클릭하여 Inspector 창에서 CubismFadeStateObserver를 연결합니다.


그런 다음 동일한 레이어에 두 개의 상태 머신을 만듭니다.
작성한 상태 머신은 모두 2에서 「Loop Time」의 체크를 해제한 AnimationClip을 설정합니다.

마지막으로, 스테이트 머신을 오른쪽 클릭하고 「Make Transition」을 클릭해, 각각을 Transition으로 연결합니다.
여기서 Transition 설정은 Exit Time을 1, Transition Duration을 0으로 설정합니다.

이상으로 설정이 완료됩니다.
이 상태에서 장면을 재생하면 모션이 페이드하면서 루프 재생됩니다.
