CubismExpressionPreview.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * Copyright(c) Live2D Inc. All rights reserved.
  3. *
  4. * Use of this source code is governed by the Live2D Open Software license
  5. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
  6. */
  7. using Live2D.Cubism.Core;
  8. using Live2D.Cubism.Framework.Expression;
  9. using UnityEngine;
  10. namespace Live2D.Cubism.Samples.OriginalWorkflow.Expression
  11. {
  12. public class CubismExpressionPreview : MonoBehaviour
  13. {
  14. /// <summary>
  15. /// ExpressionController to be operated.
  16. /// </summary>
  17. CubismExpressionController _expressionController;
  18. /// <summary>
  19. /// Get expression controller.
  20. /// </summary>
  21. private void Start()
  22. {
  23. var model = this.FindCubismModel();
  24. _expressionController = model.GetComponent<CubismExpressionController>();
  25. }
  26. /// <summary>
  27. /// Change facial expression.
  28. /// </summary>
  29. /// <param name="expressionIndex">index of facial expression to set.</param>
  30. public void ChangeExpression(int expressionIndex)
  31. {
  32. if (_expressionController != null)
  33. {
  34. _expressionController.CurrentExpressionIndex = expressionIndex;
  35. }
  36. }
  37. }
  38. }