diff --git a/examples/colormaterial_color.rs b/examples/colormaterial_color.rs index d22f9d30c604ffc8be9d626f61eaed9e8edba0c8..1810a2be457b9e07b9e199eb5d865b3651a995d8 100644 --- a/examples/colormaterial_color.rs +++ b/examples/colormaterial_color.rs @@ -7,14 +7,16 @@ use std::time::Duration; fn main() { App::default() - .insert_resource(WindowDescriptor { - title: "ColorMaterialColorLens".to_string(), - width: 1200., - height: 600., - present_mode: bevy::window::PresentMode::Fifo, // vsync + .add_plugins(DefaultPlugins.set(WindowPlugin { + window: WindowDescriptor { + title: "ColorMaterialColorLens".to_string(), + width: 1200., + height: 600., + present_mode: bevy::window::PresentMode::Fifo, // vsync + ..default() + }, ..default() - }) - .add_plugins(DefaultPlugins) + })) .add_system(bevy::window::close_on_esc) .add_plugin(TweeningPlugin) .add_startup_system(setup) @@ -26,7 +28,7 @@ fn setup( mut meshes: ResMut<Assets<Mesh>>, mut materials: ResMut<Assets<ColorMaterial>>, ) { - commands.spawn_bundle(Camera2dBundle::default()); + commands.spawn(Camera2dBundle::default()); let size = 80.; @@ -87,15 +89,16 @@ fn setup( .with_repeat_count(RepeatCount::Infinite) .with_repeat_strategy(RepeatStrategy::MirroredRepeat); - commands - .spawn_bundle(MaterialMesh2dBundle { + commands.spawn(( + MaterialMesh2dBundle { mesh: quad_mesh.clone(), transform: Transform::from_translation(Vec3::new(x, y, 0.)) .with_scale(Vec3::splat(size)), material: unique_material.clone(), ..default() - }) - .insert(AssetAnimator::new(unique_material.clone(), tween)); + }, + AssetAnimator::new(unique_material.clone(), tween), + )); y -= size * spacing; if y < -screen_y { x += size * spacing; diff --git a/examples/menu.rs b/examples/menu.rs index 244a99e18b6056a3d5ec64bba929b615b36b0142..f6c74718039f994892f231523691a981df9bcebf 100644 --- a/examples/menu.rs +++ b/examples/menu.rs @@ -22,14 +22,16 @@ const INIT_TRANSITION_DONE: u64 = 1; /// marker. fn main() { App::default() - .insert_resource(WindowDescriptor { - title: "Menu".to_string(), - width: 800., - height: 400., - present_mode: bevy::window::PresentMode::Fifo, // vsync + .add_plugins(DefaultPlugins.set(WindowPlugin { + window: WindowDescriptor { + title: "Menu".to_string(), + width: 800., + height: 400., + present_mode: bevy::window::PresentMode::Fifo, // vsync + ..default() + }, ..default() - }) - .add_plugins(DefaultPlugins) + })) .add_system(bevy::window::close_on_esc) .add_system(interaction) .add_system(enable_interaction_after_initial_animation) @@ -40,28 +42,30 @@ fn main() { } fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { - commands.spawn_bundle(Camera2dBundle::default()); + commands.spawn(Camera2dBundle::default()); let font = asset_server.load("fonts/FiraMono-Regular.ttf"); commands - .spawn_bundle(NodeBundle { - style: Style { - position_type: PositionType::Absolute, - 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, - align_self: AlignSelf::Center, - justify_content: JustifyContent::Center, + .spawn(( + NodeBundle { + style: Style { + position_type: PositionType::Absolute, + 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, + align_self: AlignSelf::Center, + justify_content: JustifyContent::Center, + ..default() + }, + background_color: BackgroundColor(Color::NONE), ..default() }, - color: UiColor(Color::NONE), - ..default() - }) - .insert(Name::new("menu")) + Name::new("menu"), + )) .with_children(|container| { let mut start_time_ms = 0; for (text, label) in [ @@ -89,29 +93,28 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { start_time_ms += 500; container - .spawn_bundle(ButtonBundle { - node: Node { - size: Vec2::new(300., 80.), - }, - 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, + .spawn(( + ButtonBundle { + 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() + }, + background_color: BackgroundColor(NORMAL_COLOR), + transform: Transform::from_scale(Vec3::splat(0.01)), ..default() }, - color: UiColor(NORMAL_COLOR), - transform: Transform::from_scale(Vec3::splat(0.01)), - ..default() - }) - .insert(Name::new(format!("button:{}", text))) - .insert(animator) - .insert(label) + Name::new(format!("button:{}", text)), + animator, + label, + )) .with_children(|parent| { - parent.spawn_bundle(TextBundle { + parent.spawn(TextBundle { text: Text::from_section( text.to_string(), TextStyle { @@ -159,7 +162,7 @@ fn interaction( &mut Animator<Transform>, &Transform, &Interaction, - &mut UiColor, + &mut BackgroundColor, &ButtonLabel, ), (Changed<Interaction>, With<InitTransitionDone>), diff --git a/examples/sequence.rs b/examples/sequence.rs index 2d43fb97e9f7e362322a581719ee9cf36d71aa0d..51f22f0be3cef529894f890a5b5961556bd6d981 100644 --- a/examples/sequence.rs +++ b/examples/sequence.rs @@ -6,14 +6,16 @@ use bevy_tweening::{lens::*, *}; fn main() { App::default() - .insert_resource(WindowDescriptor { - title: "Sequence".to_string(), - width: 600., - height: 600., - present_mode: bevy::window::PresentMode::Fifo, // vsync + .add_plugins(DefaultPlugins.set(WindowPlugin { + window: WindowDescriptor { + title: "Sequence".to_string(), + width: 600., + height: 600., + present_mode: bevy::window::PresentMode::Fifo, // vsync + ..default() + }, ..default() - }) - .add_plugins(DefaultPlugins) + })) .add_system(bevy::window::close_on_esc) .add_plugin(TweeningPlugin) .add_startup_system(setup) @@ -34,7 +36,7 @@ struct RedSprite; struct BlueSprite; fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { - commands.spawn_bundle(Camera2dBundle::default()); + commands.spawn(Camera2dBundle::default()); let font = asset_server.load("fonts/FiraMono-Regular.ttf"); let text_style_red = TextStyle { @@ -54,8 +56,8 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { }; // Text with the index of the active tween in the sequence - commands - .spawn_bundle(Text2dBundle { + commands.spawn(( + Text2dBundle { text: Text { sections: vec![ TextSection { @@ -71,12 +73,13 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { }, transform: Transform::from_translation(Vec3::new(0., 40., 0.)), ..default() - }) - .insert(RedProgress); + }, + RedProgress, + )); // Text with progress of the active tween in the sequence - commands - .spawn_bundle(Text2dBundle { + commands.spawn(( + Text2dBundle { text: Text { sections: vec![ TextSection { @@ -92,8 +95,9 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { }, transform: Transform::from_translation(Vec3::new(0., -40., 0.)), ..default() - }) - .insert(BlueProgress); + }, + BlueProgress, + )); let size = 25.; @@ -137,17 +141,18 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { ]) })); - commands - .spawn_bundle(SpriteBundle { + commands.spawn(( + SpriteBundle { sprite: Sprite { color: Color::RED, custom_size: Some(Vec2::new(size, size)), ..default() }, ..default() - }) - .insert(RedSprite) - .insert(Animator::new(seq)); + }, + RedSprite, + Animator::new(seq), + )); // First move from left to right, then rotate around self 180 degrees while // scaling size at the same time. @@ -183,17 +188,18 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { // manually to a BoxedTweenable: first move, then { rotate + scale }. let seq2 = Sequence::new([Box::new(tween_move) as BoxedTweenable<_>, tracks.into()]); - commands - .spawn_bundle(SpriteBundle { + commands.spawn(( + SpriteBundle { sprite: Sprite { color: Color::BLUE, custom_size: Some(Vec2::new(size * 3., size)), ..default() }, ..Default::default() - }) - .insert(BlueSprite) - .insert(Animator::new(seq2)); + }, + BlueSprite, + Animator::new(seq2), + )); } fn update_text( diff --git a/examples/sprite_color.rs b/examples/sprite_color.rs index ca6e6e3511314507c4915fc85c015bd8a9d1e694..b41c9e408022b19cba32620ad8be1448a6c2ddda 100644 --- a/examples/sprite_color.rs +++ b/examples/sprite_color.rs @@ -3,14 +3,16 @@ use bevy_tweening::{lens::*, *}; fn main() { App::default() - .insert_resource(WindowDescriptor { - title: "SpriteColorLens".to_string(), - width: 1200., - height: 600., - present_mode: bevy::window::PresentMode::Fifo, // vsync + .add_plugins(DefaultPlugins.set(WindowPlugin { + window: WindowDescriptor { + title: "SpriteColorLens".to_string(), + width: 1200., + height: 600., + present_mode: bevy::window::PresentMode::Fifo, // vsync + ..default() + }, ..default() - }) - .add_plugins(DefaultPlugins) + })) .add_system(bevy::window::close_on_esc) .add_plugin(TweeningPlugin) .add_startup_system(setup) @@ -18,7 +20,7 @@ fn main() { } fn setup(mut commands: Commands) { - commands.spawn_bundle(Camera2dBundle::default()); + commands.spawn(Camera2dBundle::default()); let size = 80.; @@ -71,8 +73,8 @@ fn setup(mut commands: Commands) { .with_repeat_count(RepeatCount::Infinite) .with_repeat_strategy(RepeatStrategy::MirroredRepeat); - commands - .spawn_bundle(SpriteBundle { + commands.spawn(( + SpriteBundle { transform: Transform::from_translation(Vec3::new(x, y, 0.)), sprite: Sprite { color: Color::BLACK, @@ -80,8 +82,9 @@ fn setup(mut commands: Commands) { ..default() }, ..default() - }) - .insert(Animator::new(tween)); + }, + Animator::new(tween), + )); y -= size * spacing; if y < -screen_y { diff --git a/examples/text_color.rs b/examples/text_color.rs index 25fd6c485982a9fe3201056c94cbaad48ba8b533..593049a4fe10d6037216af4d22d6dbe7be3d94f6 100644 --- a/examples/text_color.rs +++ b/examples/text_color.rs @@ -6,14 +6,16 @@ const HEIGHT: f32 = 600.; fn main() { App::default() - .insert_resource(WindowDescriptor { - title: "TextColorLens".to_string(), - width: WIDTH, - height: HEIGHT, - present_mode: bevy::window::PresentMode::Fifo, // vsync + .add_plugins(DefaultPlugins.set(WindowPlugin { + window: WindowDescriptor { + title: "TextColorLens".to_string(), + width: WIDTH, + height: HEIGHT, + present_mode: bevy::window::PresentMode::Fifo, // vsync + ..default() + }, ..default() - }) - .add_plugins(DefaultPlugins) + })) .add_system(bevy::window::close_on_esc) .add_plugin(TweeningPlugin) .add_startup_system(setup) @@ -21,7 +23,7 @@ fn main() { } fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { - commands.spawn_bundle(Camera2dBundle::default()); + commands.spawn(Camera2dBundle::default()); let font = asset_server.load("fonts/FiraMono-Regular.ttf"); @@ -79,8 +81,8 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { .with_repeat_count(RepeatCount::Infinite) .with_repeat_strategy(RepeatStrategy::MirroredRepeat); - commands - .spawn_bundle(TextBundle { + commands.spawn(( + TextBundle { style: Style { size: Size::new(Val::Px(size_x), Val::Px(size_y)), position: UiRect { @@ -105,8 +107,9 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { }, ), ..default() - }) - .insert(Animator::new(tween)); + }, + Animator::new(tween), + )); y += delta_y; iy += 1; diff --git a/examples/transform_rotation.rs b/examples/transform_rotation.rs index 67626f694b34be9bfe5f2b245080fda108a48d0c..7ecd79f0bc625fd69521bfd36f1761eb5c7bf159 100644 --- a/examples/transform_rotation.rs +++ b/examples/transform_rotation.rs @@ -5,14 +5,16 @@ use bevy_tweening::{lens::*, *}; fn main() { App::default() - .insert_resource(WindowDescriptor { - title: "TransformRotationLens".to_string(), - width: 1400., - height: 600., - present_mode: bevy::window::PresentMode::Fifo, // vsync + .add_plugins(DefaultPlugins.set(WindowPlugin { + window: WindowDescriptor { + title: "TransformRotationLens".to_string(), + width: 1400., + height: 600., + present_mode: bevy::window::PresentMode::Fifo, // vsync + ..default() + }, ..default() - }) - .add_plugins(DefaultPlugins) + })) .add_system(bevy::window::close_on_esc) .add_plugin(TweeningPlugin) .add_plugin(InspectorPlugin::<Options>::new()) @@ -21,7 +23,7 @@ fn main() { .run(); } -#[derive(Copy, Clone, PartialEq, Inspectable)] +#[derive(Copy, Clone, PartialEq, Inspectable, Resource)] struct Options { #[inspectable(min = 0.01, max = 100.)] speed: f32, @@ -34,7 +36,7 @@ impl Default for Options { } fn setup(mut commands: Commands) { - commands.spawn_bundle(Camera2dBundle::default()); + commands.spawn(Camera2dBundle::default()); let size = 80.; @@ -88,21 +90,22 @@ fn setup(mut commands: Commands) { .with_repeat_strategy(RepeatStrategy::MirroredRepeat); commands - .spawn_bundle(SpatialBundle { + .spawn(SpatialBundle { transform: Transform::from_translation(Vec3::new(x, y, 0.)), ..default() }) .with_children(|parent| { - parent - .spawn_bundle(SpriteBundle { + parent.spawn(( + SpriteBundle { sprite: Sprite { color: Color::RED, custom_size: Some(Vec2::new(size, size * 0.5)), ..default() }, ..default() - }) - .insert(Animator::new(tween)); + }, + Animator::new(tween), + )); }); y -= size * spacing; diff --git a/examples/transform_translation.rs b/examples/transform_translation.rs index 74cbf750648a919589926d3e8e64cbd8e8d5185b..d71ea2def28d5c69ae1a84f4555b56da98e6572f 100644 --- a/examples/transform_translation.rs +++ b/examples/transform_translation.rs @@ -5,14 +5,16 @@ use bevy_tweening::{lens::*, *}; fn main() { App::default() - .insert_resource(WindowDescriptor { - title: "TransformPositionLens".to_string(), - width: 1400., - height: 600., - present_mode: bevy::window::PresentMode::Fifo, // vsync + .add_plugins(DefaultPlugins.set(WindowPlugin { + window: WindowDescriptor { + title: "TransformPositionLens".to_string(), + width: 1400., + height: 600., + present_mode: bevy::window::PresentMode::Fifo, // vsync + ..default() + }, ..default() - }) - .add_plugins(DefaultPlugins) + })) .add_system(bevy::window::close_on_esc) .add_plugin(TweeningPlugin) .add_plugin(InspectorPlugin::<Options>::new()) @@ -21,7 +23,7 @@ fn main() { .run(); } -#[derive(Copy, Clone, PartialEq, Inspectable)] +#[derive(Copy, Clone, PartialEq, Inspectable, Resource)] struct Options { #[inspectable(min = 0.01, max = 100.)] speed: f32, @@ -34,7 +36,7 @@ impl Default for Options { } fn setup(mut commands: Commands) { - commands.spawn_bundle(Camera2dBundle::default()); + commands.spawn(Camera2dBundle::default()); let size = 25.; @@ -86,16 +88,17 @@ fn setup(mut commands: Commands) { .with_repeat_count(RepeatCount::Infinite) .with_repeat_strategy(RepeatStrategy::MirroredRepeat); - commands - .spawn_bundle(SpriteBundle { + commands.spawn(( + SpriteBundle { sprite: Sprite { color: Color::RED, custom_size: Some(Vec2::new(size, size)), ..default() }, ..default() - }) - .insert(Animator::new(tween)); + }, + Animator::new(tween), + )); x += size * spacing; } diff --git a/examples/ui_position.rs b/examples/ui_position.rs index e091e1899208a8fec547f729c12edb5e592f6c2b..76b7ff63556e0c2f22f4fc52d00a5e5fdd76aec6 100644 --- a/examples/ui_position.rs +++ b/examples/ui_position.rs @@ -5,14 +5,16 @@ use bevy_tweening::{lens::*, *}; fn main() { App::default() - .insert_resource(WindowDescriptor { - title: "UiPositionLens".to_string(), - width: 1400., - height: 600., - present_mode: bevy::window::PresentMode::Fifo, // vsync + .add_plugins(DefaultPlugins.set(WindowPlugin { + window: WindowDescriptor { + title: "UiPositionLens".to_string(), + width: 1400., + height: 600., + present_mode: bevy::window::PresentMode::Fifo, // vsync + ..default() + }, ..default() - }) - .add_plugins(DefaultPlugins) + })) .add_system(bevy::window::close_on_esc) .add_plugin(TweeningPlugin) .add_plugin(InspectorPlugin::<Options>::new()) @@ -21,7 +23,7 @@ fn main() { .run(); } -#[derive(Copy, Clone, PartialEq, Inspectable)] +#[derive(Copy, Clone, PartialEq, Inspectable, Resource)] struct Options { #[inspectable(min = 0.01, max = 100.)] speed: f32, @@ -34,7 +36,7 @@ impl Default for Options { } fn setup(mut commands: Commands) { - commands.spawn_bundle(Camera2dBundle::default()); + commands.spawn(Camera2dBundle::default()); let size = 25.; @@ -96,8 +98,8 @@ fn setup(mut commands: Commands) { .with_repeat_count(RepeatCount::Infinite) .with_repeat_strategy(RepeatStrategy::MirroredRepeat); - commands - .spawn_bundle(NodeBundle { + commands.spawn(( + NodeBundle { style: Style { size: Size::new(Val::Px(size), Val::Px(size)), position: UiRect { @@ -113,10 +115,11 @@ fn setup(mut commands: Commands) { justify_content: JustifyContent::Center, ..default() }, - color: UiColor(Color::RED), + background_color: BackgroundColor(Color::RED), ..default() - }) - .insert(Animator::new(tween)); + }, + Animator::new(tween), + )); x += offset_x; } diff --git a/release.md b/release.md index c51f92f3f28056b57e4b8f017fd819b758847699..39bd848e8f915481d757486a8c5cdbd18c258264 100644 --- a/release.md +++ b/release.md @@ -6,7 +6,11 @@ - Update other documentation links to point to the new Bevy release (if any) on `docs.rs` - `cargo fmt --all` - `cargo test --no-default-features` +- `cargo test --no-default-features --features="bevy_ui"` +- `cargo test --no-default-features --features="bevy_sprite"` +- `cargo test --no-default-features --features="bevy_text"` +- `cargo test --no-default-features --features="bevy_asset"` - `cargo test --all-features` - `cargo clippy --workspace --all-targets --all-features -- -D warnings` -- `cargo doc --no-deps` - `cargo +nightly build --all-features` (for `docs.rs`) +- `cargo +nightly doc --all-features --no-deps` diff --git a/src/lib.rs b/src/lib.rs index 1c1fc6ae20901b3102cda768b8ff05eecadb26b7..e1e083cf2fe72dd5b64b37937d488fc2752a3075 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -55,11 +55,12 @@ //! }, //! ); //! -//! commands +//! commands.spawn(( //! // Spawn an entity to animate the position of. -//! .spawn_bundle(TransformBundle::default()) +//! TransformBundle::default(), //! // Add an Animator component to control and execute the animation. -//! .insert(Animator::new(tween)); +//! Animator::new(tween), +//! )); //! # } //! ``` //!