133 lines
3.1 KiB
C#
133 lines
3.1 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
|
||
namespace AibisDream.SystemEditor
|
||
{
|
||
// 帧数据
|
||
[Serializable]
|
||
public class FrameData
|
||
{
|
||
public string name;
|
||
public int x;
|
||
public int y;
|
||
public int width;
|
||
public int height;
|
||
public float duration; // 毫秒
|
||
}
|
||
|
||
// 动画片段数据
|
||
[Serializable]
|
||
public class AnimationData
|
||
{
|
||
public string name;
|
||
public List<int> frameIndices;
|
||
public bool loop;
|
||
public float? frameDuration; // 可选的,覆盖全局frameDuration
|
||
public int? sampleRate; // 可选的,覆盖全局sampleRate
|
||
}
|
||
|
||
// Aseprite JSON格式的数据结构
|
||
[Serializable]
|
||
public class AsepriteFrameInfo
|
||
{
|
||
public AsepriteFrameRect frame;
|
||
public bool rotated;
|
||
public bool trimmed;
|
||
public AsepriteFrameRect spriteSourceSize;
|
||
public AsepriteSize sourceSize;
|
||
public float duration; // 毫秒
|
||
}
|
||
|
||
[Serializable]
|
||
public class AsepriteFrameRect
|
||
{
|
||
public int x;
|
||
public int y;
|
||
public int w;
|
||
public int h;
|
||
}
|
||
|
||
[Serializable]
|
||
public class AsepriteSize
|
||
{
|
||
public int w;
|
||
public int h;
|
||
}
|
||
|
||
[Serializable]
|
||
public class AsepriteFrameTag
|
||
{
|
||
public string name;
|
||
public int from;
|
||
public int to;
|
||
public string direction;
|
||
}
|
||
|
||
[Serializable]
|
||
public class AsepriteMeta
|
||
{
|
||
public string app;
|
||
public string version;
|
||
public string image;
|
||
public string format;
|
||
public AsepriteSize size;
|
||
public string scale;
|
||
public List<AsepriteFrameTag> frameTags;
|
||
public List<object> layers;
|
||
public List<object> slices;
|
||
}
|
||
|
||
// Aseprite JSON的包装类(因为Unity JsonUtility不支持Dictionary)
|
||
[Serializable]
|
||
public class AsepriteFrameEntry
|
||
{
|
||
public string key;
|
||
public AsepriteFrameInfo value;
|
||
}
|
||
|
||
[Serializable]
|
||
public class AsepriteJsonData
|
||
{
|
||
public AsepriteMeta meta;
|
||
// frames将通过手动解析处理
|
||
}
|
||
|
||
// 手动JSON格式的数据结构
|
||
[Serializable]
|
||
public class ManualLayout
|
||
{
|
||
public int rows;
|
||
public int columns;
|
||
public int? frameCount; // 可选
|
||
public string direction; // "horizontal" 或 "vertical"
|
||
}
|
||
|
||
[Serializable]
|
||
public class ManualJsonData
|
||
{
|
||
public string type;
|
||
public ManualLayout layout;
|
||
public float frameDuration; // 毫秒
|
||
public int sampleRate;
|
||
public List<AnimationData> animations;
|
||
}
|
||
|
||
// 统一的内部数据格式
|
||
public class ProcessedAnimationData
|
||
{
|
||
public List<FrameData> frames;
|
||
public List<ProcessedAnimationClip> animations;
|
||
}
|
||
|
||
public class ProcessedAnimationClip
|
||
{
|
||
public string name;
|
||
public List<int> frameIndices;
|
||
public bool loop;
|
||
public float frameDuration; // 毫秒(已应用覆盖逻辑)
|
||
public int sampleRate; // 已应用覆盖逻辑
|
||
}
|
||
}
|
||
|