From 23cd44876659ffefb5aa4ea66d7264e55677eb8a Mon Sep 17 00:00:00 2001 From: mob-sakai <12690315+mob-sakai@users.noreply.github.com> Date: Fri, 3 Jan 2025 22:50:36 +0900 Subject: [PATCH] fix: sub-emitter particles may not render correctly in certain scenarios close #348 --- Runtime/UIParticleRenderer.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Runtime/UIParticleRenderer.cs b/Runtime/UIParticleRenderer.cs index e85d258..a73b4b4 100644 --- a/Runtime/UIParticleRenderer.cs +++ b/Runtime/UIParticleRenderer.cs @@ -548,6 +548,24 @@ namespace Coffee.UIExtensions * Matrix4x4.Scale(scale) * Matrix4x4.Translate(-psPos); } + + if (_mainEmitter) + { + if (_mainEmitter.IsLocalSpace()) + { + return Matrix4x4.Translate(psPos) + * Matrix4x4.Scale(scale) + * Matrix4x4.Translate(-psPos); + } + else + { + psPos = _particleSystem.transform.position - _mainEmitter.transform.position; + return Matrix4x4.Translate(psPos) + * Matrix4x4.Scale(scale) + * Matrix4x4.Translate(-psPos); + } + } + return Matrix4x4.Scale(scale); case ParticleSystemSimulationSpace.Custom: return Matrix4x4.Translate(_particleSystem.main.customSimulationSpace.position.GetScaled(scale))