You've already forked ParticleEffectForUGUI
mirror of
https://github.com/mob-sakai/ParticleEffectForUGUI.git
synced 2026-05-15 20:50:08 +00:00
fix: Refresh() will be called multiple times in the same frame, due to external assets
This commit is contained in:
@@ -11,6 +11,7 @@ namespace Coffee.UIExtensions
|
|||||||
static readonly List<UIParticle> s_ActiveParticles = new List<UIParticle>();
|
static readonly List<UIParticle> s_ActiveParticles = new List<UIParticle>();
|
||||||
static MaterialPropertyBlock s_Mpb;
|
static MaterialPropertyBlock s_Mpb;
|
||||||
static ParticleSystem.Particle[] s_Particles = new ParticleSystem.Particle[2048];
|
static ParticleSystem.Particle[] s_Particles = new ParticleSystem.Particle[2048];
|
||||||
|
private static int frameCount = 0;
|
||||||
|
|
||||||
|
|
||||||
public static void Register(UIParticle particle)
|
public static void Register(UIParticle particle)
|
||||||
@@ -41,6 +42,10 @@ namespace Coffee.UIExtensions
|
|||||||
|
|
||||||
private static void Refresh()
|
private static void Refresh()
|
||||||
{
|
{
|
||||||
|
// Do not allow it to be called in the same frame.
|
||||||
|
if (frameCount == Time.frameCount) return;
|
||||||
|
frameCount = Time.frameCount;
|
||||||
|
|
||||||
Profiler.BeginSample("[UIParticle] Refresh");
|
Profiler.BeginSample("[UIParticle] Refresh");
|
||||||
for (var i = 0; i < s_ActiveParticles.Count; i++)
|
for (var i = 0; i < s_ActiveParticles.Count; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user