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