-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Exposes Observer
's system's name
#19611
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
base: main
Are you sure you want to change the base?
Conversation
aylmao, the test failed because it uses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, this is really clean. Two small things to clean up:
- We should probably do something like "type_name Observer" for the name. Make a method on Observer or a free function to define the exact standard name, then call that in the couple of places where we're defining the name.
- We should lump these changes in with the existing observer_overhaul release notes. Don't worry too much about making it nice; just move the content you have over and add yourself + this PR to the authors list. We'll need a big rewrite at the end of it to cover all of these changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a suggestion to avoid a new public Bundle type. Once that's fixed, this LGTM :) Thanks!
@alice-i-cecile do you think it would be a reasonable follow up to this PR (but not in it) to make this behind a feature (dunno which, I definitely don’t want to be prematurely optimizing but also I’ve seen the massive list of observers in inspector egui at least in my game and I’d be surprised if I want all those entities in my release build hanging around with |
@alice-i-cecile they need to be at least |
This should be done as part of #19558, or in follow-up after both these PRs are merged. Good thought! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, my request wasn't clear. I just wanted to use the anonymous tuple type, not to make the constructor private :) I've left a final suggestion with my intended fix, then this LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is cool!
Should there be any unit tests for this, where we spawn an observer and check that is has a Name
component with a useful value? Or maybe they would be too brittle because type_name
doesn't have any stability guarantees.
the rebase wrecked everything... will restart |
i don't know if this new attempt still count as solving the issue raised by #18726 |
This will be good enough: inspectors can manually call these methods to generate names for now. We can add |
Splitting up the trait AnyNamedSystem: Any + Send + Sync + 'static {
fn system_name(&self) -> Cow<'static, str>;
}
impl<S: System> AnyNamedSystem for S {
fn system_name(&self) -> Cow<'static, str> { self.name() }
}
// ...
pub struct Observer {
// ...
system: Box<dyn AnyNamedSystem>, |
@@ -49,8 +49,10 @@ pub trait System: Send + Sync + 'static { | |||
type In: SystemInput; | |||
/// The system's output. | |||
type Out; | |||
/// Returns the system's name. | |||
|
|||
/// Returns system's name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this still have "the", for grammar's sake?
Objective
Fixes #18726
Alternative to and closes #18797
Solution
Create a method
Observer::system_name
to expose the name of theObserver
's systemShowcase
TODO