using System;
using UnityEngine;
using UnityEngine.Scripting.APIUpdating;
namespace UnityEditor.U2D.Animation
{
/// An interface that allows Sprite Editor Modules to edit Character data for user custom importer.
/// Implement this interface for [[ScriptedImporter]] to leverage on Sprite Editor Modules to edit Character data.
[MovedFrom("UnityEditor.U2D.Experimental.Animation")]
public interface ICharacterDataProvider
{
///
/// Returns the CharacterData structure that represents the Character composition.
///
/// CharacterData data
CharacterData GetCharacterData();
///
/// Sets the CharacterData structure that represents to the data provider
///
/// CharacterData to set
void SetCharacterData(CharacterData characterData);
}
///
/// Data structure that represents a character setup
///
[Serializable]
[MovedFrom("UnityEditor.U2D.Experimental.Animation")]
public struct CharacterData
{
///
/// SpriteBones influencing the Character
///
public UnityEngine.U2D.SpriteBone[] bones;
///
/// Parts of the character
///
public CharacterPart[] parts;
///
/// The dimension of the character required
///
public Vector2Int dimension;
///
/// Character grouping information
///
public CharacterGroup[] characterGroups;
}
internal interface ICharacterOrder
{
int order { get; set;}
}
///
/// Data structure representing CharacterPart grouping
///
[Serializable]
[MovedFrom("UnityEditor.U2D.Experimental.Animation")]
public struct CharacterGroup : ICharacterOrder
{
///
/// Name of the CharacterGroup
///
public string name;
///
/// The parent group index it belongs to. Set to -1 if does not have a parent.
///
public int parentGroup;
[SerializeField]
int m_Order;
///
/// The order of the group in the list
///
public int order
{
get => m_Order;
set => m_Order = value;
}
}
///
/// Data structure representing a character part
///
[Serializable]
[MovedFrom("UnityEditor.U2D.Experimental.Animation")]
public struct CharacterPart : ICharacterOrder
{
///
/// Position for the Sprite in the character
///
public RectInt spritePosition;
///
/// Sprite ID
///
public string spriteId;
///
/// Bones influencing the Sprite
///
public int[] bones;
///
/// CharacterGroup that the part belongs to
///
public int parentGroup;
[SerializeField]
int m_Order;
///
/// The order of the part in the list
///
public int order
{
get => m_Order;
set => m_Order = value;
}
}
}