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

Create a new scene builder

The entities and components of the created scene will come from the provided world.

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.

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]

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]

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]

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]

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]

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]

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.

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.

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

Blanket Implementations

Gets the TypeId of self. Read more
Return the T [ShaderType] for self. When used in [AsBindGroup] derives, it is safe to assume that all images in self exist. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Convert 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 more
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more
Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more