Last active
December 7, 2018 03:19
-
-
Save baobao/3a901e53853405bfb371299c831ae6ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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