Skip to content

Instantly share code, notes, and snippets.

@baobao
Last active December 7, 2018 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baobao/3a901e53853405bfb371299c831ae6ae to your computer and use it in GitHub Desktop.
Save baobao/3a901e53853405bfb371299c831ae6ae to your computer and use it in GitHub Desktop.
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