You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HighGroundRoyaleNetcode/Assets/JMO Assets/Cartoon FX/Scripts/CFX_ShurikenThreadFix.cs

37 lines
832 B
C#

using UnityEngine;
using System.Collections;
// Cartoon FX - (c) 2015, Jean Moreno
// Drag/Drop this script on a Particle System (or an object having Particle System objects as children) to prevent a Shuriken bug
// where a system would emit at its original instantiated position before being translated, resulting in particles in-between
// the two positions.
// Possibly a threading bug from Unity (as of 3.5.4)
public class CFX_ShurikenThreadFix : MonoBehaviour
{
private ParticleSystem[] systems;
void OnEnable()
{
systems = GetComponentsInChildren<ParticleSystem>();
foreach(ParticleSystem ps in systems)
{
ps.Stop(true);
ps.Clear(true);
}
StartCoroutine("WaitFrame");
}
IEnumerator WaitFrame()
{
yield return null;
foreach(ParticleSystem ps in systems)
{
ps.Play(true);
}
}
}