Skip to content

Remove resources from scenes#22968

Draft
Trashtalk217 wants to merge 3 commits intobevyengine:mainfrom
Trashtalk217:remove-resources-from-scenes
Draft

Remove resources from scenes#22968
Trashtalk217 wants to merge 3 commits intobevyengine:mainfrom
Trashtalk217:remove-resources-from-scenes

Conversation

@Trashtalk217
Copy link
Contributor

@Trashtalk217 Trashtalk217 commented Feb 15, 2026

Objective

Currently, in scenes, resources are stored like this:

(
  resources: {
    "scene::ResourceA": (
      score: 1,
    ),
  },
  entities: {
    4294967297: (
      components: {
        ...
      },
    ),
    4294967298: (
      components: {
        ...
      },
    ),
  },
)

Since resources-as-components (#20934), it has become possible to attach other components to the resource entities. This is very useful for networking and something we want to support. Currently, however, the scene format does not support additional components in the format. This means that this data will be lost when converting a world to a scene and back to a world. This loss can be a pain for people working with resources.

Solution

Since resources are already stored on entities, this PR removes resources: { ... } and instead everything is done on the entity level:

(
  entities: {
    4294967296: (
      components: {
        "scene::ResourceA": (
          score: 1,
        ),
        "bevy_ecs::resource::IsResource": ((12)),
        "replicon::Replicated": () // yay ^_^
      },
    ),
    4294967297: (
      components: {
        ...
      },
    ),
    4294967298: (
      components: {
        ...
      },
    ),
  },
)

Testing

TODO: Add a test, for what happens when a resource is loaded from a scene twice. What should that even do?

@Trashtalk217 Trashtalk217 added the A-Scenes Serialized ECS data stored on the disk label Feb 15, 2026
@SkiFire13
Copy link
Contributor

"bevy_ecs::resource::IsResource": ((12)),

Note that component ids are not stable across different instances of a bevy app, so loading this scene is likely not gonna work.

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events X-Contentious There are nontrivial implications that should be thought through S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Feb 16, 2026
@alice-i-cecile alice-i-cecile added this to the 0.19 milestone Feb 16, 2026
@alice-i-cecile alice-i-cecile added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged C-Feature A new feature, making something new possible C-Bug An unexpected or incorrect behavior and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Feb 16, 2026
@cart cart added this to ECS Feb 17, 2026
@github-project-automation github-project-automation bot moved this to Needs SME Triage in ECS Feb 17, 2026
@alice-i-cecile alice-i-cecile moved this from Needs SME Triage to SME Triaged in ECS Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events A-Scenes Serialized ECS data stored on the disk C-Bug An unexpected or incorrect behavior C-Feature A new feature, making something new possible S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged X-Contentious There are nontrivial implications that should be thought through

Projects

Status: SME Triaged

Development

Successfully merging this pull request may close these issues.

3 participants