CubismExp3Json.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 System;
  8. using UnityEngine;
  9. namespace Live2D.Cubism.Framework.Json
  10. {
  11. /// <summary>
  12. /// Cubism exp3.json data.
  13. /// </summary>
  14. [Serializable]
  15. public sealed class CubismExp3Json
  16. {
  17. #region Load Methods
  18. /// <summary>
  19. /// Loads a exp3.json asset.
  20. /// </summary>
  21. /// <param name="exp3Json">exp3.json to deserialize.</param>
  22. /// <returns>Deserialized exp3.json on success; <see langword="null"/> otherwise.</returns>
  23. public static CubismExp3Json LoadFrom(string exp3Json)
  24. {
  25. return (string.IsNullOrEmpty(exp3Json))
  26. ? null
  27. : JsonUtility.FromJson<CubismExp3Json>(exp3Json);
  28. }
  29. /// <summary>
  30. /// Loads a exp3.json asset.
  31. /// </summary>
  32. /// <param name="exp3JsonAsset">exp3.json to deserialize.</param>
  33. /// <returns>Deserialized exp3.json on success; <see langword="null"/> otherwise.</returns>
  34. public static CubismExp3Json LoadFrom(TextAsset exp3JsonAsset)
  35. {
  36. return (exp3JsonAsset == null)
  37. ? null
  38. : LoadFrom(exp3JsonAsset.text);
  39. }
  40. #endregion
  41. #region Json Data
  42. /// <summary>
  43. /// Expression Type
  44. /// </summary>
  45. [SerializeField]
  46. public string Type;
  47. /// <summary>
  48. /// Expression FadeInTime
  49. /// </summary>
  50. [SerializeField]
  51. public float FadeInTime = 1.0f;
  52. /// <summary>
  53. /// Expression FadeOutTime
  54. /// </summary>
  55. [SerializeField]
  56. public float FadeOutTime = 1.0f;
  57. /// <summary>
  58. /// Expression Parameters
  59. /// </summary>
  60. [SerializeField]
  61. public SerializableExpressionParameter[] Parameters;
  62. #endregion
  63. #region Json Helpers
  64. /// <summary>
  65. /// Expression Parameter
  66. /// </summary>
  67. [Serializable]
  68. public struct SerializableExpressionParameter
  69. {
  70. /// <summary>
  71. /// Expression Parameter Id
  72. /// </summary>
  73. [SerializeField]
  74. public string Id;
  75. /// <summary>
  76. /// Expression Parameter Value
  77. /// </summary>
  78. [SerializeField]
  79. public float Value;
  80. /// <summary>
  81. /// Expression Parameter Blend Mode
  82. /// </summary>
  83. [SerializeField]
  84. public string Blend;
  85. }
  86. #endregion
  87. }
  88. }