bevyengine / bevyengine/bevy

Opt-out component reflection

Open
#2,968 4 comments 0 reactions 0 assignees View on GitHub
A-ECS A-Reflection A-Scenes C-Usability S-Needs-Design-Doc
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?

Currently, registering components for reflection is tedious and error-prone.

This makes use cases where you want to serialize many different component types (such as game saving, scenes or networking) very frustrating to use.

As you can see in the [reflection example](https://github.com/bevyengine/bevy/blob/main/examples/reflection/reflection.rs), users must manually register every type they wish to reflect.

## What solution would you like?

Now that #2254 is in place, make Reflect an additional trait bound on Component. Automatically derive Reflect for components, unless there is an existing manual impl for them.

When components are first added to the app, automatically register them.

## What alternative(s) have you considered?

Other strategies for automatically registering components may exist, and may allow us to create a more complete list before the app begins (rather than causing spiky work during the game).

Some components may not have any validly reflected values; perhaps these should simply not implement `Reflect`?

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.