2021-01-09 15:56:38 +01:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace TAO.VertexAnimation
|
|
|
|
{
|
|
|
|
[CreateAssetMenu(fileName = "new ModelBaker", menuName = "VA_ModelBaker/ModelBaker", order = 400)]
|
|
|
|
public class VA_ModelBaker : ScriptableObject
|
|
|
|
{
|
|
|
|
public GameObject model;
|
|
|
|
public AnimationClip[] animationClips;
|
2021-01-11 20:59:40 +01:00
|
|
|
[Range(1, 60)]
|
2021-01-09 15:56:38 +01:00
|
|
|
public int fps = 24;
|
|
|
|
public int textureWidth = 512;
|
2021-01-11 20:59:40 +01:00
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
2021-01-09 15:56:38 +01:00
|
|
|
public bool saveBakedDataToAsset = true;
|
2021-01-11 20:59:40 +01:00
|
|
|
public bool generateAnimationBook = true;
|
|
|
|
public bool generatePrefab = true;
|
|
|
|
public Shader materialShader = null;
|
|
|
|
|
|
|
|
public GameObject prefab = null;
|
|
|
|
public Material material = null;
|
|
|
|
public VA_AnimationBook book = null;
|
|
|
|
#endif
|
2021-01-09 15:56:38 +01:00
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private AnimationBaker.BakedData bakedData;
|
|
|
|
public AnimationBaker.BakedData BakedData
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return bakedData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Bake()
|
|
|
|
{
|
|
|
|
var target = Instantiate(model);
|
|
|
|
|
|
|
|
target.ConbineAndConvertGameObject();
|
|
|
|
bakedData = target.Bake(animationClips, fps, textureWidth);
|
|
|
|
|
|
|
|
DestroyImmediate(target);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|