Version: 2020.1
言語: 日本語

AssetPostprocessor.OnPostprocessGameObjectWithAnimatedUserProperties(GameObject, EditorCurveBinding[])

マニュアルに切り替える

パラメーター

gameObject The GameObject with animated custom properties.
bindings The animation curves bound to the custom properties.

説明

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