unity 粒子特效播放状态停止在最后一帧

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Test: MonoBehaviour
{
	public List<string> pausePsObjNames;
	// Use this for initialization
	void Start ()
	{
		Pause ();
	}
	void Pause ()
	{
		ParticleSystem[] ps = gameObject.GetComponentsInChildren<ParticleSystem> ();
		foreach (var item in ps) {
			if (pausePsObjNames.Count == 0)
				StartCoroutine (StartPause (item, item.startDelay + item.startLifetime));
			else if (pausePsObjNames.Contains (item.gameObject.name)) {
				StartCoroutine (StartPause (item, item.startDelay + item.startLifetime));
			}
		}
	}
	IEnumerator StartPause (ParticleSystem ps, float time)
	{
		yield return new WaitForSeconds (time - Time.fixedDeltaTime);
		ps.Pause ();
	}
}

猜你喜欢

转载自blog.csdn.net/fucun1984686003/article/details/54377217