Version: 2022.1
public bool splitSubEmitterRibbons ;

描述

指定在使用此系统作为子发射器时,轨迹带是否独立地连接来自每个父粒子的粒子。

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(ParticleSystem))] public class ExampleClass : MonoBehaviour { private ParticleSystem ps; private ParticleSystem sps; public bool splitSubEmitterRibbons = true;

void Start() { ps = GetComponent<ParticleSystem>();

var main = ps.main; main.startColor = new ParticleSystem.MinMaxGradient(Color.red, Color.yellow); main.startSize = new ParticleSystem.MinMaxCurve(0.01f, 1.0f); main.startLifetime = 1.5f;

sps = new GameObject("SubEmitter", typeof(ParticleSystem)).GetComponent<ParticleSystem>(); sps.transform.parent = ps.transform;

var sub = ps.subEmitters; sub.enabled = true; sub.AddSubEmitter(sps, ParticleSystemSubEmitterType.Birth, ParticleSystemSubEmitterProperties.InheritColor);

var smain = sps.main; smain.startSpeed = 0.0f;

var sshape = sps.shape; sshape.enabled = false;

var strails = sps.trails; strails.enabled = true; strails.mode = ParticleSystemTrailMode.Ribbon; strails.widthOverTrail = 0.1f;

var spsr = sps.GetComponent<ParticleSystemRenderer>(); spsr.renderMode = ParticleSystemRenderMode.None; spsr.trailMaterial = new Material(Shader.Find("Sprites/Default")); }

void Update() { var strails = sps.trails; strails.splitSubEmitterRibbons = splitSubEmitterRibbons; }

void OnGUI() { splitSubEmitterRibbons = GUI.Toggle(new Rect(25, 25, 200, 30), splitSubEmitterRibbons, "Split Sub Emitter Ribbons"); } }