Объявление
public ParticleSystem.Burst(float _time, short _count);public ParticleSystem.Burst(float _time, short _minCount, short _maxCount);
public ParticleSystem.Burst(float _time, short _minCount, short _maxCount, int _cycleCount, float _repeatInterval);
public ParticleSystem.Burst(float _time, ParticleSystem.MinMaxCurve _count);
public ParticleSystem.Burst(float _time, ParticleSystem.MinMaxCurve _count, int _cycleCount, float _repeatInterval);
Параметры
_time | Время испустить взрыв. |
_minCount | Минимальное количество испускаемых частиц. |
_maxCount | Максимальное количество испускаемых частиц. |
_count | Количество испускаемых частиц. |
_cycleCount | Указывает, сколько раз система должна воспроизводить пакет. Установите это значение на 0, чтобы оно проигрывалось бесконечно. |
_repeatInterval | Как часто повторять всплеск, в секундах. |
Описание
Создать новый пакет с указанием времени и количества.
Смотрите так же: ParticleSystem.emissionModule.SetBursts, ParticleSystem.emissionModule.GetBursts.
using UnityEngine;
using System.Collections;
// Создаем циклическую ParticleSystem.
// В 0, 1 и 2 секунды количество частиц в каждом цикле
// изменяются с 10 на 50, затем на 100.
// Циклы повторяются через 3 секунды.
[RequireComponent(typeof(ParticleSystem))]
public class ExampleClass : MonoBehaviour
{
public Material part;
void Start()
{
// создать красную наземную плоскость
GameObject ground = GameObject.CreatePrimitive(PrimitiveType.Quad);
ground.transform.rotation = Quaternion.Euler(90, 0, 0);
ground.transform.localScale = new Vector3(10, 10, 10);
ground.GetComponent<Renderer>().material.color = Color.red;
// rotate the GameObject so particles rise up in the y-axis
gameObject.transform.rotation = Quaternion.Euler(-90, 0, 0);
gameObject.AddComponent<ParticleSystem>();
// create the ParticleSystemParticleSystem ps;
ps = gameObject.GetComponent<ParticleSystem>();
ps.Stop();
// set the MainModule default values
var main = ps.main;
main.startColor = Color.yellow;
main.duration = 3;
// create a cone and change it into a cylinder
var shape = ps.shape;
shape.shapeType = ParticleSystemShapeType.Cone;
shape.angle = 0.0f;
shape.radius = 2.0f;
shape.radiusThickness = 0.0f;
// use the passed in material
gameObject.GetComponent<ParticleSystemRenderer>().material = part;
// set up the emission to generate particles
var em = ps.emission;
em.enabled = true;
em.rateOverTime = 0;
em.SetBursts(
new ParticleSystem.Burst[]
{
new ParticleSystem.Burst(0.0f, 10),
new ParticleSystem.Burst(1.0f, 50),
new ParticleSystem.Burst(2.0f, 100)
});
ps.Play();
}
}