mirror of
https://github.com/maxartz15/VertexAnimation.git
synced 2024-11-09 22:32:55 +01:00
max
cab2c4ad12
Model Baker ScriptableObject, bakes models and outputs the data. Can also generate prefab and animation books for quick setup. Updated GUI.
45 lines
1021 B
C#
45 lines
1021 B
C#
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;
|
|
[Range(1, 60)]
|
|
public int fps = 24;
|
|
public int textureWidth = 512;
|
|
|
|
#if UNITY_EDITOR
|
|
public bool saveBakedDataToAsset = true;
|
|
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
|
|
|
|
[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);
|
|
}
|
|
}
|
|
} |