-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bevy_reflect: Update enum derives (#5473)
> In draft until #4761 is merged. See the relevant commits [here](a85fe94). --- # Objective Update enums across Bevy to use the new enum reflection and get rid of `#[reflect_value(...)]` usages. ## Solution Find and replace all[^1] instances of `#[reflect_value(...)]` on enum types. --- ## Changelog - Updated all[^1] reflected enums to implement `Enum` (i.e. they are no longer `ReflectRef::Value`) ## Migration Guide Bevy-defined enums have been updated to implement `Enum` and are not considered value types (`ReflectRef::Value`) anymore. This means that their serialized representations will need to be updated. For example, given the Bevy enum: ```rust pub enum ScalingMode { None, WindowSize, Auto { min_width: f32, min_height: f32 }, FixedVertical(f32), FixedHorizontal(f32), } ``` You will need to update the serialized versions accordingly. ```js // OLD FORMAT { "type": "bevy_render::camera::projection::ScalingMode", "value": FixedHorizontal(720), }, // NEW FORMAT { "type": "bevy_render::camera::projection::ScalingMode", "enum": { "variant": "FixedHorizontal", "tuple": [ { "type": "f32", "value": 720, }, ], }, }, ``` This may also have other smaller implications (such as `Debug` representation), but serialization is probably the most prominent. [^1]: All enums except `HandleId` as neither `Uuid` nor `AssetPathId` implement the reflection traits
- Loading branch information
Showing
8 changed files
with
21 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters