mirror of
https://github.com/maxartz15/VertexAnimation.git
synced 2024-11-12 23:45:31 +01:00
max
5ac8db608e
BlobAsset creaton and testing BlobAssetStore. Start working on AnimationLibrary. Added animation looping based upon BlobAsset data.
51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
using Unity.Entities;
|
|
using Unity.Collections;
|
|
|
|
namespace TAO.VertexAnimation
|
|
{
|
|
[System.Serializable]
|
|
public struct VA_AnimationData
|
|
{
|
|
public int frames;
|
|
public int maxFrames;
|
|
}
|
|
|
|
public struct VA_AnimationDataBlobAsset
|
|
{
|
|
public BlobArray<VA_AnimationData> animations;
|
|
}
|
|
|
|
public class VA_AnimationDataBlobAssetConversionSystem : GameObjectConversionSystem
|
|
{
|
|
protected override void OnUpdate()
|
|
{
|
|
BlobAssetReference<VA_AnimationDataBlobAsset> animationDataBlobAssetRef;
|
|
|
|
// Blob builder to build.
|
|
using (BlobBuilder blobBuilder = new BlobBuilder(Allocator.Temp))
|
|
{
|
|
// Construct the root.
|
|
ref VA_AnimationDataBlobAsset animationDataBlobAsset = ref blobBuilder.ConstructRoot<VA_AnimationDataBlobAsset>();
|
|
|
|
// Set all the data.
|
|
BlobBuilderArray<VA_AnimationData> animationDataArray = blobBuilder.Allocate(ref animationDataBlobAsset.animations, 2);
|
|
for (int i = 0; i < animationDataArray.Length; i++)
|
|
{
|
|
animationDataArray[i] = new VA_AnimationData
|
|
{
|
|
frames = 36,
|
|
maxFrames = 43
|
|
};
|
|
}
|
|
|
|
// Construct blob asset reference.
|
|
animationDataBlobAssetRef = blobBuilder.CreateBlobAssetReference<VA_AnimationDataBlobAsset>(Allocator.Persistent);
|
|
|
|
UnityEngine.Debug.Log("Created: " + animationDataBlobAssetRef.Value.animations.Length.ToString());
|
|
}
|
|
|
|
// TODO: Generate Hash based on Guid.
|
|
BlobAssetStore.TryAdd(new Hash128("AnimationLib"), animationDataBlobAssetRef);
|
|
}
|
|
}
|
|
} |