mirror of
https://github.com/maxartz15/VertexAnimation.git
synced 2024-11-12 15:35:30 +01:00
Auto fill, const asset store name
Auto fill, const asset store name.
This commit is contained in:
parent
ea1d2412b1
commit
b285831ef7
@ -1,6 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace TAO.VertexAnimation.Editor
|
||||
{
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a3fe61ae09e60f488649e570a04e071
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -176,6 +176,11 @@ namespace TAO.VertexAnimation.Editor
|
||||
{
|
||||
animationPages.InsertArrayElementAtIndex(animationPages.arraySize);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("auto fill", EditorStyles.miniButton))
|
||||
{
|
||||
animationBook.AutoFill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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) =>
|
||||
{
|
||||
|
8
Samples~/Example1.meta
Normal file
8
Samples~/Example1.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb128807d44bec847a9f9d1c4aafb5b1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Samples~/Example1/Animations.meta
Normal file
8
Samples~/Example1/Animations.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0014c77daedcce641a0054e802fde87f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
23
Samples~/Example1/Animations/AnimationLib.asset
Normal file
23
Samples~/Example1/Animations/AnimationLib.asset
Normal file
@ -0,0 +1,23 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0d1625f26e651894b954faf1934378dc, type: 3}
|
||||
m_Name: AnimationLib
|
||||
m_EditorClassIdentifier:
|
||||
animationBooks:
|
||||
- {fileID: 11400000, guid: 317f071a0ab99b845bf3b609ca7cbc63, type: 2}
|
||||
animations:
|
||||
- frames: 36
|
||||
maxFrames: 43
|
||||
frameTime: 0.023255814
|
||||
duration: 0.8372093
|
||||
animationMapIndex: 0
|
||||
colorMapIndex: 0
|
8
Samples~/Example1/Animations/AnimationLib.asset.meta
Normal file
8
Samples~/Example1/Animations/AnimationLib.asset.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 721fbe09d2910a949925c6b1ed810323
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user