How to serialize/deserialize a resource that holds Entities (ie MapEntities)
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
Nowhere that I can find in the documentation, online tutorials, or the official examples shows how to correctly set up a resource struct for serialization/deserialization when it holds entities that need to be mapped to the new world.
The documentation for components is also in a very bad state, in regards to entity mapping, but I was able to figure it out by searching through the discord server at least. Not so for resources.
For example:
```rust
#[derive(Component, Reflect)]
#[reflect(Component)]
struct MyComponent {
#[entities]
entity: Entity
}
```
works for components,
but the same thing does NOT work for resources
```rust
#[derive(Resource,Reflect)]
#[reflect(Resource)]
struct MyResource{
#[entities]
entity:Entity
}
```
The compiler says : ```cannot find attribute `entities` in this scope
`entities` is an attribute that can be used by the derive macros `Component` and `MapEntities`, you might be missing a `derive` attributer```
This, which I found on discord, also doesn't work:
```rust
#[derive(Resource,MapEntities,Reflect)]
#[reflect(Resource)]
#[reflect(MapEntities)]
struct MyResource{
#[entities]
entity:Entity
}
```
Knowing how to do this is pretty essential for my application, and I image for many other serious bevy users as well.
Contributor guide
Assessment
This issue has not been assessed yet.