Skip to content
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

[Merged by Bors] - 0.7 migration guide #332

Closed
wants to merge 22 commits into from
Closed
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 172 additions & 0 deletions content/learn/book/migration-guides/0.6-0.7/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
+++
title = "0.6 to 0.7"
weight = 1
sort_by = "weight"
template = "book-section.html"
page_template = "book-section.html"
insert_anchor_links = "right"
[extra]
long_title = "Migration Guide: 0.6 to 0.7"
+++

<!-- Github filter used to find the relevant PRs "is:pr label:C-Breaking-Change closed:>2022-02-01 [Merged by Bors]" -->

### AliasedMutability

<https://github.com/bevyengine/bevy/pull/4298>

The `QueryEntityError` enum now has a `AliasedMutability` variant, and returns the offending entity.

### Remove margins.rs

<https://github.com/bevyengine/bevy/pull/4284>

The `Margins` type was removed. To migrate, replace of `Margins` with `UiRect`.
IceSentry marked this conversation as resolved.
Show resolved Hide resolved

### Remove face_toward.rs

<https://github.com/bevyengine/bevy/pull/4277>

The `FaceToward` trait was removed. To migrate, replace every occurrence of `Mat4::face_toward` to `Mat4::look_at_rh`.

### `World::entities_mut` is now unsafe

<https://github.com/bevyengine/bevy/pull/4093>

```rs
// 0.6
world.entities_mut()

// 0.7
unsafe { world.entities_mut() }
```

### Mesh vertex buffer layouts

<https://github.com/bevyengine/bevy/pull/3959>

TODO
IceSentry marked this conversation as resolved.
Show resolved Hide resolved

### Remove the need for 'IntoSystem::into_system()' when using run criteria piping

<https://github.com/bevyengine/bevy/pull/3923>

```rs
// 0.6
.with_run_criteria(RunCriteria::pipe(
"is_done_label",
IntoSystem::into_system(inverse),
))

// 0.7
.with_run_criteria(RunCriteria::pipe("is_done_label", inverse))
```

### Obviate the need for RunSystem, and remove it

<https://github.com/bevyengine/bevy/pull/3817>

TODO

### Replace VSync with PresentMode

https://github.com/bevyengine/bevy/pull/3812

Instead of using a boolean flag for vsync we switched to using a [`PresentMode`] enum with multiple variants.

```rs
// 0.6
App::new()
.insert_resource(WindowDescriptor {
vsync: false,
..Default::default()
})

// 0.7
App::new()
.insert_resource(WindowDescriptor {
present_mode: PresentMode::Mailbox,
IceSentry marked this conversation as resolved.
Show resolved Hide resolved
..Default::default()
})
```

<!-- TODO update to 0.7 link -->
[`PresentMode`]: http://dev-docs.bevyengine.org/bevy/window/enum.PresentMode.html

### Fix mul_vec3 tranformation order

<https://github.com/bevyengine/bevy/pull/3811>

Transforms are now consistently applied in the standard scale -> rotate -> translate. This doesn't require any code changes, but it means SpriteBundle will behave as expected when rotating.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Fix mul_vec3 tranformation order
<https://github.com/bevyengine/bevy/pull/3811>
Transforms are now consistently applied in the standard scale -> rotate -> translate. This doesn't require any code changes, but it means SpriteBundle will behave as expected when rotating.

Would love to hear other opinions on this, but if this isn't actionable, I don't think it needs to be here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it technically affected how things were transformed, so if somebody hacked something on top, they can remove it, but I guess the changelog is enough for this.

### Use marker components for cameras instead of name strings

<https://github.com/bevyengine/bevy/pull/3635>

TODO

### Remove the config api

<https://github.com/bevyengine/bevy/pull/3633>

TODO

### Add capability to render to a texture
IceSentry marked this conversation as resolved.
Show resolved Hide resolved
IceSentry marked this conversation as resolved.
Show resolved Hide resolved

<https://github.com/bevyengine/bevy/pull/3412>

```rs
// 0.6
commands.spawn_bundle(PerspectiveCameraBundle {
camera: Camera {
window: window_id,
..Default::default()
},
..Default::default()
});

// 0.7
commands.spawn_bundle(PerspectiveCameraBundle {
camera: Camera {
target: RenderTarget::Window(window_id),
..Default::default()
},
..Default::default()
});
```

### Implement init_resource for Commands and World

<https://github.com/bevyengine/bevy/pull/3079>

```rs
#[derive(Default)]
struct Scoreboard {
current_score: u32,
high_score: u32,
}

// 0.6
commands.insert_resource(Scoreboard::Default());
IceSentry marked this conversation as resolved.
Show resolved Hide resolved

// 0.7
commands.init_resource::<Scoreboard>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't the 0.6 and the 0.7 examples here have different behaviour in case there is already a scoreboard resource?

Maybe we should just say this is new functionality on Commands, so no 0.6 example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's a migration guide, if it's purely new then it doesn't need any migration. I just did that after a quick glance at the PR. I wasn't sure what the change was.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.
It is possible to get the same functionality in 0.6 with an exclusive system. We could compare that with a 0.7 system that only needs commands.

```

### ParamSet for conflicting SystemParam
IceSentry marked this conversation as resolved.
Show resolved Hide resolved

<https://github.com/bevyengine/bevy/pull/2765>

TODO
IceSentry marked this conversation as resolved.
Show resolved Hide resolved

### Infallabile resource getters

<https://github.com/bevyengine/bevy/pull/4047>

```rs
// 0.6
let score = world.get_resource::<Score>().unwrap();

// 0.7
let score = world.resource::<Score>();
```