Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ICharacterDataProvider.cs 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. /// Bones are readonly
  48. /// </summary>
  49. [Obsolete("boneReadOnly is no longer part of CharacterData. To check if character has Main Skeleton assigned to it, please use IMainSkeletonDataProvider instead.")]
  50. public bool boneReadOnly;
  51. }
  52. internal interface ICharacterOrder
  53. {
  54. int order { get; set;}
  55. }
  56. /// <summary>
  57. /// Data structure representing CharacterPart grouping
  58. /// </summary>
  59. [Serializable]
  60. [MovedFrom("UnityEditor.U2D.Experimental.Animation")]
  61. public struct CharacterGroup : ICharacterOrder
  62. {
  63. /// <summary>
  64. /// Name of the CharacterGroup
  65. /// </summary>
  66. public string name;
  67. /// <summary>
  68. /// The parent group index it belongs to. Set to -1 if does not have a parent.
  69. /// </summary>
  70. public int parentGroup;
  71. [SerializeField]
  72. int m_Order;
  73. /// <summary>
  74. /// The order of the group in the list
  75. /// </summary>
  76. public int order
  77. {
  78. get => m_Order;
  79. set => m_Order = value;
  80. }
  81. }
  82. /// <summary>
  83. /// Data structure representing a character part
  84. /// </summary>
  85. [Serializable]
  86. [MovedFrom("UnityEditor.U2D.Experimental.Animation")]
  87. public struct CharacterPart : ICharacterOrder
  88. {
  89. /// <summary>
  90. /// Position for the Sprite in the character
  91. /// </summary>
  92. public RectInt spritePosition;
  93. /// <summary>
  94. /// Sprite ID
  95. /// </summary>
  96. public string spriteId;
  97. /// <summary>
  98. /// Bones influencing the Sprite
  99. /// </summary>
  100. public int[] bones;
  101. /// <summary>
  102. /// CharacterGroup that the part belongs to
  103. /// </summary>
  104. public int parentGroup;
  105. [SerializeField]
  106. int m_Order;
  107. /// <summary>
  108. /// The order of the part in the list
  109. /// </summary>
  110. public int order
  111. {
  112. get => m_Order;
  113. set => m_Order = value;
  114. }
  115. }
  116. /// <summary>An interface that provides data from the Main Skeleton.</summary>
  117. /// <remarks>Available only when the Main Skeleton has been assigned.</remarks>
  118. public interface IMainSkeletonDataProvider
  119. {
  120. /// <summary>
  121. /// Returns Main Skeleton data.
  122. /// </summary>
  123. /// <returns>MainSkeletonData data.</returns>
  124. MainSkeletonData GetMainSkeletonData();
  125. }
  126. /// <summary>
  127. /// Data structure providing the Main Skeleton data.
  128. /// </summary>
  129. public struct MainSkeletonData
  130. {
  131. /// <summary>
  132. /// Returns skeleton bones from the Main Skeleton asset.
  133. /// </summary>
  134. public SpriteBone[] bones;
  135. }
  136. }