Loading custom materials in a resource sometimes fails
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## Bevy version 0.12.1
Custom materials that are loaded in a resource sometimes doesn't work
## \[Optional\] Relevant system information
```
AdapterInfo { name: "NVIDIA GeForce RTX 3070", vendor: 4318, device: 9352, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "545.29.02", backend: Vulkan }
```
## What you did
I made a custom material based on the `custom_material_2d` example and put it in a plugin like this:

The problem occurs when `init_resource` is called during `build` or outside the plugin, but not when called during `finish`.
I haven't tested if this happens with other asset types or the builtin materials.
## What went wrong
The material isn't loaded/doesn't work, nothing happens if I try to load it later, and no errors or other logging are printed.
If the problem turns out to be that you're not allowed to touch materials registered with `MaterialPlugin` before the plugin has been built, then I'd very much like a big notice in the documentation and some error logging, as this was a very hard problem to find in a big codebase. I also suspect that this behavior is new in 0.12 as I discovered this while updating.
## Additional information
I have made a repository that reproduces the problem here: https://github.com/kristoff3r/bevy-asset-bug/
Contributor guide
Assessment
This issue has not been assessed yet.