GameObjectRecorder

class in UnityEditor.Animations

/

Inherits from:Object

Switch to Manual

Description

在运行场景时记录 GameObject 的变化属性并将信息保存在 AnimationClip 中。

该类将绑定 GameObject 属性,在属性值在运行场景中发生变化时记录相应的值,并将结果保存在 AnimationClip 中。记录的游戏对象在类中称为 root,您也可以绑定 root 任何子项的属性。

请参阅以下代码示例,了解如何实现该类以及如何设置要记录的内容。

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); } } }

Variables

currentTime返回录制的当前时间。(只读)
isRecording录制器进行录制时,返回 true。(只读)
root动画层级视图的 GameObject 根。(只读)

Constructors

GameObjectRecorder创建新的游戏对象录制器。

Public Functions

Bind根据 EditorCurveBinding 的定义绑定游戏对象的属性。
BindAll为 target 的所有属性添加绑定;如果 recursive 为 /true/,也要为 target 子项的所有属性添加绑定。
BindComponent为 component 的所有属性添加绑定。
BindComponentsOfType为 target 中的首个 T 类型组件的所有属性添加绑定;如果 recursive 为 true ,也要为 target 子项的所有属性添加绑定。
GetBindings返回添加到录制器的所有绑定的数组。
ResetRecording重置记录。
SaveToClip将录制的动画保存到 clip 中。When no frames per second is given, the default is 60 FPS.
TakeSnapshot按 dt 秒时间转发动画,然后记录添加的绑定值。

Inherited members

Variables

hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
name对象的名称。

Public Functions

GetInstanceID返回对象的实例 ID。
ToString返回 GameObject 的名称。

Static Functions

Destroy删除 GameObject、组件或资源。
DestroyImmediate立即销毁对象 /obj/。强烈建议您改用 Destroy。
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindObjectOfType返回第一个类型为 type 的已加载的激活对象。
FindObjectsOfType返回所有类型为 type 的已加载的激活对象的列表。
Instantiate克隆 original 对象并返回克隆对象。

Operators

bool该对象是否存在?
operator !=比较两个对象是否引用不同的对象。
operator ==比较两个对象引用,判断它们是否引用同一个对象。