-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bevy_scene: Add ReflectBundle
#6344
Conversation
b9ec315
to
4029144
Compare
First: I do think we need something functionally similar to this! Being able to specify a "logical group" of entity configuration and only specify components with non-default values is an important step for the scene system / this has always been the plan. However this is controversial as its starting to encroach on "prefab space" and the concerns outlined in the "Components as Bundles" conversation: #2974 (comment), where we agreed that Bundles should just be "simple groups of components" (at least for now). The main question is: Will we support Bundles in scene editing scenarios? Supporting 3 concepts seems like too many:
Will Bundles "become" prefabs? Is this even technically feasible? (this would require a number of internal changes to bevy_ecs / break existing assumptions). Does that mean components are also prefabs? |
Makes sense, I don't have an issue with marking this as controversial.
Yeah there are a lot of vaguely similar concepts that are liable to confuse users. Each one kinda blends into the next (especially when coming from something like Unity or another engine). I don't think bundles should be prefabs, but they definitely can be viewed that way. They encapsulate a set of components, can define data for those components (think constructors or So in my eyes, and I'm sure others, bundles are prefab-like. The main differences1 are that they don't provide any other prefab-related functionality and they don't really "exist" in the world (as they're just sugar for a group of components2). And the same could be said for components (they're basically just a bundle with one item). All that to say, I think we could go ahead with My arguments for it:
My arguments against it:
Footnotes |
4029144
to
203cf79
Compare
@MrGVSV maybe we can have |
# Objective Similar to #6344, but contains only `ReflectBundle` changes. Useful for scripting. The implementation has also been updated to look exactly like `ReflectComponent`. --- ## Changelog ### Added - Reflection for bundles. --------- Co-authored-by: Gino Valente <[email protected]>
# Objective Similar to bevyengine#6344, but contains only `ReflectBundle` changes. Useful for scripting. The implementation has also been updated to look exactly like `ReflectComponent`. --- ## Changelog ### Added - Reflection for bundles. --------- Co-authored-by: Gino Valente <[email protected]>
# Objective Similar to bevyengine#6344, but contains only `ReflectBundle` changes. Useful for scripting. The implementation has also been updated to look exactly like `ReflectComponent`. --- ## Changelog ### Added - Reflection for bundles. --------- Co-authored-by: Gino Valente <[email protected]>
Backlog cleanup: closing due to inactivity, and because it seems like once |
Objective
Scenes do not currently support spawning entire bundles. This means that in order to simulate spawning a bundle, one must include all components within that bundle.
Given the following bundle:
We must then include the following in our scene file:
We only needed to specify data for
ComponentA
. All other components in the bundle could have just as easily been left out since we didn't have to specify anything for them (or perhaps they're just markers).Solution
Add
ReflectBundle
to allow scenes to spawn complete bundles.With this change, we can now update our example bundle:
And add a
bundles
section to our scene files:Much nicer!
Considerations
There are some caveats to this system we might need to consider:
bundles
field will never be serialized by theDynamicScene
serializer. This could be confusing to users who expect it to serialize. The problem is, we don't have a great way of knowing whether every necessary component exists to create a valid bundle and not lose any information. So for now it's a manually-written/deserialize-only feature.Component
s also implementBundle
, it would be possible to register aReflectBundle
for a component. If this is done, then applying the "bundle" will result in each field of the component being inserted onto the entity. This is obviously not good. However, there's not a good way of knowing whether aBundle
is only a component or not. If we could add aBundle::IS_COMPONENT
constant or something, it might be possible to throw an error when attempting to create aReflectBundle
for a component.Changelog
ReflectBundle
bundles
field toDynamicEntity
bundles
map to be optionally included per entity in scene files