-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Merged by Bors] - Enable Constructing ReflectComponent/Resource #6257
[Merged by Bors] - Enable Constructing ReflectComponent/Resource #6257
Conversation
@@ -27,7 +27,36 @@ pub struct ReflectComponent { | |||
copy: fn(&World, &mut World, Entity, Entity), | |||
} | |||
|
|||
/// The raw functions needed to make up a [`ReflectComponent`]. | |||
/// | |||
/// This is used when creating custom implementations of [`ReflectComponent`] with |
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.
We should link to / explain the simpler way here. Ditto for the resource equivalent.
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.
Agreed. We should probably also include it in the docs for the constructors (e.g. ReflectComponent::new
) as well, and indicate that this is almost certainly not needed unless you know what you're doing.
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.
I like the general approach. I think the docs need a bit of work. If you can add a bit more advice about how this might be used in practice (even if not a full example), I think this will be significantly less mysterious to users.
I'm not entirely sure on the best place for that, so use your judgement :)
/// This is used when creating custom implementations of [`ReflectComponent`] with | ||
/// [`ReflectComponent::new()`]. | ||
pub struct ReflectComponentFns { | ||
pub insert: fn(&mut World, Entity, &dyn Reflect), |
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.
Could you add a doc comment for each of these (same for ReflectResourceFns
)? I imagine the people who do need this could benefit from knowing what they actually do.
/// | ||
/// This is used when creating custom implementations of [`ReflectComponent`] with | ||
/// [`ReflectComponent::new()`]. | ||
pub struct ReflectComponentFns { |
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 these structs have their own ReflectComponentFns::new<T: Component>() -> Self
functions to fill in the entire struct, allowing individual modification if needed? Or does it not make sense to only override some but not all function pointers?
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.
That's actually a good idea. I'm not 100% sure that there will be a use for overriding only some options, but it seems like it could happen.
86dddef
to
be21e55
Compare
Pushed a bunch of docs, and extra helper methods like you guys suggested. |
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! Thanks for updating the docs. Just a few more comments from me.
be21e55
to
7c46bf7
Compare
Pushed another update. |
7c46bf7
to
fb37d6b
Compare
Co-authored-by: Gino Valente <[email protected]>
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.
Great docs, and very well made. I trust your judgement that this is in fact very useful :p
bors r+ |
# Objective - Fixes #6206 ## Solution - Create a constructor for creating `ReflectComponent` and `ReflectResource` --- ## Changelog > This section is optional. If this was a trivial fix, or has no externally-visible impact, you can delete this section. ### Added - Created constructors for `ReflectComponent` and `ReflectResource`, allowing for advanced scripting use-cases.
Pull request successfully merged into main. Build succeeded: |
# Objective - Fixes bevyengine#6206 ## Solution - Create a constructor for creating `ReflectComponent` and `ReflectResource` --- ## Changelog > This section is optional. If this was a trivial fix, or has no externally-visible impact, you can delete this section. ### Added - Created constructors for `ReflectComponent` and `ReflectResource`, allowing for advanced scripting use-cases.
# Objective - Fixes bevyengine#6206 ## Solution - Create a constructor for creating `ReflectComponent` and `ReflectResource` --- ## Changelog > This section is optional. If this was a trivial fix, or has no externally-visible impact, you can delete this section. ### Added - Created constructors for `ReflectComponent` and `ReflectResource`, allowing for advanced scripting use-cases.
# Objective - Fixes bevyengine#6206 ## Solution - Create a constructor for creating `ReflectComponent` and `ReflectResource` --- ## Changelog > This section is optional. If this was a trivial fix, or has no externally-visible impact, you can delete this section. ### Added - Created constructors for `ReflectComponent` and `ReflectResource`, allowing for advanced scripting use-cases.
# Objective - Fixes bevyengine#6206 ## Solution - Create a constructor for creating `ReflectComponent` and `ReflectResource` --- ## Changelog > This section is optional. If this was a trivial fix, or has no externally-visible impact, you can delete this section. ### Added - Created constructors for `ReflectComponent` and `ReflectResource`, allowing for advanced scripting use-cases.
Objective
ReflectComponent
#6206Solution
ReflectComponent
andReflectResource
Changelog
Added
ReflectComponent
andReflectResource
, allowing for advanced scripting use-cases.