public ParticleSystemInheritVelocityMode mode;
Описание
Указывает, как применить скорость эмиттера к частицам.
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(ParticleSystem))]
public class ExampleClass : MonoBehaviour
{
private ParticleSystem ps;
public bool moduleEnabled = true;
public float hSliderValue = 5.0f;
public ParticleSystemInheritVelocityMode inheritMode;
void Start()
{
ps = GetComponent<ParticleSystem>();
var main = ps.main;
main.simulationSpace = ParticleSystemSimulationSpace.World; // rate over distance only works for world space simulations
// добавляем сферу, чтобы мы могли видеть нашу трансформируемую позицию по мере ее перемещения
var sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
sphere.transform.parent = ps.transform;
}
void Update()
{
var inheritVelocity = ps.inheritVelocity;
inheritVelocity.enabled = moduleEnabled;
inheritVelocity.curveMultiplier = hSliderValue;
inheritVelocity.mode = inheritMode;
ps.transform.position = new Vector3(Mathf.Sin(Time.time * 2.0f) * 2.0f, 0.0f, 0.0f);
}
void OnGUI()
{
moduleEnabled = GUI.Toggle(new Rect(25, 45, 100, 30), moduleEnabled, "Enabled");
hSliderValue = GUI.HorizontalSlider(new Rect(25, 85, 100, 30), hSliderValue, 0.0f, 10.0f);
inheritMode = (ParticleSystemInheritVelocityMode)GUI.SelectionGrid(new Rect(25, 125, 300, 30), (int)inheritMode, new GUIContent[] { new GUIContent("Initial"), new GUIContent("Current") }, 2);
}
}