mirror of
				https://github.com/maxartz15/VertexAnimation.git
				synced 2025-11-04 02:15:59 +01:00 
			
		
		
		
	Auto fill, const asset store name
Auto fill, const asset store name.
This commit is contained in:
		@@ -1,5 +0,0 @@
 | 
			
		||||
using UnityEngine;
 | 
			
		||||
 | 
			
		||||
namespace TAO.VertexAnimation
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
@@ -1,11 +0,0 @@
 | 
			
		||||
fileFormatVersion: 2
 | 
			
		||||
guid: 1d191fd2694a80142aaa155c49b1b8ae
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
  defaultReferences: []
 | 
			
		||||
  executionOrder: 0
 | 
			
		||||
  icon: {instanceID: 0}
 | 
			
		||||
  userData: 
 | 
			
		||||
  assetBundleName: 
 | 
			
		||||
  assetBundleVariant: 
 | 
			
		||||
@@ -4,7 +4,7 @@ using UnityEngine;
 | 
			
		||||
 | 
			
		||||
namespace TAO.VertexAnimation
 | 
			
		||||
{
 | 
			
		||||
    [CreateAssetMenu(fileName = "new AnimationBook", menuName = "AnimationBook", order = 0)]
 | 
			
		||||
    [CreateAssetMenu(fileName = "new AnimationBook", menuName = "VA_Animation/AnimationBook", order = 400)]
 | 
			
		||||
    public class VA_AnimationBook : ScriptableObject
 | 
			
		||||
    {
 | 
			
		||||
        public int maxFrames;
 | 
			
		||||
@@ -149,6 +149,40 @@ namespace TAO.VertexAnimation
 | 
			
		||||
 | 
			
		||||
            return -1;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Auto fill names and frames.
 | 
			
		||||
        public void AutoFill()
 | 
			
		||||
        {
 | 
			
		||||
            if (animationPages != null)
 | 
			
		||||
            {
 | 
			
		||||
                for (int i = 0; i < animationPages.Count; i++)
 | 
			
		||||
                {
 | 
			
		||||
                    VA_AnimationPage ap = animationPages[i];
 | 
			
		||||
                    if (ap.textures != null && ap.textures.Count > 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        string textureName = ap.textures[0].texture2D.name;
 | 
			
		||||
 | 
			
		||||
                        string[] parts = textureName.Split('_');
 | 
			
		||||
 | 
			
		||||
                        foreach (var p in parts)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (p.StartsWith("N-"))
 | 
			
		||||
                            {
 | 
			
		||||
                                ap.name = p.Remove(0, 2);
 | 
			
		||||
                            }
 | 
			
		||||
                            else if (p.StartsWith("F-"))
 | 
			
		||||
                            {
 | 
			
		||||
                                if(int.TryParse(p.Remove(0, 2), out int frames))
 | 
			
		||||
                                {
 | 
			
		||||
                                    ap.frames = frames;
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    animationPages[i] = ap;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [System.Serializable]
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@ using UnityEngine;
 | 
			
		||||
 | 
			
		||||
namespace TAO.VertexAnimation
 | 
			
		||||
{
 | 
			
		||||
	[CreateAssetMenu(fileName = "new AnimationLibrary", menuName = "AnimationLibrary", order = 0)]
 | 
			
		||||
	[CreateAssetMenu(fileName = "new AnimationLibrary", menuName = "VA_Animation/AnimationLibrary", order = 400)]
 | 
			
		||||
	public class VA_AnimationLibrary : ScriptableObject
 | 
			
		||||
	{
 | 
			
		||||
		[SerializeField]
 | 
			
		||||
 
 | 
			
		||||
@@ -38,8 +38,7 @@ namespace TAO.VertexAnimation
 | 
			
		||||
					BlobAssetReference<VA_AnimationLibraryData> animLibAssetRef = blobBuilder.CreateBlobAssetReference<VA_AnimationLibraryData>(Allocator.Persistent);
 | 
			
		||||
 | 
			
		||||
					// Add it to the asset store.
 | 
			
		||||
					// TODO: Generate Hash based on Guid.
 | 
			
		||||
					BlobAssetStore.TryAdd(new Hash128("AnimationLib"), animLibAssetRef);
 | 
			
		||||
					BlobAssetStore.TryAdd(new Hash128(VA_AnimationLibraryUtils.AnimationLibraryAssetStoreName), animLibAssetRef);
 | 
			
		||||
 | 
			
		||||
					UnityEngine.Debug.Log("VA_AnimationLibrary has " + animLibAssetRef.Value.animations.Length.ToString() + " animations.");
 | 
			
		||||
				}
 | 
			
		||||
 
 | 
			
		||||
@@ -29,6 +29,8 @@ namespace TAO.VertexAnimation
 | 
			
		||||
 | 
			
		||||
    public static class VA_AnimationLibraryUtils
 | 
			
		||||
	{
 | 
			
		||||
		public const string AnimationLibraryAssetStoreName = "VA_AnimationLibrary";
 | 
			
		||||
 | 
			
		||||
        public static int GetAnimation(ref VA_AnimationLibraryData animationsRef, FixedString32 animationName)
 | 
			
		||||
        {
 | 
			
		||||
            for (int i = 0; i < animationsRef.animations.Length; i++)
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ namespace TAO.VertexAnimation
 | 
			
		||||
	{
 | 
			
		||||
		protected override void OnUpdate()
 | 
			
		||||
		{
 | 
			
		||||
			BlobAssetStore.TryGet(new Unity.Entities.Hash128("AnimationLib"), out BlobAssetReference<VA_AnimationLibraryData> animLib);
 | 
			
		||||
			BlobAssetStore.TryGet(new Unity.Entities.Hash128(VA_AnimationLibraryUtils.AnimationLibraryAssetStoreName), out BlobAssetReference<VA_AnimationLibraryData> animLib);
 | 
			
		||||
 | 
			
		||||
			Entities.ForEach((VA_AnimatorComponentAuthoring animator) =>
 | 
			
		||||
			{
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user