gameObject | 具有动画自定义属性的 GameObject。 |
bindings | 绑定到自定义属性的动画曲线。 |
该函数在自定义属性的动画曲线完成导入后调用。
它将对具有动画自定义属性的每个 GameObject 调用。每个动画属性都具有由 EditorCurveBinding 表示的动画曲线。这使您可以动态向 GameObject 添加组件并重新指定 EditorCurveBindings 以匹配任何可动画属性。
using UnityEngine; using UnityEditor;
class MyAllPostprocessor : AssetPostprocessor { void OnPostprocessGameObjectWithAnimatedUserProperties(GameObject go, EditorCurveBinding[] bindings) { // add a particle emitter to every game object that has a custom property called "particleAmount" // then map the animation to the emission rate for (int i = 0; i < bindings.Length; i++) { if (bindings[i].propertyName == "particlesAmount") { ParticleSystem emitter = go.AddComponent<ParticleSystem>(); var emission = emitter.emission; emission.rateOverTimeMultiplier = 0;
bindings[i].propertyName = "EmissionModule.rateOverTime.scalar"; bindings[i].path = AnimationUtility.CalculateTransformPath(go.transform, go.transform.root); bindings[i].type = typeof(ParticleSystem); } } } }