-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Problem
Serializing and deserializing resources is a common and important task. Currently, this must be done manually.
However, we already have a tool for this serialization: Scenes
. Each Scene
stores a World
, which (now) includes resources, but the rest of the machinery is missing.
Proposed solution
Update the Scene
machinery to handle resources as well. This should be reasonably straightforward (we can reflect resources, and we get access to the whole world when loading / saving / storing scenes), but fleshing out the rest of the API will be a fair bit of work.
The hardest part will be updating the serde
.ron
format: this presumes that only entities are included.
Our scene example should also be updated to show how to serialize / deserialize resources.
Alternatives considered
We could make a distinct serialization strategy for resources. This makes sense to include as part of scenes because:
- Common uses of scenes (saving / loading games, grabbing scenes from editors, networking) often include critical resources (current score, global illumination settings, difficulty settings) that should be logically batched together.
- Refactoring between entities and resources is very common, and two seperate strategies would cause frustrating refactoring pain.
- We're already storing a
World
everywhere for scenes.
Context
Before #1144, the World
only stored entities and components. This code hasn't been updated to work for resources too yet.