SAIMA/Assets//Shader/火焰/Particleappear.cs

38 lines
984 B
C#
Raw Normal View History

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<AudioSource>();
boomAudio.Play();
StartCoroutine(SetParticleColor(gameObject.GetComponent<ParticleSystem>(), 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());
}
}