Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render events #18517

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Render events #18517

wants to merge 8 commits into from

Conversation

ecoskey
Copy link
Contributor

@ecoskey ecoskey commented Mar 24, 2025

Objective

fix #18491 (comment)
Sometimes users want to send events from the render world to the main world. While not often advised, some advanced use-cases like readback use a similar pattern, which often requires setting up a channel and relaying events manually.

Solution

Add a simple abstraction (App::init_render_event) to set up the channel and relay events to the main world, retaining caller information.

Note: this pr makes Events::send_with_caller public, but does not add a similar public method on EventWriter

Testing

Ran example

Copy link
Contributor

The generated examples/README.md is out of sync with the example metadata in Cargo.toml or the example readme template. Please run cargo run -p build-templated-pages -- update examples to update it, and commit the file change.

@ecoskey ecoskey requested a review from IceSentry March 24, 2025 17:52
@ecoskey ecoskey added A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Mar 24, 2025
@JMS55
Copy link
Contributor

JMS55 commented Mar 24, 2025

Quickly leaving my thoughts, I don't love the events naming.

It has nothing to do with events about rendering, but is just an arbitrary channel for sending data back to the main world, right?

Not sure what a better name is though, and again haven't looked at the PR to deeply yet.

@IceSentry
Copy link
Contributor

They are events from the render world. I think it's fair to call them render event. Presumably, users will need this to send events in the context of rendering. Otherwise they wouldn't need events sent from the render world. Maybe specify render world event just to remove any possible ambiguity, but I'm not sure what kind of ambiguity there could be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Send events from the render world to the main world
3 participants