fix: nullptr exceptions when using nested UIParticle components in hierarchy

close #246
pull/289/head
mob-sakai 2023-08-14 15:42:25 +09:00
parent 723a04d0cf
commit e67e9482e2
1 changed files with 11 additions and 1 deletions

View File

@ -286,7 +286,17 @@ namespace Coffee.UIExtensions
public void RefreshParticles(List<ParticleSystem> particles)
{
GetComponentsInChildren(m_Renderers);
// #246: Nullptr exceptions when using nested UIParticle components in hierarchy
m_Renderers.Clear();
foreach (Transform child in transform)
{
var uiParticleRenderer = child.GetComponent<UIParticleRenderer>();
if (uiParticleRenderer != null)
{
m_Renderers.Add(uiParticleRenderer);
}
}
var j = 0;
for (var i = 0; i < particles.Count; i++)