Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(ui): a particle emitter in the UI tree draws where the tree puts it

yhh5a7010e91f0f
diff --git a/src/esengine/ui/UIRenderOrderSystem.hpp b/src/esengine/ui/UIRenderOrderSystem.hpp
index b2f807f55..183979f94 100644
--- a/src/esengine/ui/UIRenderOrderSystem.hpp
+++ b/src/esengine/ui/UIRenderOrderSystem.hpp
@@ -8,6 +8,7 @@
#include "../ecs/components/Sprite.hpp"
#include "../ecs/components/UIVisual.hpp"
#include "../ecs/components/Canvas.hpp"
+#include "../ecs/components/ParticleEmitter.hpp"
namespace esengine::ecs {
@@ -23,6 +24,15 @@ inline i32 assignRenderOrder(Registry& registry, Entity entity, i32 counter) {
sprite.layer = counter;
}
counter++;
+ } else if (auto* emitter = registry.tryGet<ParticleEmitter>(entity)) {
+ // An emitter in the UI tree draws where the tree says it does, like the
+ // Sprite above: without this it keeps its authored layer and a UI effect
+ // lands under (or over) the whole panel instead of between two of its
+ // elements — the reason Unity needs a UIParticle extension at all.
+ if (emitter->layer != counter) {
+ emitter->layer = counter;
+ }
+ counter++;
}
}