using UnityEngine;
using UnityEditor.Animations;
public class RecordTransformHierarchy : MonoBehaviour
{
public AnimationClip clip;
private GameObjectRecorder m_Recorder;
void Start()
{
// Create recorder and record the script GameObject.
m_Recorder = new GameObjectRecorder(gameObject);
// Bind all the Transforms on the GameObject and all its children.
m_Recorder.BindComponentsOfType<Transform>(gameObject, true);
}
void LateUpdate()
{
if (clip == null)
return;
// Take a snapshot and record all the bindings values for this frame.
m_Recorder.TakeSnapshot(Time.deltaTime);
}
void OnDisable()
{
if (clip == null)
return;
if (m_Recorder.isRecording)
{
// Save the recorded session to the clip.
m_Recorder.SaveToClip(clip);
}
}
}
挂载此脚本到gameobject
新建animation clip
播放编辑器的同时自动K帧到animation clip