AssetPostprocessor.OnPostprocessGameObjectWithAnimatedUserProperties(GameObject, EditorCurveBinding[])

Cambiar al Manual

Parámetros

gameObjectThe GameObject with animated custom properties.
bindingsThe animation curves bound to the custom properties.

Descripción

This function is called when the animation curves for a custom property are finished importing.

It is called for every GameObject with an animated custom property. Each animated property has an animation curve that is represented by an EditorCurveBinding. This lets you dynamically add components to a GameObject and retarget the EditorCurveBindings to any animatable property.

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); } } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961