2020-12-09 18:36:32 +01:00
|
|
|
|
using Unity.Entities;
|
|
|
|
|
using Unity.Collections;
|
|
|
|
|
|
|
|
|
|
namespace TAO.VertexAnimation
|
|
|
|
|
{
|
|
|
|
|
[UnityEngine.RequireComponent(typeof(ConvertToEntity))]
|
|
|
|
|
[UnityEngine.DisallowMultipleComponent]
|
|
|
|
|
public class VA_AnimationLibraryComponentAuthoring : UnityEngine.MonoBehaviour
|
|
|
|
|
{
|
2020-12-10 19:51:02 +01:00
|
|
|
|
public VA_AnimationLibrary animationLibrary;
|
2020-12-09 18:36:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class VA_AnimationLibraryConversionSystem : GameObjectConversionSystem
|
|
|
|
|
{
|
|
|
|
|
protected override void OnUpdate()
|
|
|
|
|
{
|
|
|
|
|
Entities.ForEach((VA_AnimationLibraryComponentAuthoring animationLib) =>
|
|
|
|
|
{
|
2020-12-21 23:19:05 +01:00
|
|
|
|
animationLib.animationLibrary.Init();
|
2020-12-10 19:51:02 +01:00
|
|
|
|
|
2020-12-09 18:36:32 +01:00
|
|
|
|
// Blob builder to build.
|
|
|
|
|
using (BlobBuilder blobBuilder = new BlobBuilder(Allocator.Temp))
|
|
|
|
|
{
|
|
|
|
|
// Construct the root.
|
2020-12-10 19:51:02 +01:00
|
|
|
|
ref VA_AnimationLibraryData animationDataBlobAsset = ref blobBuilder.ConstructRoot<VA_AnimationLibraryData>();
|
2020-12-09 18:36:32 +01:00
|
|
|
|
|
|
|
|
|
// Set all the data.
|
|
|
|
|
BlobBuilderArray<VA_AnimationData> animationDataArray = blobBuilder.Allocate(ref animationDataBlobAsset.animations, animationLib.animationLibrary.animations.Count);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < animationDataArray.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
// Copy data.
|
|
|
|
|
animationDataArray[i] = animationLib.animationLibrary.animations[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Construct blob asset reference.
|
2020-12-10 19:51:02 +01:00
|
|
|
|
BlobAssetReference<VA_AnimationLibraryData> animLibAssetRef = blobBuilder.CreateBlobAssetReference<VA_AnimationLibraryData>(Allocator.Persistent);
|
2020-12-09 18:36:32 +01:00
|
|
|
|
|
|
|
|
|
// Add it to the asset store.
|
2020-12-16 11:59:22 +01:00
|
|
|
|
BlobAssetStore.TryAdd(new Hash128(VA_AnimationLibraryUtils.AnimationLibraryAssetStoreName), animLibAssetRef);
|
2020-12-09 18:36:32 +01:00
|
|
|
|
|
|
|
|
|
UnityEngine.Debug.Log("VA_AnimationLibrary has " + animLibAssetRef.Value.animations.Length.ToString() + " animations.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove the entity since we don't need it anymore.
|
|
|
|
|
DstEntityManager.DestroyEntity(GetPrimaryEntity(animationLib));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|