SAIMA/Assets//Shader/火焰/Particleappear.cs
GrassTE 37278672ed 整理及制作特效
1.制作了火焰粒子及shader
2.整理相关特效为预制体,为方便程序导入,都为拖入场景就能用的。
2022-08-26 04:45:43 +08:00

38 lines
984 B
C#

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());
}
}