Skip to content

Apply CustomMaterial to SceneBundle #8533

Answered by nicopap
Youdiie asked this question in Q&A
Discussion options

You must be logged in to vote

This question came up a few times recently in the bevy discord. This is finally the opportunity to write it down on a search-engine-enabled web page.

You need to:

  1. Iterate over all entities in the loaded scene (here we will use SceneSpawner::iter_instance_entities)
  2. Get all the entities with the Handle<StandardMaterial> component
  3. Get the StandardMaterial for that handle
  4. Convert it into your custom material
  5. Add the custom material to the assets, keeping track of the handle
  6. Add the handle back to the entity in question, making sure to not forget to remove the Handle<StandardMaterial>

We will create a system that does all those steps and call it customize_scene_materials.

We create a new mar…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@nicopap
Comment options

@Youdiie
Comment options

@nicopap
Comment options

@Youdiie
Comment options

@Youdiie
Comment options

Answer selected by Youdiie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
A-Rendering Drawing game state to the screen A-Assets Load files from disk to use for things like images, models, and sounds A-Scenes Serialized ECS data stored on the disk
2 participants