fix: Refresh() will be called multiple times in the same frame, due to external assets

pull/169/head
mob-sakai 2021-06-03 03:03:16 +09:00
parent 24d32d8441
commit 0b9d80da93
1 changed files with 5 additions and 0 deletions

View File

@ -11,6 +11,7 @@ namespace Coffee.UIExtensions
static readonly List<UIParticle> s_ActiveParticles = new List<UIParticle>();
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++)
{