60 lines
1.8 KiB
C#
60 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace OctoberStudio.VAT
|
|
{
|
|
/// <summary>
|
|
/// 一个 VAT Atlas 上每段 clip 的元数据。
|
|
/// yStart/ySpan 是归一化到 [0,1] 的纵向区段 (= clipFrames / atlasHeight),
|
|
/// shader 通过它们计算 atlas 采样的 V 坐标。
|
|
/// </summary>
|
|
[Serializable]
|
|
public struct VATClipEntry
|
|
{
|
|
public string name;
|
|
public float yStart; // [0,1]
|
|
public float ySpan; // [0,1]
|
|
public float length; // seconds
|
|
public int frameCount;
|
|
public bool loop;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 一个角色一份。Bake atlas 时由工具自动生成,运行时由 VATAnimationController 引用。
|
|
/// </summary>
|
|
[CreateAssetMenu(menuName = "OctoberStudio/VAT/VAT Clip Database", fileName = "VATClipDatabase")]
|
|
public class VATClipDatabase : ScriptableObject
|
|
{
|
|
[Tooltip("整张 atlas 贴图。所有 clip 段沿 Y 轴堆叠。")]
|
|
public Texture2D atlas;
|
|
|
|
[Tooltip("所有动画段的元数据。")]
|
|
public List<VATClipEntry> clips = new List<VATClipEntry>();
|
|
|
|
public bool TryFind(string name, out VATClipEntry entry)
|
|
{
|
|
for (int i = 0; i < clips.Count; i++)
|
|
{
|
|
if (string.Equals(clips[i].name, name, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
entry = clips[i];
|
|
return true;
|
|
}
|
|
}
|
|
entry = default;
|
|
return false;
|
|
}
|
|
|
|
public int IndexOf(string name)
|
|
{
|
|
for (int i = 0; i < clips.Count; i++)
|
|
{
|
|
if (string.Equals(clips[i].name, name, StringComparison.OrdinalIgnoreCase))
|
|
return i;
|
|
}
|
|
return -1;
|
|
}
|
|
}
|
|
}
|