bevyengine / bevyengine/bevy

AssetServer doesn't work in `FromWorld`

Open
#11,473 5 comments 1 reaction 0 assignees View on GitHub
A-Assets C-Bug
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version

0.12.1

## Relevant system information

MacOs Intel

```ignore
`AdapterInfo { name: "AMD Radeon Pro 5300M", vendor: 0, device: 0, device_type: DiscreteGpu, driver: "", driver_info: "", backend: Metal }`
```
## What you did

I have a resource storing some materials called `MapAssets`:

```rust
#[derive(Resource)]
pub struct MapAssets {
pub mat: Handle
}
```

This material uses a `base_color_texture` loaded from the `assets/` folder.

If I load that texture in my `FromWorld` impl

```rust
impl FromWorld for MapAssets {
fn from_world(world: &mut World) -> Self {
let server = world.resource::();
let texture = server.load("my_texture.png);
let mut materials = world.resource_mut::>;
let mat = materials.add(StandardMaterial::from(texture));
Self { mat }
}
}
```

The object is invisible.

On the other hand if I use a `Startup` system using `Res` and insert the resource through `Commands` it works as expected.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.