mirror of
https://github.com/maxartz15/VertexAnimation.git
synced 2024-11-09 22:32:55 +01:00
fix: multiple animators support
This commit is contained in:
parent
4499f67f31
commit
7741a1ef77
@ -18,9 +18,17 @@ namespace TAO.VertexAnimation
|
||||
private List<VA_Animation> loadedAnimationsPreview = null;
|
||||
#endif
|
||||
|
||||
public void Init()
|
||||
public Unity.Entities.Hash128 key;
|
||||
public string guid;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
// generate guid
|
||||
guid = System.Guid.NewGuid().ToString("N");
|
||||
key = new Unity.Entities.Hash128(guid);
|
||||
|
||||
animationData = new List<VA_AnimationData>();
|
||||
|
||||
|
||||
foreach (VA_AnimationBook book in animationBooks)
|
||||
{
|
||||
|
@ -1,5 +1,7 @@
|
||||
using Unity.Entities;
|
||||
using Unity.Collections;
|
||||
using Unity.Assertions;
|
||||
using System;
|
||||
|
||||
namespace TAO.VertexAnimation
|
||||
{
|
||||
@ -14,7 +16,7 @@ namespace TAO.VertexAnimation
|
||||
public class VA_AnimationLibraryConversionSystem : GameObjectConversionSystem
|
||||
{
|
||||
// Static because of multi scene setup.
|
||||
public static BlobAssetReference<VA_AnimationLibraryData> animLibAssetRef;
|
||||
//public static BlobAssetReference<VA_AnimationLibraryData> animLibAssetRef;
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
@ -43,17 +45,23 @@ namespace TAO.VertexAnimation
|
||||
}
|
||||
|
||||
// Construct blob asset reference.
|
||||
//BlobAssetReference<VA_AnimationLibraryData> animLibAssetRef = blobBuilder.CreateBlobAssetReference<VA_AnimationLibraryData>(Allocator.Persistent);
|
||||
// Static because of multi scene setup.
|
||||
animLibAssetRef = blobBuilder.CreateBlobAssetReference<VA_AnimationLibraryData>(Allocator.Persistent);
|
||||
BlobAssetReference<VA_AnimationLibraryData> animLibAssetRef = blobBuilder.CreateBlobAssetReference<VA_AnimationLibraryData>(Allocator.Persistent);
|
||||
|
||||
|
||||
// Add it to the asset store.
|
||||
BlobAssetStore.TryAdd(new Hash128(VA_AnimationLibraryUtils.AnimationLibraryAssetStoreName), animLibAssetRef);
|
||||
var anumLibName = animationLib.animationLibrary.name;
|
||||
|
||||
var hash = animationLib.animationLibrary.key;
|
||||
var result = BlobAssetStore.TryAdd(hash, animLibAssetRef);
|
||||
|
||||
if (animationLib.debugMode)
|
||||
{
|
||||
UnityEngine.Debug.Log("VA_AnimationLibrary has " + animLibAssetRef.Value.animations.Length.ToString() + " animations.");
|
||||
UnityEngine.Debug.Log($"blob asset {anumLibName} key: {hash.Value.x} {hash.Value.y} {hash.Value.z} {hash.Value.w} ");
|
||||
UnityEngine.Debug.Log($"VA_AnimationLibrary {anumLibName} has {animLibAssetRef.Value.animations.Length.ToString()} animations.");
|
||||
}
|
||||
|
||||
|
||||
Assert.IsTrue(result, $"{anumLibName} hasn't been added to the blob asset store");
|
||||
}
|
||||
|
||||
// Remove the entity since we don't need it anymore.
|
||||
|
@ -1,5 +1,7 @@
|
||||
using Unity.Entities;
|
||||
using Unity.Collections;
|
||||
using Unity.Assertions;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TAO.VertexAnimation
|
||||
{
|
||||
@ -40,7 +42,6 @@ namespace TAO.VertexAnimation
|
||||
|
||||
public static class VA_AnimationLibraryUtils
|
||||
{
|
||||
public const string AnimationLibraryAssetStoreName = "VA_AnimationLibrary";
|
||||
|
||||
public static int GetAnimation(ref VA_AnimationLibraryData animationsRef, FixedString64 animationName)
|
||||
{
|
||||
@ -52,6 +53,8 @@ namespace TAO.VertexAnimation
|
||||
}
|
||||
}
|
||||
|
||||
Debug.LogError($"{animationName} animation not found!");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ namespace TAO.VertexAnimation
|
||||
[DisallowMultipleComponent]
|
||||
public class VA_AnimatorComponentAuthoring : MonoBehaviour
|
||||
{
|
||||
|
||||
public VA_AnimationLibrary lib;
|
||||
}
|
||||
|
||||
//[GenerateAuthoringComponent]
|
||||
@ -25,12 +25,14 @@ namespace TAO.VertexAnimation
|
||||
{
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
//BlobAssetStore.TryGet(new Unity.Entities.Hash128(VA_AnimationLibraryUtils.AnimationLibraryAssetStoreName), out BlobAssetReference<VA_AnimationLibraryData> animLib);
|
||||
// Static because of multi scene setup.
|
||||
BlobAssetReference<VA_AnimationLibraryData> animLib = VA_AnimationLibraryConversionSystem.animLibAssetRef;
|
||||
//BlobAssetReference<VA_AnimationLibraryData> animLib = VA_AnimationLibraryConversionSystem.animLibAssetRef;
|
||||
|
||||
Entities.ForEach((VA_AnimatorComponentAuthoring animator) =>
|
||||
{
|
||||
|
||||
BlobAssetStore.TryGet(animator.lib.key, out BlobAssetReference<VA_AnimationLibraryData> animLib);
|
||||
|
||||
Entity entity = GetPrimaryEntity(animator);
|
||||
|
||||
// Add animator to 'parent'.
|
||||
|
Loading…
Reference in New Issue
Block a user