录制动画 保存到 animationclip

2020-03-11  本文已影响0人  杰罗xr
using UnityEngine;
using UnityEditor.Experimental.Animations;

public class AnimatorTest : MonoBehaviour
{
    public AnimationClip clip;

    private GameObjectRecorder m_Recorder;
    public int a;

    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);
        m_Recorder.BindComponentsOfType<dsf>(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);
        }
    }
}
image.png
上一篇下一篇

猜你喜欢

热点阅读