From 0b9d80da939580c72ca1471081d7a034edc985d4 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Thu, 3 Jun 2021 03:03:16 +0900 Subject: [PATCH] fix: Refresh() will be called multiple times in the same frame, due to external assets --- Scripts/UIParticleUpdater.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Scripts/UIParticleUpdater.cs b/Scripts/UIParticleUpdater.cs index 1e1b717..e5ca8ff 100755 --- a/Scripts/UIParticleUpdater.cs +++ b/Scripts/UIParticleUpdater.cs @@ -11,6 +11,7 @@ namespace Coffee.UIExtensions static readonly List s_ActiveParticles = new List(); static MaterialPropertyBlock s_Mpb; static ParticleSystem.Particle[] s_Particles = new ParticleSystem.Particle[2048]; + private static int frameCount = 0; public static void Register(UIParticle particle) @@ -41,6 +42,10 @@ namespace Coffee.UIExtensions 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"); for (var i = 0; i < s_ActiveParticles.Count; i++) {