Open musjj opened 8 months ago
Can you get this working with bevy_mod_picking
for your interactions? I suggest that both as a workaround, and because we're in the process of upstreaming it (and ripping out the existing interaction code to use it).
I just tried using bevy_mod_picking
, but alas it still does not work. Without the TargetCamera
component everything works just fine, but in case I'm doing something wrong, here's the updated code:
So I don't think it's TargetCamera
that is at fault here.
Might even be a known limitation when rendering to a non-window target based on this comment here:
but if you swap your
With<InGameCamera>
in your setup_ui
to With<OuterCamera>
it will exhibit the same behavior as omitting TargetCamera
and that's because without TargetCamera
, it will just pick the camera with the highest order that has its render target set to the window https://github.com/bevyengine/bevy/blob/017ffc5a7ba00e2734a68c03459ba718bd4aa462/crates/bevy_ui/src/ui_node.rs#L2180-L2187
Edit: If support can't be added, it might be worth having TargetCamera
warn when using a camera whose render target is not a window.
Yeah, I think bevy_mod_picking
works on the same logic (at least for UI).
I think the best solution here is to provide a way to achieve the same thing without a RenderTarget
. Would it be possible to create a projection that retains the original pixel grid, regardless of its zoom level (if that makes sense)?
Currently, if you zoom an OrthographicProjection
without RenderTarget
-ing a texture you will no longer get pixelation for free: https://github.com/drakmaniso/bevy_pixel_camera/issues/30. In fact, I don't think it even affects the scale of the UI right now.
I would love to hear how other pixel art devs currently do their UI.
Also, does anyone know how other engines like Godot, Love2D or Ebitengine achieves this? I remember having a pretty easy time achieving pixel-art graphics there.
Godot: https://docs.godotengine.org/en/stable/tutorials/rendering/multiple_resolutions.html#desktop-game
Love2D: https://github.com/a327ex/blog/issues/19
Ebitengine: https://ebitengine.org/en/examples/animation.html
I haven't tested it yet but I think this might provide some the ground work to get interactions working with UI nodes that specify a TargetCamera
rendering to a texture (if you were to use bevy_mod_picking
and egui
). You can in theory have the replaced InputPlugin
set the Interaction
component.
https://github.com/aevyrie/bevy_mod_picking/blob/main/examples/render_to_texture.rs
Bevy version
0.13.1
What you did
This is a combination of 2d/pixel_grid_snap.rs and ui/button.rs from the examples:
What went wrong
Button interaction simply does not work at all. Hovering and clicking the button should cause
hovered!
andpressed!
to be printed to the console, but it does nothing here.I believe this is a critical issue for pixel-art games as this prevents mouse interaction from working at all. I hope that there is at least a workaround for such a show-stopping bug.
Additional information
Some relevant PRs:
Relevant issues: