Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor.Experimental.Animations;
#endif
public class GameObjectRecorderTest : MonoBehaviour
{
#if UNITY_EDITOR
GameObjectRecorder r;
// 記録するAnimationClipをセット
public AnimationClip clip;
public bool isRecord = false;
void Start ()
{
r = new GameObjectRecorder ();
r.root = gameObject;
// 記録するコンポーネントをセット
// 第2引数をtrueにすると下階層のオブジェクトも記録対象になる
r.BindComponent<Transform> (gameObject, false);
}
void LateUpdate ()
{
if (isRecord) {
r.TakeSnapshot (Time.deltaTime);
} else if (isRecord == false && r.isRecording) {
// 記録を止めてAnimationClipを保存する
r.SaveToClip (clip);
r.ResetRecording ();
}
}
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment