From eb2e862e80e549c8cf16ddfed776c101c2413bac Mon Sep 17 00:00:00 2001 From: mob-sakai <12690315+mob-sakai@users.noreply.github.com> Date: Wed, 24 Dec 2025 20:10:01 +0900 Subject: [PATCH] fix: avoid endless loop close #392 --- Assets/Tests/Editor/NewTestScript.cs | 13 +++++++++---- Packages/src/Runtime/UIParticle.cs | 1 + .../Runtime/Utilities/ParticleSystemExtensions.cs | 6 +----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Assets/Tests/Editor/NewTestScript.cs b/Assets/Tests/Editor/NewTestScript.cs index 9de2f92..0556565 100644 --- a/Assets/Tests/Editor/NewTestScript.cs +++ b/Assets/Tests/Editor/NewTestScript.cs @@ -1,16 +1,21 @@ using System.Collections; +using Coffee.UIParticleInternal; using NUnit.Framework; +using UnityEngine; using UnityEngine.TestTools; namespace Coffee.UIParticle.Editor.Tests { public class NewTestScript { - // A Test behaves as an ordinary method - [Test] - public void NewTestScriptSimplePasses() + [TestCase(-1)] + [TestCase(0)] + [TestCase(2048)] + [TestCase(3000)] + public void GetParticleArray(int requiredSize) { - // Use the Assert class to test conditions + var array = ParticleSystemExtensions.GetParticleArray(requiredSize); + Debug.Log($"requiredSize: {requiredSize}, array.Length: {array.Length}"); } // A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use diff --git a/Packages/src/Runtime/UIParticle.cs b/Packages/src/Runtime/UIParticle.cs index b2c079b..5c0e4f7 100644 --- a/Packages/src/Runtime/UIParticle.cs +++ b/Packages/src/Runtime/UIParticle.cs @@ -9,6 +9,7 @@ using UnityEngine.UI; using Random = UnityEngine.Random; [assembly: InternalsVisibleTo("Coffee.UIParticle.Editor")] +[assembly: InternalsVisibleTo("Coffee.UIParticle.Editor.Tests")] [assembly: InternalsVisibleTo("Coffee.UIParticle.PerformanceDemo")] [assembly: InternalsVisibleTo("Coffee.UIParticle.Demo")] diff --git a/Packages/src/Runtime/Utilities/ParticleSystemExtensions.cs b/Packages/src/Runtime/Utilities/ParticleSystemExtensions.cs index 4bd5c69..7fec948 100644 --- a/Packages/src/Runtime/Utilities/ParticleSystemExtensions.cs +++ b/Packages/src/Runtime/Utilities/ParticleSystemExtensions.cs @@ -13,11 +13,7 @@ namespace Coffee.UIParticleInternal { if (s_TmpParticles.Length < size) { - while (s_TmpParticles.Length < size) - { - size = Mathf.NextPowerOfTwo(size); - } - + size = Mathf.NextPowerOfTwo(size); s_TmpParticles = new ParticleSystem.Particle[size]; }