Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.Scripting.APIUpdating;
  4. using UnityEngine.U2D;
  5. namespace UnityEditor.U2D.Animation
  6. {
  7. /// <summary>An interface that allows Sprite Editor Modules to edit Character data for user custom importer.</summary>
  8. /// <remarks>Implement this interface for [[ScriptedImporter]] to leverage on Sprite Editor Modules to edit Character data.</remarks>
  9. [MovedFrom("UnityEditor.U2D.Experimental.Animation")]
  10. public interface ICharacterDataProvider
  11. {
  12. /// <summary>
  13. /// Returns the CharacterData structure that represents the Character composition.
  14. /// </summary>
  15. /// <returns>CharacterData data</returns>
  16. CharacterData GetCharacterData();
  17. /// <summary>
  18. /// Sets the CharacterData structure that represents to the data provider
  19. /// </summary>
  20. /// <param name="characterData">CharacterData to set</param>
  21. void SetCharacterData(CharacterData characterData);
  22. }
  23. /// <summary>
  24. /// Data structure that represents a character setup
  25. /// </summary>
  26. [Serializable]
  27. [MovedFrom("UnityEditor.U2D.Experimental.Animation")]
  28. public struct CharacterData
  29. {
  30. /// <summary>
  31. /// SpriteBones influencing the Character
  32. /// </summary>
  33. public SpriteBone[] bones;
  34. /// <summary>
  35. /// Parts of the character
  36. /// </summary>
  37. public CharacterPart[] parts;
  38. /// <summary>
  39. /// The dimension of the character required
  40. /// </summary>
  41. public Vector2Int dimension;
  42. /// <summary>
  43. /// Character grouping information
  44. /// </summary>
  45. public CharacterGroup[] characterGroups;
  46. /// <summary>
  47. /// Character pivot. The value is a normalized value between (0,0) and (1,1) where (1,1) represents the value in CharacterData.dimension
  48. /// </summary>
  49. public Vector2 pivot;
  50. /// <summary>
  51. /// Bones are readonly
  52. /// </summary>
  53. [Obsolete("boneReadOnly is no longer part of CharacterData. To check if character has Main Skeleton assigned to it, please use IMainSkeletonDataProvider instead.")]
  54. public bool boneReadOnly;
  55. }
  56. internal interface ICharacterOrder
  57. {
  58. int order { get; set;}
  59. }
  60. /// <summary>
  61. /// Data structure representing CharacterPart grouping
  62. /// </summary>
  63. [Serializable]
  64. [MovedFrom("UnityEditor.U2D.Experimental.Animation")]
  65. public struct CharacterGroup : ICharacterOrder
  66. {
  67. /// <summary>
  68. /// Name of the CharacterGroup
  69. /// </summary>
  70. public string name;
  71. /// <summary>
  72. /// The parent group index it belongs to. Set to -1 if does not have a parent.
  73. /// </summary>
  74. public int parentGroup;
  75. [SerializeField]
  76. int m_Order;
  77. /// <summary>
  78. /// The order of the group in the list
  79. /// </summary>
  80. public int order
  81. {
  82. get => m_Order;
  83. set => m_Order = value;
  84. }
  85. }
  86. /// <summary>
  87. /// Data structure representing a character part
  88. /// </summary>
  89. [Serializable]
  90. [MovedFrom("UnityEditor.U2D.Experimental.Animation")]
  91. public struct CharacterPart : ICharacterOrder
  92. {
  93. /// <summary>
  94. /// Position for the Sprite in the character
  95. /// </summary>
  96. public RectInt spritePosition;
  97. /// <summary>
  98. /// Sprite ID
  99. /// </summary>
  100. public string spriteId;
  101. /// <summary>
  102. /// Bones influencing the Sprite
  103. /// </summary>
  104. public int[] bones;
  105. /// <summary>
  106. /// CharacterGroup that the part belongs to
  107. /// </summary>
  108. public int parentGroup;
  109. [SerializeField]
  110. int m_Order;
  111. /// <summary>
  112. /// The order of the part in the list
  113. /// </summary>
  114. public int order
  115. {
  116. get => m_Order;
  117. set => m_Order = value;
  118. }
  119. }
  120. /// <summary>An interface that provides data from the Main Skeleton.</summary>
  121. /// <remarks>Available only when the Main Skeleton has been assigned.</remarks>
  122. public interface IMainSkeletonDataProvider
  123. {
  124. /// <summary>
  125. /// Returns Main Skeleton data.
  126. /// </summary>
  127. /// <returns>MainSkeletonData data.</returns>
  128. MainSkeletonData GetMainSkeletonData();
  129. }
  130. /// <summary>
  131. /// Data structure providing the Main Skeleton data.
  132. /// </summary>
  133. public struct MainSkeletonData
  134. {
  135. /// <summary>
  136. /// Returns skeleton bones from the Main Skeleton asset.
  137. /// </summary>
  138. public SpriteBone[] bones;
  139. }
  140. }