From 0b69cdb626cb6f45c507b596d31a85255bf2cded Mon Sep 17 00:00:00 2001
From: Jerome Humbert <djeedai@gmail.com>
Date: Thu, 4 Aug 2022 10:01:26 +0100
Subject: [PATCH] Upgrade to Bevy 0.8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Upgrade to the latest released version 0.8.0 of Bevy.

Add a new `bevy_asset` feature to enable animation of Bevy assets
(types implementing the `Asset` trait). Bevy 0.8 does not contain
`bevy_asset` in its defaul features, so this new feature reflects that
new possibility to build Bevy and í½ƒ Bevy Tweening without support
for the `bevy_asset` crate. The new feature is enabled by default for
discoverability and to prevent a behavior breaking change.
---
 CHANGELOG.md                      |  11 +--
 Cargo.toml                        |  12 +--
 README.md                         |  31 ++++----
 benchmarks/Cargo.toml             |   2 +-
 benchmarks/benches/lens.rs        |  12 +--
 examples/colormaterial_color.rs   |   2 +-
 examples/menu.rs                  | 117 +++++++++++++++---------------
 examples/sequence.rs              |   2 +-
 examples/sprite_color.rs          |   2 +-
 examples/text_color.rs            |   8 +-
 examples/transform_rotation.rs    |  10 +--
 examples/transform_translation.rs |   2 +-
 examples/ui_position.rs           |   8 +-
 src/lens.rs                       |  52 ++++++-------
 src/lib.rs                        |  40 +++++++---
 src/plugin.rs                     |  35 ++++++---
 16 files changed, 188 insertions(+), 158 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index b8caeb9..8e072bc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,14 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Added
 
-- Add `is_forward()` and `is_backward()` convenience helpers to `TweeningDirection`.
-- Add `Tween::set_direction()` and `Tween::with_direction()` which allow configuring the playback direction of a tween, allowing to play it backward from end to start.
-- Support dynamically changing an animation's speed with `Animator::set_speed`
-- Add `AnimationSystem` label to tweening tick systems
-- A `BoxedTweenable` type to make working with `Box<dyn Tweenable + ...>` easier
+- Added `is_forward()` and `is_backward()` convenience helpers to `TweeningDirection`.
+- Added `Tween::set_direction()` and `Tween::with_direction()` which allow configuring the playback direction of a tween, allowing to play it backward from end to start.
+- Added support for dynamically changing an animation's speed with `Animator::set_speed`.
+- Added `AnimationSystem` label to tweening tick systems.
+- Added a `BoxedTweenable` trait to make working with `Box<dyn Tweenable + ...>` easier.
 
 ### Changed
 
+- Compatible with Bevy 0.8
 - Double boxing in `Sequence` and `Tracks` was fixed. As a result, any custom tweenables
   should implement `From` for `BoxedTweenable` to make those APIs easier to use.
 
diff --git a/Cargo.toml b/Cargo.toml
index c1a693c..3047136 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "bevy_tweening"
-version = "0.4.0"
+version = "0.5.0-dev"
 authors = ["François Mockers <mockersf@gmail.com>", "Jerome Humbert <djeedai@gmail.com>"]
 edition = "2021"
 description = "Tweening animation plugin for the Bevy game engine"
@@ -13,7 +13,9 @@ readme = "README.md"
 exclude = ["examples/*.gif", ".github", "release.md"]
 
 [features]
-default = ["bevy_sprite", "bevy_ui"]
+default = ["bevy_sprite", "bevy_ui", "bevy_asset"]
+# Enable support for Asset animation
+bevy_asset = ["bevy/bevy_asset"]
 # Enable built-in lenses for Bevy sprites
 bevy_sprite = ["bevy/bevy_sprite", "bevy/bevy_render"]
 # Enable built-in lenses for Bevy UI
@@ -21,10 +23,10 @@ bevy_ui = ["bevy/bevy_ui", "bevy/bevy_text", "bevy/bevy_render"]
 
 [dependencies]
 interpolation = "0.2"
-bevy = { version = "0.7", default-features = false }
+bevy = { version = "0.8", default-features = false }
 
 [dev-dependencies]
-bevy-inspector-egui = "0.10"
+bevy-inspector-egui = "0.12"
 
 [[example]]
 name = "menu"
@@ -32,7 +34,7 @@ required-features = [ "bevy/bevy_winit" ]
 
 [[example]]
 name = "colormaterial_color"
-required-features = [ "bevy_sprite", "bevy/bevy_winit" ]
+required-features = [ "bevy_asset", "bevy_sprite", "bevy/bevy_winit" ]
 
 [[example]]
 name = "sprite_color"
diff --git a/README.md b/README.md
index e4797b4..39e4e6b 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@
 [![Crate](https://img.shields.io/crates/v/bevy_tweening.svg)](https://crates.io/crates/bevy_tweening)
 [![Build Status](https://github.com/djeedai/bevy_tweening/actions/workflows/ci.yaml/badge.svg)](https://github.com/djeedai/bevy_tweening/actions/workflows/ci.yaml)
 [![Coverage Status](https://coveralls.io/repos/github/djeedai/bevy_tweening/badge.svg?branch=main&kill_cache=1)](https://coveralls.io/github/djeedai/bevy_tweening?branch=main)
-[![Bevy tracking](https://img.shields.io/badge/Bevy%20tracking-v0.7-lightblue)](https://github.com/bevyengine/bevy/blob/main/docs/plugins_guidelines.md#main-branch-tracking)
+[![Bevy tracking](https://img.shields.io/badge/Bevy%20tracking-v0.8-lightblue)](https://github.com/bevyengine/bevy/blob/main/docs/plugins_guidelines.md#main-branch-tracking)
 
 Tweening animation plugin for the Bevy game engine.
 
@@ -31,6 +31,7 @@ This crate supports the following features:
 
 | Feature | Default | Description |
 |---|---|---|
+| `bevy_asset`  | Yes | Enable animating Bevy assets (`Asset`) in addition of components. |
 | `bevy_sprite` | Yes | Includes built-in lenses for some `Sprite`-related components. |
 | `bevy_ui`     | Yes | Includes built-in lenses for some UI-related components. |
 
@@ -63,7 +64,7 @@ let tween = Tween::new(
     // to animate it. It also contains the start and end values associated
     // with the animation ratios 0. and 1.
     TransformPositionLens {
-        start: Vec3::new(0., 0., 0.),
+        start: Vec3::ZERO,
         end: Vec3::new(1., 2., -4.),
     },
 );
@@ -111,16 +112,16 @@ The naming scheme for predefined lenses is `"<TargetName><FieldName>Lens"`, wher
 
 | Target Component | Animated Field | Lens | Feature |
 |---|---|---|---|
-| [`Transform`](https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html) | [`translation`](https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html#structfield.translation) | [`TransformPositionLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformPositionLens.html) | |
-| | [`rotation`](https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (`Quat`)¹ | [`TransformRotationLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformRotationLens.html) | |
-| | [`rotation`](https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateXLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformRotateXLens.html) | |
-| | [`rotation`](https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateYLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformRotateYLens.html) | |
-| | [`rotation`](https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateZLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformRotateZLens.html) | |
-| | [`rotation`](https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateAxisLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformRotateAxisLens.html) | |
-| | [`scale`](https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html#structfield.scale) | [`TransformScaleLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformScaleLens.html) | |
-| [`Sprite`](https://docs.rs/bevy/0.7.0/bevy/sprite/struct.Sprite.html) | [`color`](https://docs.rs/bevy/0.7.0/bevy/sprite/struct.Sprite.html#structfield.color) | [`SpriteColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.SpriteColorLens.html) | `bevy_sprite` |
-| [`Style`](https://docs.rs/bevy/0.7.0/bevy/ui/struct.Style.html) | [`position`](https://docs.rs/bevy/0.7.0/bevy/ui/struct.Style.html#structfield.position) | [`UiPositionLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.UiPositionLens.html) | `bevy_ui` |
-| [`Text`](https://docs.rs/bevy/0.7.0/bevy/text/struct.Text.html) | [`TextStyle::color`](https://docs.rs/bevy/0.7.0/bevy/text/struct.TextStyle.html#structfield.color) | [`TextColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TextColorLens.html) | `bevy_ui` |
+| [`Transform`](https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html) | [`translation`](https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.translation) | [`TransformPositionLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformPositionLens.html) | |
+| | [`rotation`](https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (`Quat`)¹ | [`TransformRotationLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformRotationLens.html) | |
+| | [`rotation`](https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateXLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformRotateXLens.html) | |
+| | [`rotation`](https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateYLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformRotateYLens.html) | |
+| | [`rotation`](https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateZLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformRotateZLens.html) | |
+| | [`rotation`](https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.rotation) (angle)² | [`TransformRotateAxisLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformRotateAxisLens.html) | |
+| | [`scale`](https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.scale) | [`TransformScaleLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TransformScaleLens.html) | |
+| [`Sprite`](https://docs.rs/bevy/0.8.0/bevy/sprite/struct.Sprite.html) | [`color`](https://docs.rs/bevy/0.8.0/bevy/sprite/struct.Sprite.html#structfield.color) | [`SpriteColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.SpriteColorLens.html) | `bevy_sprite` |
+| [`Style`](https://docs.rs/bevy/0.8.0/bevy/ui/struct.Style.html) | [`position`](https://docs.rs/bevy/0.8.0/bevy/ui/struct.Style.html#structfield.position) | [`UiPositionLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.UiPositionLens.html) | `bevy_ui` |
+| [`Text`](https://docs.rs/bevy/0.8.0/bevy/text/struct.Text.html) | [`TextStyle::color`](https://docs.rs/bevy/0.8.0/bevy/text/struct.TextStyle.html#structfield.color) | [`TextColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.TextColorLens.html) | `bevy_ui` |
 
 ¹ Shortest-path interpolation between two rotations, using `Quat::slerp()`.
 
@@ -130,9 +131,11 @@ See the [comparison of rotation lenses](https://docs.rs/bevy_tweening/0.4.0/bevy
 
 ### Bevy Assets
 
+Asset animation always requires the `bevy_asset` feature.
+
 | Target Asset | Animated Field | Lens | Feature |
 |---|---|---|---|
-| [`ColorMaterial`](https://docs.rs/bevy/0.7.0/bevy/sprite/struct.ColorMaterial.html) | [`color`](https://docs.rs/bevy/0.7.0/bevy/sprite/struct.ColorMaterial.html#structfield.color) | [`ColorMaterialColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.ColorMaterialColorLens.html) | `bevy_sprite` |
+| [`ColorMaterial`](https://docs.rs/bevy/0.8.0/bevy/sprite/struct.ColorMaterial.html) | [`color`](https://docs.rs/bevy/0.8.0/bevy/sprite/struct.ColorMaterial.html#structfield.color) | [`ColorMaterialColorLens`](https://docs.rs/bevy_tweening/latest/bevy_tweening/struct.ColorMaterialColorLens.html) | `bevy_asset` + `bevy_sprite` |
 
 ## Custom lens
 
@@ -186,7 +189,7 @@ Then, in addition, the system `component_animator_system::<CustomComponent>` nee
 
 ## Custom asset support
 
-The process is similar to custom components, creating a custom lens for the custom asset. The system to add is `asset_animator_system::<CustomAsset>`.
+The process is similar to custom components, creating a custom lens for the custom asset. The system to add is `asset_animator_system::<CustomAsset>`. This requires the `bevy_asset` feature (enabled by default).
 
 ## Examples
 
diff --git a/benchmarks/Cargo.toml b/benchmarks/Cargo.toml
index 56ff410..be7e057 100644
--- a/benchmarks/Cargo.toml
+++ b/benchmarks/Cargo.toml
@@ -18,7 +18,7 @@ criterion = { version = "0.3", features = ["html_reports"] }
 bevy_tweening = { path = "../" }
 
 [dependencies.bevy]
-version = "0.6"
+version = "0.8.0"
 default-features = false
 features = [ "render" ]
 
diff --git a/benchmarks/benches/lens.rs b/benchmarks/benches/lens.rs
index 3ce3e35..8c87acb 100644
--- a/benchmarks/benches/lens.rs
+++ b/benchmarks/benches/lens.rs
@@ -11,18 +11,18 @@ fn text_color_lens(c: &mut Criterion) {
         end: Color::BLUE,
         section: 0,
     };
-    let mut text = Text::with_section(
+    let mut text = Text::from_section(
         "test".to_string(),
         TextStyle {
             font: Default::default(),
             font_size: 60.0,
             color: Color::WHITE,
         },
-        TextAlignment {
-            vertical: VerticalAlign::Center,
-            horizontal: HorizontalAlign::Center,
-        },
-    );
+    )
+    .with_alignment(TextAlignment {
+        vertical: VerticalAlign::Center,
+        horizontal: HorizontalAlign::Center,
+    });
     c.bench_function("TextColorLens", |b| {
         b.iter(|| lens.lerp(&mut text, black_box(0.3)))
     });
diff --git a/examples/colormaterial_color.rs b/examples/colormaterial_color.rs
index ad6e950..edf90e3 100644
--- a/examples/colormaterial_color.rs
+++ b/examples/colormaterial_color.rs
@@ -25,7 +25,7 @@ fn setup(
     mut meshes: ResMut<Assets<Mesh>>,
     mut materials: ResMut<Assets<ColorMaterial>>,
 ) {
-    commands.spawn_bundle(OrthographicCameraBundle::new_2d());
+    commands.spawn_bundle(Camera2dBundle::default());
 
     let size = 80.;
 
diff --git a/examples/menu.rs b/examples/menu.rs
index 1990afa..3c0fefd 100644
--- a/examples/menu.rs
+++ b/examples/menu.rs
@@ -20,17 +20,17 @@ fn main() {
 }
 
 fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
-    commands.spawn_bundle(UiCameraBundle::default());
+    commands.spawn_bundle(Camera2dBundle::default());
 
     let font = asset_server.load("fonts/FiraMono-Regular.ttf");
 
-    let container = commands
+    commands
         .spawn_bundle(NodeBundle {
             style: Style {
                 position_type: PositionType::Absolute,
-                position: Rect::all(Val::Px(0.)),
-                margin: Rect::all(Val::Px(16.)),
-                padding: Rect::all(Val::Px(16.)),
+                position: UiRect::all(Val::Px(0.)),
+                margin: UiRect::all(Val::Px(16.)),
+                padding: UiRect::all(Val::Px(16.)),
                 flex_direction: FlexDirection::ColumnReverse,
                 align_content: AlignContent::Center,
                 align_items: AlignItems::Center,
@@ -42,60 +42,59 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
             ..default()
         })
         .insert(Name::new("menu"))
-        .id();
-
-    let mut start_time_ms = 0;
-    for text in &["Continue", "New Game", "Settings", "Quit"] {
-        let delay = Delay::new(Duration::from_millis(start_time_ms));
-        start_time_ms += 500;
-        let tween_scale = Tween::new(
-            EaseFunction::BounceOut,
-            TweeningType::Once,
-            Duration::from_secs(2),
-            TransformScaleLens {
-                start: Vec3::splat(0.01),
-                end: Vec3::ONE,
-            },
-        );
-        let seq = delay.then(tween_scale);
-        commands
-            .spawn_bundle(NodeBundle {
-                node: Node {
-                    size: Vec2::new(300., 80.),
-                },
-                style: Style {
-                    min_size: Size::new(Val::Px(300.), Val::Px(80.)),
-                    margin: Rect::all(Val::Px(8.)),
-                    padding: Rect::all(Val::Px(8.)),
-                    align_content: AlignContent::Center,
-                    align_items: AlignItems::Center,
-                    align_self: AlignSelf::Center,
-                    justify_content: JustifyContent::Center,
-                    ..default()
-                },
-                color: UiColor(Color::rgb_u8(162, 226, 95)),
-                transform: Transform::from_scale(Vec3::splat(0.01)),
-                ..default()
-            })
-            .insert(Name::new(format!("button:{}", text)))
-            .insert(Parent(container))
-            .insert(Animator::new(seq))
-            .with_children(|parent| {
-                parent.spawn_bundle(TextBundle {
-                    text: Text::with_section(
-                        text.to_string(),
-                        TextStyle {
-                            font: font.clone(),
-                            font_size: 48.0,
-                            color: Color::rgb_u8(83, 163, 130),
+        .with_children(|container| {
+            let mut start_time_ms = 0;
+            for text in &["Continue", "New Game", "Settings", "Quit"] {
+                let delay = Delay::new(Duration::from_millis(start_time_ms));
+                start_time_ms += 500;
+                let tween_scale = Tween::new(
+                    EaseFunction::BounceOut,
+                    TweeningType::Once,
+                    Duration::from_secs(2),
+                    TransformScaleLens {
+                        start: Vec3::splat(0.01),
+                        end: Vec3::ONE,
+                    },
+                );
+                let seq = delay.then(tween_scale);
+                container
+                    .spawn_bundle(NodeBundle {
+                        node: Node {
+                            size: Vec2::new(300., 80.),
                         },
-                        TextAlignment {
-                            vertical: VerticalAlign::Center,
-                            horizontal: HorizontalAlign::Center,
+                        style: Style {
+                            min_size: Size::new(Val::Px(300.), Val::Px(80.)),
+                            margin: UiRect::all(Val::Px(8.)),
+                            padding: UiRect::all(Val::Px(8.)),
+                            align_content: AlignContent::Center,
+                            align_items: AlignItems::Center,
+                            align_self: AlignSelf::Center,
+                            justify_content: JustifyContent::Center,
+                            ..default()
                         },
-                    ),
-                    ..default()
-                });
-            });
-    }
+                        color: UiColor(Color::rgb_u8(162, 226, 95)),
+                        transform: Transform::from_scale(Vec3::splat(0.01)),
+                        ..default()
+                    })
+                    .insert(Name::new(format!("button:{}", text)))
+                    .insert(Animator::new(seq))
+                    .with_children(|parent| {
+                        parent.spawn_bundle(TextBundle {
+                            text: Text::from_section(
+                                text.to_string(),
+                                TextStyle {
+                                    font: font.clone(),
+                                    font_size: 48.0,
+                                    color: Color::rgb_u8(83, 163, 130),
+                                },
+                            )
+                            .with_alignment(TextAlignment {
+                                vertical: VerticalAlign::Center,
+                                horizontal: HorizontalAlign::Center,
+                            }),
+                            ..default()
+                        });
+                    });
+            }
+        });
 }
diff --git a/examples/sequence.rs b/examples/sequence.rs
index 6ae3f19..9ed183f 100644
--- a/examples/sequence.rs
+++ b/examples/sequence.rs
@@ -31,7 +31,7 @@ struct RedSprite;
 struct BlueSprite;
 
 fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
-    commands.spawn_bundle(OrthographicCameraBundle::new_2d());
+    commands.spawn_bundle(Camera2dBundle::default());
 
     let font = asset_server.load("fonts/FiraMono-Regular.ttf");
     let text_style_red = TextStyle {
diff --git a/examples/sprite_color.rs b/examples/sprite_color.rs
index 3f1a94a..e42aa4e 100644
--- a/examples/sprite_color.rs
+++ b/examples/sprite_color.rs
@@ -17,7 +17,7 @@ fn main() {
 }
 
 fn setup(mut commands: Commands) {
-    commands.spawn_bundle(OrthographicCameraBundle::new_2d());
+    commands.spawn_bundle(Camera2dBundle::default());
 
     let size = 80.;
 
diff --git a/examples/text_color.rs b/examples/text_color.rs
index 5232330..a1d3e9f 100644
--- a/examples/text_color.rs
+++ b/examples/text_color.rs
@@ -20,7 +20,7 @@ fn main() {
 }
 
 fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
-    commands.spawn_bundle(UiCameraBundle::default());
+    commands.spawn_bundle(Camera2dBundle::default());
 
     let font = asset_server.load("fonts/FiraMono-Regular.ttf");
 
@@ -81,7 +81,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
             .spawn_bundle(TextBundle {
                 style: Style {
                     size: Size::new(Val::Px(size_x), Val::Px(size_y)),
-                    position: Rect {
+                    position: UiRect {
                         left: Val::Px(x),
                         top: Val::Px(y),
                         right: Val::Auto,
@@ -94,15 +94,13 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
                     justify_content: JustifyContent::Center,
                     ..default()
                 },
-                text: Text::with_section(
+                text: Text::from_section(
                     *ease_name,
                     TextStyle {
                         font: font.clone(),
                         font_size: 24.0,
                         color: Color::WHITE,
                     },
-                    // you can still use Default
-                    default(),
                 ),
                 ..default()
             })
diff --git a/examples/transform_rotation.rs b/examples/transform_rotation.rs
index a259ff3..aa68b87 100644
--- a/examples/transform_rotation.rs
+++ b/examples/transform_rotation.rs
@@ -33,7 +33,7 @@ impl Default for Options {
 }
 
 fn setup(mut commands: Commands) {
-    commands.spawn_bundle(OrthographicCameraBundle::new_2d());
+    commands.spawn_bundle(Camera2dBundle::default());
 
     let size = 80.;
 
@@ -86,10 +86,10 @@ fn setup(mut commands: Commands) {
         );
 
         commands
-            .spawn_bundle((
-                Transform::from_translation(Vec3::new(x, y, 0.)),
-                GlobalTransform::default(),
-            ))
+            .spawn_bundle(SpatialBundle {
+                transform: Transform::from_translation(Vec3::new(x, y, 0.)),
+                ..default()
+            })
             .with_children(|parent| {
                 parent
                     .spawn_bundle(SpriteBundle {
diff --git a/examples/transform_translation.rs b/examples/transform_translation.rs
index 75cc678..29088b0 100644
--- a/examples/transform_translation.rs
+++ b/examples/transform_translation.rs
@@ -33,7 +33,7 @@ impl Default for Options {
 }
 
 fn setup(mut commands: Commands) {
-    commands.spawn_bundle(OrthographicCameraBundle::new_2d());
+    commands.spawn_bundle(Camera2dBundle::default());
 
     let size = 25.;
 
diff --git a/examples/ui_position.rs b/examples/ui_position.rs
index 24ff0e3..236b6fb 100644
--- a/examples/ui_position.rs
+++ b/examples/ui_position.rs
@@ -33,7 +33,7 @@ impl Default for Options {
 }
 
 fn setup(mut commands: Commands) {
-    commands.spawn_bundle(UiCameraBundle::default());
+    commands.spawn_bundle(Camera2dBundle::default());
 
     let size = 25.;
 
@@ -79,13 +79,13 @@ fn setup(mut commands: Commands) {
             TweeningType::PingPong,
             std::time::Duration::from_secs(1),
             UiPositionLens {
-                start: Rect {
+                start: UiRect {
                     left: Val::Px(x),
                     top: Val::Px(10.),
                     right: Val::Auto,
                     bottom: Val::Auto,
                 },
-                end: Rect {
+                end: UiRect {
                     left: Val::Px(x),
                     top: Val::Px(screen_y - 10. - size),
                     right: Val::Auto,
@@ -98,7 +98,7 @@ fn setup(mut commands: Commands) {
             .spawn_bundle(NodeBundle {
                 style: Style {
                     size: Size::new(Val::Px(size), Val::Px(size)),
-                    position: Rect {
+                    position: UiRect {
                         left: Val::Px(x),
                         top: Val::Px(10.),
                         right: Val::Auto,
diff --git a/src/lens.rs b/src/lens.rs
index 368b740..155d07d 100644
--- a/src/lens.rs
+++ b/src/lens.rs
@@ -31,9 +31,9 @@
 //! - [`TransformRotateZLens`]
 //! - [`TransformRotateAxisLens`]
 //!
-//! [`rotation`]: https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html#structfield.rotation
-//! [`Transform`]: https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html
-//! [`Quat::slerp()`]: https://docs.rs/bevy/0.7.0/bevy/math/struct.Quat.html#method.slerp
+//! [`rotation`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.rotation
+//! [`Transform`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html
+//! [`Quat::slerp()`]: https://docs.rs/bevy/0.8.0/bevy/math/struct.Quat.html#method.slerp
 
 use bevy::prelude::*;
 
@@ -77,8 +77,8 @@ pub trait Lens<T> {
 /// A lens to manipulate the [`color`] field of a section of a [`Text`]
 /// component.
 ///
-/// [`color`]: https://docs.rs/bevy/0.7.0/bevy/text/struct.TextStyle.html#structfield.color
-/// [`Text`]: https://docs.rs/bevy/0.7.0/bevy/text/struct.Text.html
+/// [`color`]: https://docs.rs/bevy/0.8.0/bevy/text/struct.TextStyle.html#structfield.color
+/// [`Text`]: https://docs.rs/bevy/0.8.0/bevy/text/struct.Text.html
 #[cfg(feature = "bevy_ui")]
 #[derive(Debug, Copy, Clone, PartialEq)]
 pub struct TextColorLens {
@@ -104,8 +104,8 @@ impl Lens<Text> for TextColorLens {
 
 /// A lens to manipulate the [`translation`] field of a [`Transform`] component.
 ///
-/// [`translation`]: https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html#structfield.translation
-/// [`Transform`]: https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html
+/// [`translation`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.translation
+/// [`Transform`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html
 #[derive(Debug, Copy, Clone, PartialEq)]
 pub struct TransformPositionLens {
     /// Start value of the translation.
@@ -134,9 +134,9 @@ impl Lens<Transform> for TransformPositionLens {
 /// See the [top-level `lens` module documentation] for a comparison of rotation
 /// lenses.
 ///
-/// [`rotation`]: https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html#structfield.rotation
-/// [`Transform`]: https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html
-/// [`Quat::slerp()`]: https://docs.rs/bevy/0.7.0/bevy/math/struct.Quat.html#method.slerp
+/// [`rotation`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.rotation
+/// [`Transform`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html
+/// [`Quat::slerp()`]: https://docs.rs/bevy/0.8.0/bevy/math/struct.Quat.html#method.slerp
 /// [top-level `lens` module documentation]: crate::lens
 #[derive(Debug, Copy, Clone, PartialEq)]
 pub struct TransformRotationLens {
@@ -162,7 +162,7 @@ impl Lens<Transform> for TransformRotationLens {
 /// See the [top-level `lens` module documentation] for a comparison of rotation
 /// lenses.
 ///
-/// [`Transform`]: https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html
+/// [`Transform`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html
 /// [top-level `lens` module documentation]: crate::lens
 #[derive(Debug, Copy, Clone, PartialEq)]
 pub struct TransformRotateXLens {
@@ -189,7 +189,7 @@ impl Lens<Transform> for TransformRotateXLens {
 /// See the [top-level `lens` module documentation] for a comparison of rotation
 /// lenses.
 ///
-/// [`Transform`]: https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html
+/// [`Transform`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html
 /// [top-level `lens` module documentation]: crate::lens
 #[derive(Debug, Copy, Clone, PartialEq)]
 pub struct TransformRotateYLens {
@@ -216,7 +216,7 @@ impl Lens<Transform> for TransformRotateYLens {
 /// See the [top-level `lens` module documentation] for a comparison of rotation
 /// lenses.
 ///
-/// [`Transform`]: https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html
+/// [`Transform`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html
 /// [top-level `lens` module documentation]: crate::lens
 #[derive(Debug, Copy, Clone, PartialEq)]
 pub struct TransformRotateZLens {
@@ -247,7 +247,7 @@ impl Lens<Transform> for TransformRotateZLens {
 ///
 /// This method panics if the `axis` vector is not normalized.
 ///
-/// [`Transform`]: https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html
+/// [`Transform`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html
 /// [top-level `lens` module documentation]: crate::lens
 #[derive(Debug, Copy, Clone, PartialEq)]
 pub struct TransformRotateAxisLens {
@@ -268,8 +268,8 @@ impl Lens<Transform> for TransformRotateAxisLens {
 
 /// A lens to manipulate the [`scale`] field of a [`Transform`] component.
 ///
-/// [`scale`]: https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html#structfield.scale
-/// [`Transform`]: https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html
+/// [`scale`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.scale
+/// [`Transform`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html
 #[derive(Debug, Copy, Clone, PartialEq)]
 pub struct TransformScaleLens {
     /// Start value of the scale.
@@ -287,15 +287,15 @@ impl Lens<Transform> for TransformScaleLens {
 
 /// A lens to manipulate the [`position`] field of a UI [`Style`] component.
 ///
-/// [`position`]: https://docs.rs/bevy/0.7.0/bevy/ui/struct.Style.html#structfield.position
-/// [`Style`]: https://docs.rs/bevy/0.7.0/bevy/ui/struct.Style.html
+/// [`position`]: https://docs.rs/bevy/0.8.0/bevy/ui/struct.Style.html#structfield.position
+/// [`Style`]: https://docs.rs/bevy/0.8.0/bevy/ui/struct.Style.html
 #[cfg(feature = "bevy_ui")]
 #[derive(Debug, Copy, Clone, PartialEq)]
 pub struct UiPositionLens {
     /// Start position.
-    pub start: Rect<Val>,
+    pub start: UiRect<Val>,
     /// End position.
-    pub end: Rect<Val>,
+    pub end: UiRect<Val>,
 }
 
 #[cfg(feature = "bevy_ui")]
@@ -312,7 +312,7 @@ fn lerp_val(start: &Val, end: &Val, ratio: f32) -> Val {
 #[cfg(feature = "bevy_ui")]
 impl Lens<Style> for UiPositionLens {
     fn lerp(&mut self, target: &mut Style, ratio: f32) {
-        target.position = Rect {
+        target.position = UiRect {
             left: lerp_val(&self.start.left, &self.end.left, ratio),
             right: lerp_val(&self.start.right, &self.end.right, ratio),
             top: lerp_val(&self.start.top, &self.end.top, ratio),
@@ -323,8 +323,8 @@ impl Lens<Style> for UiPositionLens {
 
 /// A lens to manipulate the [`color`] field of a [`ColorMaterial`] asset.
 ///
-/// [`color`]: https://docs.rs/bevy/0.7.0/bevy/sprite/struct.ColorMaterial.html#structfield.color
-/// [`ColorMaterial`]: https://docs.rs/bevy/0.7.0/bevy/sprite/struct.ColorMaterial.html
+/// [`color`]: https://docs.rs/bevy/0.8.0/bevy/sprite/struct.ColorMaterial.html#structfield.color
+/// [`ColorMaterial`]: https://docs.rs/bevy/0.8.0/bevy/sprite/struct.ColorMaterial.html
 #[cfg(feature = "bevy_sprite")]
 #[derive(Debug, Copy, Clone, PartialEq)]
 pub struct ColorMaterialColorLens {
@@ -348,8 +348,8 @@ impl Lens<ColorMaterial> for ColorMaterialColorLens {
 
 /// A lens to manipulate the [`color`] field of a [`Sprite`] asset.
 ///
-/// [`color`]: https://docs.rs/bevy/0.7.0/bevy/sprite/struct.Sprite.html#structfield.color
-/// [`Sprite`]: https://docs.rs/bevy/0.7.0/bevy/sprite/struct.Sprite.html
+/// [`color`]: https://docs.rs/bevy/0.8.0/bevy/sprite/struct.Sprite.html#structfield.color
+/// [`Sprite`]: https://docs.rs/bevy/0.8.0/bevy/sprite/struct.Sprite.html
 #[cfg(feature = "bevy_sprite")]
 #[derive(Debug, Copy, Clone, PartialEq)]
 pub struct SpriteColorLens {
@@ -384,7 +384,7 @@ mod tests {
             end: Color::BLUE,
             section: 0,
         };
-        let mut text = Text::with_section("", default(), default());
+        let mut text = Text::from_section("", default());
 
         lens.lerp(&mut text, 0.);
         assert_eq!(text.sections[0].style.color, Color::RED);
diff --git a/src/lib.rs b/src/lib.rs
index 55a104c..84ac755 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -132,7 +132,7 @@
 //! ## Assets animation
 //!
 //! Assets are animated in a similar way to component, via the [`AssetAnimator`]
-//! component.
+//! component. This requires the `bevy_asset` feature (enabled by default).
 //!
 //! Because assets are typically shared, and the animation applies to the asset
 //! itself, all users of the asset see the animation. For example, animating the
@@ -149,16 +149,19 @@
 //! lens can also be created by implementing the trait, allowing to animate
 //! virtually any field of any Bevy component or asset.
 //!
-//! [`Transform::translation`]: https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html#structfield.translation
-//! [`Entity`]: https://docs.rs/bevy/0.7.0/bevy/ecs/entity/struct.Entity.html
-//! [`Query`]: https://docs.rs/bevy/0.7.0/bevy/ecs/system/struct.Query.html
-//! [`ColorMaterial`]: https://docs.rs/bevy/0.7.0/bevy/sprite/struct.ColorMaterial.html
-//! [`Sprite`]: https://docs.rs/bevy/0.7.0/bevy/sprite/struct.Sprite.html
-//! [`Transform`]: https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html
-
-use bevy::{asset::Asset, prelude::*};
+//! [`Transform::translation`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html#structfield.translation
+//! [`Entity`]: https://docs.rs/bevy/0.8.0/bevy/ecs/entity/struct.Entity.html
+//! [`Query`]: https://docs.rs/bevy/0.8.0/bevy/ecs/system/struct.Query.html
+//! [`ColorMaterial`]: https://docs.rs/bevy/0.8.0/bevy/sprite/struct.ColorMaterial.html
+//! [`Sprite`]: https://docs.rs/bevy/0.8.0/bevy/sprite/struct.Sprite.html
+//! [`Transform`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html
+
+use bevy::prelude::*;
 use std::time::Duration;
 
+#[cfg(feature = "bevy_asset")]
+use bevy::asset::Asset;
+
 use interpolation::Ease as IEase;
 pub use interpolation::{EaseFunction, Lerp};
 
@@ -167,13 +170,14 @@ mod plugin;
 mod tweenable;
 
 pub use lens::Lens;
-pub use plugin::{
-    asset_animator_system, component_animator_system, AnimationSystem, TweeningPlugin,
-};
+pub use plugin::{component_animator_system, AnimationSystem, TweeningPlugin};
 pub use tweenable::{
     BoxedTweenable, Delay, Sequence, Tracks, Tween, TweenCompleted, TweenState, Tweenable,
 };
 
+#[cfg(feature = "bevy_asset")]
+pub use plugin::asset_animator_system;
+
 /// Type of looping for a tween animation.
 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
 pub enum TweeningType {
@@ -486,6 +490,7 @@ impl<T: Component> Animator<T> {
 }
 
 /// Component to control the animation of an asset.
+#[cfg(feature = "bevy_asset")]
 #[derive(Component)]
 pub struct AssetAnimator<T: Asset> {
     /// Control if this animation is played or not.
@@ -495,6 +500,7 @@ pub struct AssetAnimator<T: Asset> {
     speed: f32,
 }
 
+#[cfg(feature = "bevy_asset")]
 impl<T: Asset + std::fmt::Debug> std::fmt::Debug for AssetAnimator<T> {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         f.debug_struct("AssetAnimator")
@@ -503,6 +509,7 @@ impl<T: Asset + std::fmt::Debug> std::fmt::Debug for AssetAnimator<T> {
     }
 }
 
+#[cfg(feature = "bevy_asset")]
 impl<T: Asset> Default for AssetAnimator<T> {
     fn default() -> Self {
         Self {
@@ -514,6 +521,7 @@ impl<T: Asset> Default for AssetAnimator<T> {
     }
 }
 
+#[cfg(feature = "bevy_asset")]
 impl<T: Asset> AssetAnimator<T> {
     /// Create a new asset animator component from a single tweenable.
     #[must_use]
@@ -536,6 +544,8 @@ impl<T: Asset> AssetAnimator<T> {
 #[cfg(test)]
 mod tests {
     use super::{lens::*, *};
+
+    #[cfg(feature = "bevy_asset")]
     use bevy::reflect::TypeUuid;
 
     struct DummyLens {
@@ -548,6 +558,7 @@ mod tests {
         value: f32,
     }
 
+    #[cfg(feature = "bevy_asset")]
     #[derive(Reflect, TypeUuid)]
     #[uuid = "a33abc11-264e-4bbb-82e8-b87226bb4383"]
     struct DummyAsset {
@@ -560,6 +571,7 @@ mod tests {
         }
     }
 
+    #[cfg(feature = "bevy_asset")]
     impl Lens<DummyAsset> for DummyLens {
         fn lerp(&mut self, target: &mut DummyAsset, ratio: f32) {
             target.value = self.start.lerp(&self.end, &ratio);
@@ -702,6 +714,7 @@ mod tests {
     }
 
     /// AssetAnimator::new()
+    #[cfg(feature = "bevy_asset")]
     #[test]
     fn asset_animator_new() {
         let tween = Tween::<DummyAsset>::new(
@@ -717,6 +730,7 @@ mod tests {
     }
 
     /// AssetAnimator::with_state()
+    #[cfg(feature = "bevy_asset")]
     #[test]
     fn asset_animator_with_state() {
         for state in [AnimatorState::Playing, AnimatorState::Paused] {
@@ -733,6 +747,7 @@ mod tests {
     }
 
     /// AssetAnimator::default() + AssetAnimator::set_tweenable()
+    #[cfg(feature = "bevy_asset")]
     #[test]
     fn asset_animator_default() {
         let mut animator = AssetAnimator::<DummyAsset>::default();
@@ -753,6 +768,7 @@ mod tests {
     }
 
     /// AssetAnimator control playback
+    #[cfg(feature = "bevy_asset")]
     #[test]
     fn asset_animator_controls() {
         let tween = Tween::new(
diff --git a/src/plugin.rs b/src/plugin.rs
index 70cbe3e..c02d3f6 100644
--- a/src/plugin.rs
+++ b/src/plugin.rs
@@ -1,6 +1,12 @@
-use bevy::{asset::Asset, ecs::component::Component, prelude::*};
+use bevy::{ecs::component::Component, prelude::*};
 
-use crate::{Animator, AnimatorState, AssetAnimator, TweenCompleted};
+#[cfg(feature = "bevy_asset")]
+use bevy::asset::Asset;
+
+use crate::{Animator, AnimatorState, TweenCompleted};
+
+#[cfg(feature = "bevy_asset")]
+use crate::AssetAnimator;
 
 /// Plugin to add systems related to tweening of common components and assets.
 ///
@@ -25,11 +31,11 @@ use crate::{Animator, AnimatorState, AssetAnimator, TweenCompleted};
 /// add manually the relevant systems for the exact set of components and assets
 /// actually animated.
 ///
-/// [`Transform`]: https://docs.rs/bevy/0.7.0/bevy/transform/components/struct.Transform.html
-/// [`Text`]: https://docs.rs/bevy/0.7.0/bevy/text/struct.Text.html
-/// [`Style`]: https://docs.rs/bevy/0.7.0/bevy/ui/struct.Style.html
-/// [`Sprite`]: https://docs.rs/bevy/0.7.0/bevy/sprite/struct.Sprite.html
-/// [`ColorMaterial`]: https://docs.rs/bevy/0.7.0/bevy/sprite/struct.ColorMaterial.html
+/// [`Transform`]: https://docs.rs/bevy/0.8.0/bevy/transform/components/struct.Transform.html
+/// [`Text`]: https://docs.rs/bevy/0.8.0/bevy/text/struct.Text.html
+/// [`Style`]: https://docs.rs/bevy/0.8.0/bevy/ui/struct.Style.html
+/// [`Sprite`]: https://docs.rs/bevy/0.8.0/bevy/sprite/struct.Sprite.html
+/// [`ColorMaterial`]: https://docs.rs/bevy/0.8.0/bevy/sprite/struct.ColorMaterial.html
 #[derive(Debug, Clone, Copy)]
 pub struct TweeningPlugin;
 
@@ -44,10 +50,12 @@ impl Plugin for TweeningPlugin {
             .add_system(component_animator_system::<Style>.label(AnimationSystem::AnimationUpdate));
 
         #[cfg(feature = "bevy_sprite")]
-        app.add_system(component_animator_system::<Sprite>.label(AnimationSystem::AnimationUpdate))
-            .add_system(
-                asset_animator_system::<ColorMaterial>.label(AnimationSystem::AnimationUpdate),
-            );
+        app.add_system(component_animator_system::<Sprite>.label(AnimationSystem::AnimationUpdate));
+
+        #[cfg(all(feature = "bevy_sprite", feature = "bevy_asset"))]
+        app.add_system(
+            asset_animator_system::<ColorMaterial>.label(AnimationSystem::AnimationUpdate),
+        );
     }
 }
 
@@ -78,6 +86,9 @@ pub fn component_animator_system<T: Component>(
 ///
 /// This system ticks all `AssetAnimator<T>` components to animate their
 /// associated asset.
+///
+/// This requires the `bevy_asset` feature (enabled by default).
+#[cfg(feature = "bevy_asset")]
 pub fn asset_animator_system<T: Asset>(
     time: Res<Time>,
     mut assets: ResMut<Assets<T>>,
@@ -86,7 +97,7 @@ pub fn asset_animator_system<T: Asset>(
 ) {
     for (entity, ref mut animator) in query.iter_mut() {
         if animator.state != AnimatorState::Paused {
-            if let Some(target) = assets.get_mut(animator.handle()) {
+            if let Some(target) = assets.get_mut(&animator.handle()) {
                 animator.tick(time.delta(), target, entity, &mut event_writer);
             }
         }
-- 
GitLab