VertexAnimation/Runtime/Scripts/VA_AnimationLibraryData.cs
max ea1d2412b1 AnimationLibrary
AnimationLibraryBook editor setup.
AnimationLibrary AnimationData generation and material setup.
AnimationBook added support for non animation textures as well. This allows the user for example, to link Albedo maps with animations.
MaterialData is now in one component.
Note: Only 1/3th of the performance when having 4 swapping texture maps/arrays.
2020-12-14 20:27:44 +01:00

55 lines
1.5 KiB
C#

using Unity.Entities;
using Unity.Collections;
namespace TAO.VertexAnimation
{
[System.Serializable]
public struct VA_AnimationData
{
// The name of the animation.
public FixedString32 name;
// The frames in this animation.
public int frames;
// The maximum of frames the texture holds.
public int maxFrames;
// 1.0f / maxFrames.
public float frameTime;
// FrameTime * frames.
public float duration;
// The index of the related animation texture.
public int animationMapIndex;
// The index of the related color textures if/when added.
public int colorMapIndex;
}
public struct VA_AnimationLibraryData
{
public BlobArray<VA_AnimationData> animations;
}
public static class VA_AnimationLibraryUtils
{
public static int GetAnimation(ref VA_AnimationLibraryData animationsRef, FixedString32 animationName)
{
for (int i = 0; i < animationsRef.animations.Length; i++)
{
if (animationsRef.animations[i].name == animationName)
{
return i;
}
}
return -1;
}
public static int GetAnimationMapIndex(ref VA_AnimationLibraryData animationsRef, int animation)
{
return animationsRef.animations[animation].animationMapIndex;
}
public static int GetColorMapIndex(ref VA_AnimationLibraryData animationsRef, int animation)
{
return animationsRef.animations[animation].colorMapIndex;
}
}
}