Struct iyes_scene_tools::SceneBuilder
source · pub struct SceneBuilder<'w> { /* private fields */ }
Expand description
Flexible tool for creating Bevy scenes
You can select what entities from your World
you would like
to include in the scene, by adding them using the various methods.
For each entity, you can choose whether you would like to include
all components (that impl Reflect
) or just a specific set.
See the documentation of the various methods for more info.
After you are done adding entities and components, you can call
.build_scene(...)
to create a [DynamicScene
] with everything
that was selected.
Implementations
sourceimpl<'w> SceneBuilder<'w>
impl<'w> SceneBuilder<'w>
sourcepub fn new(world: &'w mut World) -> SceneBuilder<'w>
pub fn new(world: &'w mut World) -> SceneBuilder<'w>
Create a new scene builder
The entities and components of the created scene will come from
the provided world
.
sourcepub fn ignore_components<Q>(&mut self) -> &mut Selfwhere
Q: ComponentList,
pub fn ignore_components<Q>(&mut self) -> &mut Selfwhere
Q: ComponentList,
Add components to the set of components to be ignored
This applies only to entities without explicit component selections.
If you have explicitly added any of them to specific entities, they will still be exported to the scene.
If an entity was added in “all components” mode, then .build_scene()
will skip any of these components that it encounters.
sourcepub fn add_from_query_filter<F>(&mut self) -> &mut Selfwhere
F: ReadOnlyWorldQuery + 'static,
pub fn add_from_query_filter<F>(&mut self) -> &mut Selfwhere
F: ReadOnlyWorldQuery + 'static,
Add all entities that match the given query filter
This method allows you to select entities in a way similar to using Bevy query filters.
All components of each entity will be included.
If you want to only include specific components, try:
- [
add_with_components
]
sourcepub fn add_entity(&mut self, e: Entity) -> &mut Self
pub fn add_entity(&mut self, e: Entity) -> &mut Self
Add a specific entity
The entity ID provided will be added, if it has not been already.
All components of the entity will be included.
If you want to only include specific components, try:
- [
add_components_to_entity
]
sourcepub fn add_components_to_entity<Q>(&mut self, e: Entity) -> &mut Selfwhere
Q: ComponentList,
pub fn add_components_to_entity<Q>(&mut self, e: Entity) -> &mut Selfwhere
Q: ComponentList,
Include the specified components on a given entity ID
The entity ID provided will be added, if it has not been already.
The components listed in Q
will be added its component selection.
If you want to select all components, try:
- [
add_entity
]
sourcepub fn add_entities<I>(&mut self, entities: I) -> &mut Selfwhere
I: IntoIterator<Item = Entity>,
pub fn add_entities<I>(&mut self, entities: I) -> &mut Selfwhere
I: IntoIterator<Item = Entity>,
Add entities by ID
The entity IDs provided will be added, if they have not been already.
All components of each entity will be included.
If you want to only include specific components, try:
- [
add_components_to_entities
]
sourcepub fn add_components_to_entities<I, Q>(&mut self, entities: I) -> &mut Selfwhere
I: IntoIterator<Item = Entity>,
Q: ComponentList,
pub fn add_components_to_entities<I, Q>(&mut self, entities: I) -> &mut Selfwhere
I: IntoIterator<Item = Entity>,
Q: ComponentList,
Include the specified components to entities with ID
The entity IDs provided will be added, if they have not been already.
The components listed in Q
will be added their component selections.
If you want to select all components, try:
- [
add_entities
]
sourcepub fn add_with_components<Q, F>(&mut self) -> &mut Selfwhere
Q: ComponentList,
F: ReadOnlyWorldQuery + 'static,
pub fn add_with_components<Q, F>(&mut self) -> &mut Selfwhere
Q: ComponentList,
F: ReadOnlyWorldQuery + 'static,
Add specific components to entities that match a query filter
This method allows you to select entities in a way similar to using Bevy query filters.
The components listed in Q
will be added to each of the entities.
If you want to select all components, try:
- [
add_from_query_filter
]
sourcepub fn build_scene(&self) -> DynamicScene
pub fn build_scene(&self) -> DynamicScene
Build a [DynamicScene
] with the selected entities and components
Everything that was added to the builder (using the various add_*
methods) will be included in the scene.
All the relevant data will be copied from the World
that was provided
when the SceneBuilder
was created.
sourcepub fn export_to_file(
&self,
path: impl AsRef<Path>
) -> Result<DynamicScene, SceneExportError>
pub fn export_to_file(
&self,
path: impl AsRef<Path>
) -> Result<DynamicScene, SceneExportError>
Convenience method: build the scene and serialize to file
Creates a file in the Bevy Scene RON format. Path should end in .scn.ron
.
On success (if both scene generation and file output succeed), will return
the generated [DynamicScene
], just in case you need it.
sourcepub fn build_scene_and_add(&mut self) -> Handle<DynamicScene>
pub fn build_scene_and_add(&mut self) -> Handle<DynamicScene>
Convenience method: build the scene and add to the app’s asset collection
Returns an asset handle that can be used for spawning the scene, (with [DynamicSceneBundle
]).
Auto Trait Implementations
impl<'w> !RefUnwindSafe for SceneBuilder<'w>
impl<'w> Send for SceneBuilder<'w>
impl<'w> Sync for SceneBuilder<'w>
impl<'w> Unpin for SceneBuilder<'w>
impl<'w> !UnwindSafe for SceneBuilder<'w>
Blanket Implementations
impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
[ShaderType
] for self
. When used in [AsBindGroup
]
derives, it is safe to assume that all images in self
exist. Read moresourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read morefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read morefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read morefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more