using System;
using UnityEngine;
using UnityEngine.Scripting.APIUpdating;
using UnityEngine.U2D;
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 SpriteBone[] bones;
///
/// Parts of the character
///
public CharacterPart[] parts;
///
/// The dimension of the character required
///
public Vector2Int dimension;
///
/// Character grouping information
///
public CharacterGroup[] characterGroups;
///
/// Bones are readonly
///
[Obsolete("boneReadOnly is no longer part of CharacterData. To check if character has Main Skeleton assigned to it, please use IMainSkeletonDataProvider instead.")]
public bool boneReadOnly;
}
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;
}
}
/// An interface that provides data from the Main Skeleton.
/// Available only when the Main Skeleton has been assigned.
public interface IMainSkeletonDataProvider
{
///
/// Returns Main Skeleton data.
///
/// MainSkeletonData data.
MainSkeletonData GetMainSkeletonData();
}
///
/// Data structure providing the Main Skeleton data.
///
public struct MainSkeletonData
{
///
/// Returns skeleton bones from the Main Skeleton asset.
///
public SpriteBone[] bones;
}
}