AnimationUtility.GetObjectReferenceCurveBindings

Switch to Manual
public static EditorCurveBinding[] GetObjectReferenceCurveBindings (AnimationClip clip);

Description

返回当前存储在剪辑中的所有对象引用曲线绑定。

回答以下问题:“哪些对象引用属性由剪辑进行动画化?”

Unity 具有两种类型的动画:浮点和对象引用。浮点曲线是一种随着时间的推移对浮点属性进行动画化的经典曲线。对象引用“曲线”是一种随着时间的推移对对象引用属性进行动画化的构造。

此方法仅返回对象引用绑定。请参阅 AnimationUtility.GetCurveBindings 以了解浮点曲线。


using UnityEditor;
using UnityEngine;

// Editor window for listing all object reference curves in an animation clip public class ClipInfo : EditorWindow { private AnimationClip clip;

[MenuItem("Window/Clip Info")] static void Init() { GetWindow(typeof(ClipInfo)); }

public void OnGUI() { clip = EditorGUILayout.ObjectField("Clip", clip, typeof(AnimationClip), false) as AnimationClip;

EditorGUILayout.LabelField("Object reference curves:"); if (clip != null) { foreach (var binding in AnimationUtility.GetObjectReferenceCurveBindings(clip)) { ObjectReferenceKeyframe[] keyframes = AnimationUtility.GetObjectReferenceCurve(clip, binding); EditorGUILayout.LabelField(binding.path + "/" + binding.propertyName + ", Keys: " + keyframes.Length); } } } }