mirror of
https://github.com/maxartz15/VertexAnimation.git
synced 2024-11-14 00:05:35 +01:00
31 lines
926 B
C#
31 lines
926 B
C#
using System.Collections.Generic;
|
|
using Unity.Collections;
|
|
using Unity.Entities;
|
|
using UnityEngine;
|
|
|
|
namespace TAO.VertexAnimation
|
|
{
|
|
|
|
public class AnimationCurveAuthoring : MonoBehaviour
|
|
{
|
|
public List < AnimationCurve > CurvesToConvert;
|
|
public int NumberOfSamples = 256;
|
|
}
|
|
|
|
|
|
public class AnimationCurveAuthoringBaker : Baker <AnimationCurveAuthoring>
|
|
{
|
|
public override void Bake( AnimationCurveAuthoring authoring )
|
|
{
|
|
EntitiesAnimationCurveLibrary curveLibrary = new EntitiesAnimationCurveLibrary();
|
|
curveLibrary.CurveReferences = new NativeList < EntitiesAnimationCurveReference >( 5, Allocator.Persistent );
|
|
foreach ( AnimationCurve curve in authoring.CurvesToConvert )
|
|
{
|
|
curveLibrary.CurveReferences.Add( curve.LoadUnityAnimationCurveIntoEntitiesAnimationCurve( authoring.NumberOfSamples ) );
|
|
}
|
|
|
|
AddComponent( curveLibrary );
|
|
}
|
|
}
|
|
}
|