AnimationLibrary start, AnimatorSystem parallel

Base setup animation library.
AnimatorSystem now runs in parallel.
TextureImporter preset.
This commit is contained in:
max 2020-12-09 18:36:32 +01:00
parent 5ac8db608e
commit 52dd9d4b3c
13 changed files with 760 additions and 134 deletions

8
Editor/Presets.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 58cbb5e6d3dfc7e41a4832f8880928ea
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,535 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!181963792 &2655988077585873504
Preset:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: VertexAnimationTextureImporter
m_TargetType:
m_NativeTypeID: 1006
m_ManagedTypePPtr: {fileID: 0}
m_ManagedTypeFallback:
m_Properties:
- target: {fileID: 0}
propertyPath: m_ExternalObjects.Array.size
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_MipMapMode
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_EnableMipMap
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_sRGBTexture
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_LinearTexture
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_FadeOut
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_BorderMipMap
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_MipMapsPreserveCoverage
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_AlphaTestReferenceValue
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_MipMapFadeDistanceStart
value: 1
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_MipMapFadeDistanceEnd
value: 3
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_ConvertToNormalMap
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_ExternalNormalMap
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_HeightScale
value: 0.25
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_NormalMapFilter
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_IsReadable
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_StreamingMipmaps
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_StreamingMipmapsPriority
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_VTOnly
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_GrayScaleToAlpha
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_GenerateCubemap
value: 6
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_CubemapConvolution
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SeamlessCubemap
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_TextureFormat
value: 1
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_MaxTextureSize
value: 2048
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_TextureSettings.m_FilterMode
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_TextureSettings.m_Aniso
value: 2
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_TextureSettings.m_MipBias
value: -100
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_TextureSettings.m_WrapU
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_TextureSettings.m_WrapV
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_TextureSettings.m_WrapW
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_NPOTScale
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_Lightmap
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_CompressionQuality
value: 50
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpriteMode
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpriteExtrude
value: 1
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpriteMeshType
value: 1
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_Alignment
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpritePivot.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpritePivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpritePixelsToUnits
value: 100
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpriteBorder.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpriteBorder.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpriteBorder.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpriteBorder.w
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpriteGenerateFallbackPhysicsShape
value: 1
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_AlphaUsage
value: 1
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_AlphaIsTransparency
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpriteTessellationDetail
value: -1
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_TextureType
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_TextureShape
value: 1
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SingleChannelComponent
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_MaxTextureSizeSet
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_CompressionQualitySet
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_TextureFormatSet
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_IgnorePngGamma
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_ApplyGammaDecoding
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.size
value: 5
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[0].m_BuildTarget
value: DefaultTexturePlatform
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[0].m_MaxTextureSize
value: 8192
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[0].m_ResizeAlgorithm
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[0].m_TextureFormat
value: -1
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[0].m_TextureCompression
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[0].m_CompressionQuality
value: 50
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[0].m_CrunchedCompression
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[0].m_AllowsAlphaSplitting
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[0].m_Overridden
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[0].m_AndroidETC2FallbackOverride
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[0].m_ForceMaximumCompressionQuality_BC6H_BC7
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[1].m_BuildTarget
value: Standalone
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[1].m_MaxTextureSize
value: 8192
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[1].m_ResizeAlgorithm
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[1].m_TextureFormat
value: -1
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[1].m_TextureCompression
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[1].m_CompressionQuality
value: 50
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[1].m_CrunchedCompression
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[1].m_AllowsAlphaSplitting
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[1].m_Overridden
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[1].m_AndroidETC2FallbackOverride
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[1].m_ForceMaximumCompressionQuality_BC6H_BC7
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[2].m_BuildTarget
value: iPhone
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[2].m_MaxTextureSize
value: 8192
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[2].m_ResizeAlgorithm
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[2].m_TextureFormat
value: -1
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[2].m_TextureCompression
value: 1
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[2].m_CompressionQuality
value: 50
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[2].m_CrunchedCompression
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[2].m_AllowsAlphaSplitting
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[2].m_Overridden
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[2].m_AndroidETC2FallbackOverride
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[2].m_ForceMaximumCompressionQuality_BC6H_BC7
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[3].m_BuildTarget
value: Android
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[3].m_MaxTextureSize
value: 8192
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[3].m_ResizeAlgorithm
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[3].m_TextureFormat
value: -1
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[3].m_TextureCompression
value: 1
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[3].m_CompressionQuality
value: 50
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[3].m_CrunchedCompression
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[3].m_AllowsAlphaSplitting
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[3].m_Overridden
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[3].m_AndroidETC2FallbackOverride
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[3].m_ForceMaximumCompressionQuality_BC6H_BC7
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[4].m_BuildTarget
value: Windows Store Apps
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[4].m_MaxTextureSize
value: 8192
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[4].m_ResizeAlgorithm
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[4].m_TextureFormat
value: -1
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[4].m_TextureCompression
value: 1
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[4].m_CompressionQuality
value: 50
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[4].m_CrunchedCompression
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[4].m_AllowsAlphaSplitting
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[4].m_Overridden
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[4].m_AndroidETC2FallbackOverride
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PlatformSettings.Array.data[4].m_ForceMaximumCompressionQuality_BC6H_BC7
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpriteSheet.m_Sprites.Array.size
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpriteSheet.m_Outline.Array.size
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpriteSheet.m_PhysicsShape.Array.size
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpriteSheet.m_Bones.Array.size
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpriteSheet.m_SpriteID
value:
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpriteSheet.m_InternalID
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpriteSheet.m_Vertices.Array.size
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpriteSheet.m_Indices.Array.size
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpriteSheet.m_Edges.Array.size
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpriteSheet.m_Weights.Array.size
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpriteSheet.m_SecondaryTextures.Array.size
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_SpritePackingTag
value:
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PSDRemoveMatte
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_PSDShowRemoveMatteOption
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_UserData
value:
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_AssetBundleName
value:
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_AssetBundleVariant
value:
objectReference: {fileID: 0}
m_ExcludedProperties: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0f7881a0354329b46aab70076cbffd97
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace TAO.VertexAnimation
{
[CreateAssetMenu(fileName = "new AnimationBook", menuName = "AnimationBook", order = 0)]
public class VA_AnimationBookSO : ScriptableObject
{
public int maxFrames;
public Material[] materials;
public VA_AnimationPage[] animationPages;
private void Setup()
{
// TODO: ...
// GenerateTextures.
// SetupMaterials.
}
}
[System.Serializable]
public struct VA_AnimationPage
{
public string name;
public int frames;
public Texture2D texture2D;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 97cdf8b194bcb83459d952b3cb008113
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -6,46 +6,33 @@ namespace TAO.VertexAnimation
[System.Serializable]
public struct VA_AnimationData
{
public FixedString32 name;
public int frames;
public int maxFrames;
// 1.0f / maxFrames.
public float frameTime;
// frameTime * frames.
public float duration;
}
public struct VA_AnimationDataBlobAsset
public struct VA_AnimationLibrary
{
public BlobArray<VA_AnimationData> animations;
}
public class VA_AnimationDataBlobAssetConversionSystem : GameObjectConversionSystem
public static class VA_AnimationLibraryUtils
{
protected override void OnUpdate()
public static int GetAnimation(ref VA_AnimationLibrary animationsRef, FixedString32 animationName)
{
BlobAssetReference<VA_AnimationDataBlobAsset> animationDataBlobAssetRef;
for (int i = 0; i < animationsRef.animations.Length; i++)
{
if (animationsRef.animations[i].name == animationName)
{
return i;
}
}
// 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);
}
return -1;
}
}
}

View File

@ -0,0 +1,49 @@
using Unity.Entities;
using Unity.Collections;
namespace TAO.VertexAnimation
{
[UnityEngine.RequireComponent(typeof(ConvertToEntity))]
[UnityEngine.DisallowMultipleComponent]
public class VA_AnimationLibraryComponentAuthoring : UnityEngine.MonoBehaviour
{
public VA_AnimationLibrarySO animationLibrary;
}
public class VA_AnimationLibraryConversionSystem : GameObjectConversionSystem
{
protected override void OnUpdate()
{
Entities.ForEach((VA_AnimationLibraryComponentAuthoring animationLib) =>
{
// Blob builder to build.
using (BlobBuilder blobBuilder = new BlobBuilder(Allocator.Temp))
{
// Construct the root.
ref VA_AnimationLibrary animationDataBlobAsset = ref blobBuilder.ConstructRoot<VA_AnimationLibrary>();
// 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.
BlobAssetReference<VA_AnimationLibrary> animLibAssetRef = blobBuilder.CreateBlobAssetReference<VA_AnimationLibrary>(Allocator.Persistent);
// Add it to the asset store.
// TODO: Generate Hash based on Guid.
BlobAssetStore.TryAdd(new Hash128("AnimationLib"), animLibAssetRef);
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));
});
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4900528f6fface444826347ebac032b5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,46 @@
using System.Collections.Generic;
using UnityEngine;
namespace TAO.VertexAnimation
{
[CreateAssetMenu(fileName = "new AnimationLibrary", menuName = "AnimationLibrary", order = 0)]
public class VA_AnimationLibrarySO : ScriptableObject
{
[SerializeField]
private VA_AnimationBookSO[] animationBooks;
[HideInInspector]
public List<VA_AnimationData> animations = null;
private void OnValidate()
{
SetupAnimations();
}
private void SetupAnimations()
{
animations = new List<VA_AnimationData>();
if (animationBooks != null)
{
for (int b = 0; b < animationBooks.Length; b++)
{
if(animationBooks[b].animationPages != null)
{
for (int p = 0; p < animationBooks[b].animationPages.Length; p++)
{
animations.Add(new VA_AnimationData
{
name = new Unity.Collections.FixedString32(animationBooks[b].animationPages[p].name),
maxFrames = animationBooks[b].maxFrames,
frames = animationBooks[b].animationPages[p].frames,
frameTime = 1.0f / animationBooks[b].maxFrames,
duration = 1.0f / animationBooks[b].maxFrames * animationBooks[b].animationPages[p].frames
});
}
}
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0d1625f26e651894b954faf1934378dc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -17,15 +17,15 @@ namespace TAO.VertexAnimation
public int animationIndex;
public int animationIndexSchedule;
public float animationTime;
public BlobAssetReference<VA_AnimationDataBlobAsset> animationsRef;
public BlobAssetReference<VA_AnimationLibrary> animationLibrary;
}
[UpdateAfter(typeof(VA_AnimationDataBlobAssetConversionSystem))]
[UpdateAfter(typeof(VA_AnimationLibraryConversionSystem))]
public class VA_AnimatorConversionSystem : GameObjectConversionSystem
{
protected override void OnUpdate()
{
BlobAssetStore.TryGet(new Unity.Entities.Hash128("AnimationLib"), out BlobAssetReference<VA_AnimationDataBlobAsset> assetReference);
BlobAssetStore.TryGet(new Unity.Entities.Hash128("AnimationLib"), out BlobAssetReference<VA_AnimationLibrary> animLib);
Entities.ForEach((VA_AnimatorComponentAuthoring animator) =>
{
@ -37,7 +37,7 @@ namespace TAO.VertexAnimation
animationIndex = 0,
animationIndexSchedule = -1,
animationTime = 0,
animationsRef = assetReference
animationLibrary = animLib
};
DstEntityManager.AddComponentData(entity, animatorComponent);

View File

@ -6,45 +6,6 @@ using Unity.Mathematics;
namespace TAO.VertexAnimation
{
//TODO: SetComponent.
//TODO: Disable thread safety.
//TODO: Blob data for static animation data.
//public class VA_AnimatorSystem : SystemBase
//{
// private EndSimulationEntityCommandBufferSystem endSimulationEntityCommandBufferSystem;
// protected override void OnCreate()
// {
// base.OnCreate();
// endSimulationEntityCommandBufferSystem = World.GetExistingSystem<EndSimulationEntityCommandBufferSystem>();
// }
// protected override void OnUpdate()
// {
// var ecb = endSimulationEntityCommandBufferSystem.CreateCommandBuffer().AsParallelWriter();
// Entities.ForEach((Entity entity, int entityInQueryIndex, in VA_AnimatorComponent ac, in DynamicBuffer<Child> children) =>
// {
// for (int i = 0; i < children.Length; i++)
// {
// // Get child.
// Entity child = children[i].Value;
// // Overwrite existing component.
// ecb.AddComponent(entityInQueryIndex, child, new VA_AnimationTimeComponent { Value = ac.animationTime });
// ecb.AddComponent(entityInQueryIndex, child, new VA_AnimationIndexComponent { Value = ac.animationIndex });
// }
// })
// .ScheduleParallel();
// endSimulationEntityCommandBufferSystem.AddJobHandleForProducer(Dependency);
// }
//}
//[UpdateBefore(typeof(HybridRendererSystem))]
public class VA_AnimatorSystem : SystemBase
{
protected override void OnUpdate()
@ -59,59 +20,29 @@ namespace TAO.VertexAnimation
// Get child.
Entity child = children[i].Value;
// Get a copy of the time Component of the child.
VA_AnimationTimeComponent atcCopy = atc[child];
// Set new value.
atcCopy.Value = ac.animationTime;
// Update original.
atc[child] = atcCopy;
atc[child] = new VA_AnimationTimeComponent { Value = ac.animationTime };
VA_AnimationIndexComponent aicCopy = aic[child];
aicCopy.Value = ac.animationIndex;
aic[child] = aicCopy;
//// Get a copy of the time Component of the child.
//VA_AnimationTimeComponent atcCopy = atc[child];
//// Set new value.
//atcCopy.Value = ac.animationTime;
//// Update original.
//atc[child] = atcCopy;
aic[child] = new VA_AnimationIndexComponent { Value = ac.animationIndex };
//VA_AnimationIndexComponent aicCopy = aic[child];
//aicCopy.Value = ac.animationIndex;
//aic[child] = aicCopy;
}
})
.Run();
.WithNativeDisableContainerSafetyRestriction(atc)
.WithNativeDisableContainerSafetyRestriction(aic)
.ScheduleParallel();
}
}
//public class VA_AnimatorSystem2 : SystemBase
//{
// protected override void OnCreate()
// {
// base.OnCreate();
// Enabled = false;
// }
// protected override void OnUpdate()
// {
// Entities.ForEach((ref VA_AnimatorComponent ac, in DynamicBuffer<Child> children) =>
// {
// for (int i = 0; i < children.Length; i++)
// {
// // Get child.
// Entity child = children[i].Value;
// //if(HasComponent<VA_AnimationTimeComponent>(child))
// //{
// var atc = GetComponent<VA_AnimationTimeComponent>(child);
// atc.Value = ac.animationTime;
// SetComponent(child, atc);
// //}
// //if(HasComponent<VA_AnimationIndexComponent>(child))
// //{
// var aic = GetComponent<VA_AnimationIndexComponent>(child);
// aic.Value = ac.animationIndex;
// SetComponent(child, aic);
// //}
// }
// })
// .Run();
// }
//}
// Example systems to update animation parameters.
[UpdateBefore(typeof(VA_AnimatorSystem))]
public class VA_AnimationTimeSystem : SystemBase
{
@ -122,20 +53,13 @@ namespace TAO.VertexAnimation
Entities.ForEach((ref VA_AnimatorComponent ac) =>
{
// Get the animation lib data.
ref VA_AnimationDataBlobAsset animationsRef = ref ac.animationsRef.Value;
int aFrames = animationsRef.animations[ac.animationIndex].frames;
int aMaxFrames = animationsRef.animations[ac.animationIndex].maxFrames;
ref VA_AnimationLibrary animationsRef = ref ac.animationLibrary.Value;
ac.animationTime += deltaTime;
// Time per frame.
float fTime = 1.0f / aMaxFrames;
// Animation time.
float cTime = fTime * (aFrames);
if (ac.animationTime > cTime)
if (ac.animationTime > animationsRef.animations[ac.animationIndex].duration)
{
ac.animationTime = ac.animationTime - cTime;
ac.animationTime = ac.animationTime - animationsRef.animations[ac.animationIndex].duration;
}
}).ScheduleParallel();
@ -149,9 +73,14 @@ namespace TAO.VertexAnimation
{
Entities.ForEach((Entity entity, ref VA_AnimatorComponent ac) =>
{
//int index = entity.Index % 2;
//ac.animationIndex = index;
ac.animationIndex = 0;
// Get the animation lib data.
ref VA_AnimationLibrary animationLib = ref ac.animationLibrary.Value;
int animationIndex = VA_AnimationLibraryUtils.GetAnimation(ref animationLib, "Shoot");
//int index = entity.Index % 2;
//ac.animationIndex = index;
ac.animationIndex = animationIndex;
}).ScheduleParallel();
}
}

View File

@ -6,7 +6,8 @@
"GUID:8819f35a0fc84499b990e90a4ca1911f",
"GUID:7a450cf7ca9694b5a8bfa3fd83ec635a",
"GUID:a5baed0c9693541a5bd947d336ec7659",
"GUID:d8b63aba1907145bea998dd612889d6b"
"GUID:d8b63aba1907145bea998dd612889d6b",
"GUID:e0cd26848372d4e5c891c569017e11f1"
],
"includePlatforms": [],
"excludePlatforms": [],