using System.Collections; using System.Collections.Generic; using UnityEngine; public class Particleappear : MonoBehaviour { // Start is called before the first frame update private AudioSource boomAudio; void Start() { boomAudio = GetComponent(); boomAudio.Play(); StartCoroutine(SetParticleColor(gameObject.GetComponent(), 0, 6f)); } public IEnumerator des() { yield return new WaitForSeconds(0.4f); Destroy(gameObject); } //修改粒子,使粒子淡出 private IEnumerator SetParticleColor(ParticleSystem particleSystem,float endValue,float speed) { #pragma warning disable 0618 Color color = particleSystem.startColor; while (particleSystem.startColor.a>0) { yield return new WaitForSeconds(0.1f); color.a -= 1; particleSystem.startColor = color; } StartCoroutine(des()); } }