AssetPostprocessor.OnPostprocessGameObjectWithAnimatedUserProperties(GameObject, EditorCurveBinding[])
Параметры
| Параметр | Описание |
|---|---|
| gameObject | GameObject с анимированными пользовательскими свойствами. |
| связки | Кривые анимации связаны с пользовательскими свойствами. |
Описание
Вызывается после завершения импорта кривых анимации для пользовательского свойства типа float.
Вызывается для каждого GameObject с анимированным пользовательским свойством типа float. Каждое анимированное свойство имеет кривую анимации, которая представлена EditorCurveBinding. Это позволяет динамически добавлять компоненты к GameObject и перенацеливать EditorCurveBindings на любое анимированное свойство.
using UnityEngine; using UnityEditor;
class MyAllPostprocessor : AssetPostprocessor { // Increment the version number, when the AssetPostprocessors code/behavior is changed static readonly uint k_Version = 0; public override uint GetVersion() { return k_Version; }
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); } } } }