ICharacterDataProvider.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.Scripting.APIUpdating;
  4. namespace UnityEditor.U2D.Animation
  5. {
  6. /// <summary>An interface that allows Sprite Editor Modules to edit Character data for user custom importer.</summary>
  7. /// <remarks>Implement this interface for [[ScriptedImporter]] to leverage on Sprite Editor Modules to edit Character data.</remarks>
  8. [MovedFrom("UnityEditor.U2D.Experimental.Animation")]
  9. public interface ICharacterDataProvider
  10. {
  11. /// <summary>
  12. /// Returns the CharacterData structure that represents the Character composition.
  13. /// </summary>
  14. /// <returns>CharacterData data</returns>
  15. CharacterData GetCharacterData();
  16. /// <summary>
  17. /// Sets the CharacterData structure that represents to the data provider
  18. /// </summary>
  19. /// <param name="characterData">CharacterData to set</param>
  20. void SetCharacterData(CharacterData characterData);
  21. }
  22. /// <summary>
  23. /// Data structure that represents a character setup
  24. /// </summary>
  25. [Serializable]
  26. [MovedFrom("UnityEditor.U2D.Experimental.Animation")]
  27. public struct CharacterData
  28. {
  29. /// <summary>
  30. /// SpriteBones influencing the Character
  31. /// </summary>
  32. public UnityEngine.U2D.SpriteBone[] bones;
  33. /// <summary>
  34. /// Parts of the character
  35. /// </summary>
  36. public CharacterPart[] parts;
  37. /// <summary>
  38. /// The dimension of the character required
  39. /// </summary>
  40. public Vector2Int dimension;
  41. /// <summary>
  42. /// Character grouping information
  43. /// </summary>
  44. public CharacterGroup[] characterGroups;
  45. }
  46. internal interface ICharacterOrder
  47. {
  48. int order { get; set;}
  49. }
  50. /// <summary>
  51. /// Data structure representing CharacterPart grouping
  52. /// </summary>
  53. [Serializable]
  54. [MovedFrom("UnityEditor.U2D.Experimental.Animation")]
  55. public struct CharacterGroup : ICharacterOrder
  56. {
  57. /// <summary>
  58. /// Name of the CharacterGroup
  59. /// </summary>
  60. public string name;
  61. /// <summary>
  62. /// The parent group index it belongs to. Set to -1 if does not have a parent.
  63. /// </summary>
  64. public int parentGroup;
  65. [SerializeField]
  66. int m_Order;
  67. /// <summary>
  68. /// The order of the group in the list
  69. /// </summary>
  70. public int order
  71. {
  72. get => m_Order;
  73. set => m_Order = value;
  74. }
  75. }
  76. /// <summary>
  77. /// Data structure representing a character part
  78. /// </summary>
  79. [Serializable]
  80. [MovedFrom("UnityEditor.U2D.Experimental.Animation")]
  81. public struct CharacterPart : ICharacterOrder
  82. {
  83. /// <summary>
  84. /// Position for the Sprite in the character
  85. /// </summary>
  86. public RectInt spritePosition;
  87. /// <summary>
  88. /// Sprite ID
  89. /// </summary>
  90. public string spriteId;
  91. /// <summary>
  92. /// Bones influencing the Sprite
  93. /// </summary>
  94. public int[] bones;
  95. /// <summary>
  96. /// CharacterGroup that the part belongs to
  97. /// </summary>
  98. public int parentGroup;
  99. [SerializeField]
  100. int m_Order;
  101. /// <summary>
  102. /// The order of the part in the list
  103. /// </summary>
  104. public int order
  105. {
  106. get => m_Order;
  107. set => m_Order = value;
  108. }
  109. }
  110. }