-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Add marker for ExtractResource #22867
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ use crate::{Extract, ExtractSchedule, RenderApp}; | |
| /// | ||
| /// Therefore the resource is transferred from the "main world" into the "render world" | ||
| /// in the [`ExtractSchedule`] step. | ||
| pub trait ExtractResource: Resource { | ||
| pub trait ExtractResource<Marker = ()>: Resource { | ||
| type Source: Resource; | ||
|
|
||
| /// Defines how the resource is transferred into the "render world". | ||
|
|
@@ -22,18 +22,18 @@ pub trait ExtractResource: Resource { | |
| /// | ||
| /// Therefore it sets up the[`ExtractSchedule`] step | ||
| /// for the specified [`Resource`]. | ||
| pub struct ExtractResourcePlugin<R: ExtractResource>(PhantomData<R>); | ||
| pub struct ExtractResourcePlugin<R: ExtractResource<M>, M = ()>(PhantomData<(R, M)>); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ExtractComponent uses F for the marker, i think for "Foreign type" it would be nice to be consistent
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I called them |
||
|
|
||
| impl<R: ExtractResource> Default for ExtractResourcePlugin<R> { | ||
| impl<R: ExtractResource<M>, M> Default for ExtractResourcePlugin<R, M> { | ||
| fn default() -> Self { | ||
| Self(PhantomData) | ||
| } | ||
| } | ||
|
|
||
| impl<R: ExtractResource> Plugin for ExtractResourcePlugin<R> { | ||
| impl<R: ExtractResource<M>, M: 'static + Send + Sync> Plugin for ExtractResourcePlugin<R, M> { | ||
| fn build(&self, app: &mut App) { | ||
| if let Some(render_app) = app.get_sub_app_mut(RenderApp) { | ||
| render_app.add_systems(ExtractSchedule, extract_resource::<R>); | ||
| render_app.add_systems(ExtractSchedule, extract_resource::<R, M>); | ||
| } else { | ||
| once!(bevy_log::error!( | ||
| "Render app did not exist when trying to add `extract_resource` for <{}>.", | ||
|
|
@@ -44,7 +44,7 @@ impl<R: ExtractResource> Plugin for ExtractResourcePlugin<R> { | |
| } | ||
|
|
||
| /// This system extracts the resource of the corresponding [`Resource`] type | ||
| pub fn extract_resource<R: ExtractResource>( | ||
| pub fn extract_resource<R: ExtractResource<M>, M>( | ||
| mut commands: Commands, | ||
| main_resource: Extract<Option<Res<R::Source>>>, | ||
| target_resource: Option<ResMut<R>>, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.