From 5ad8ac78dd9a2e0d4ec614010775a2d5d3b444eb Mon Sep 17 00:00:00 2001 From: Cyannide Date: Sat, 5 Aug 2023 03:20:40 -0500 Subject: [PATCH] Updated to Bevy 0.11 (#29) Updated to Bevy 0.11 --- Cargo.toml | 6 +++--- README.md | 3 ++- examples/2d_text.rs | 4 ++-- examples/3d_scene.rs | 24 ++++++++++++++++------ examples/performance.rs | 42 +++++++++++++++++++++++--------------- src/font_loader.rs | 4 ++-- src/lib.rs | 8 ++++++-- src/mesh_data_generator.rs | 4 ++++ 8 files changed, 63 insertions(+), 32 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3495d92..d851aee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_text_mesh" -version = "0.6.0" +version = "0.7.0" edition = "2021" description = "A bevy 3D text mesh generator for displaying text" repository = "https://github.com/blaind/bevy_text_mesh" @@ -16,7 +16,7 @@ anyhow = "1.0" glyph_brush_layout = "0.2.3" [dependencies.bevy] -version = "0.10.0" +version = "0.11.0" default-features = false features = ["bevy_render", "bevy_text", "bevy_pbr", "bevy_asset", "bevy_sprite"] @@ -24,7 +24,7 @@ features = ["bevy_render", "bevy_text", "bevy_pbr", "bevy_asset", "bevy_sprite"] rand = "0.8.4" [dev-dependencies.bevy] -version = "0.10.0" +version = "0.11.0" default-features = false features = [ "bevy_winit", diff --git a/README.md b/README.md index 9473d36..9ded8bd 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Consider this as a preview of the plugin for gathering feedback about the API: | bevy | bevy_text_mesh | | ---- | -------------- | +| 0.11 | 0.7.0 | | 0.10 | 0.6.0 | | 0.9 | 0.5.0 | | 0.8 | 0.4.0 | @@ -60,7 +61,7 @@ Add to Cargo.toml: ``` [dependencies] -bevy_text_mesh = "0.6.0" +bevy_text_mesh = "0.7.0" ``` Include the library: diff --git a/examples/2d_text.rs b/examples/2d_text.rs index 75936d0..4b2e150 100644 --- a/examples/2d_text.rs +++ b/examples/2d_text.rs @@ -3,8 +3,8 @@ use bevy::prelude::*; fn main() { App::new() .add_plugins(DefaultPlugins) - .add_startup_system(setup) - .add_system(animate_rotation) + .add_systems(Startup, setup) + .add_systems(Update, animate_rotation) .run(); } diff --git a/examples/3d_scene.rs b/examples/3d_scene.rs index 18fbcdb..cebc797 100644 --- a/examples/3d_scene.rs +++ b/examples/3d_scene.rs @@ -6,12 +6,24 @@ use bevy_text_mesh::prelude::*; fn main() { App::new() .insert_resource(Msaa::Sample4) - .add_plugins(DefaultPlugins) - .add_plugin(TextMeshPlugin) - .add_startup_system(setup) - .add_startup_system(setup_text_mesh) - .add_system(update_text_mesh) - .add_system(rotate_camera) + .add_plugins( + ( + DefaultPlugins, + TextMeshPlugin, + ) + ) + .add_systems(Startup, + ( + setup, + setup_text_mesh.after(setup), + ) + ) + .add_systems(Update, + ( + update_text_mesh, + rotate_camera, + ) + ) .run(); } diff --git a/examples/performance.rs b/examples/performance.rs index 5165fc8..1632995 100644 --- a/examples/performance.rs +++ b/examples/performance.rs @@ -2,7 +2,7 @@ use std::time::Duration; use bevy::{ diagnostic::{ - Diagnostic, DiagnosticId, Diagnostics, FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin, + Diagnostic, DiagnosticId, Diagnostics, DiagnosticsStore, FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin, RegisterDiagnostic }, prelude::*, render::camera::Camera, @@ -28,16 +28,29 @@ const INITIAL_WAIT_MS: u64 = 500; fn main() { App::new() .insert_resource(Msaa::Sample4) - .add_plugins(DefaultPlugins) - .add_plugin(TextMeshPlugin) - .add_plugin(FrameTimeDiagnosticsPlugin::default()) - .add_plugin(LogDiagnosticsPlugin::default()) - .add_startup_system(setup) - .add_startup_system(setup_text_mesh) - .add_system(spawn_meshes) - .add_system(update_text_mesh) - .add_system(rotate_camera) - .add_system(update_frame_rate.in_base_set(CoreSet::PostUpdate)) + .add_plugins(( + DefaultPlugins, + TextMeshPlugin, + FrameTimeDiagnosticsPlugin::default(), + LogDiagnosticsPlugin::default(), + )) + .register_diagnostic( + Diagnostic::new(TEXT_MESH_UPDATES, "text_mesh_updates", 20) + ) + .add_systems(Startup, + ( + setup, + setup_text_mesh, + ) + ) + .add_systems(Update, + ( + spawn_meshes, + update_text_mesh, + rotate_camera, + ) + ) + .add_systems(PostUpdate, update_frame_rate) .run(); } @@ -69,13 +82,10 @@ pub const TEXT_MESH_UPDATES: DiagnosticId = DiagnosticId::from_u128(1082410928401928501928509128509125); fn setup_text_mesh( - mut diagnostics: ResMut, mut materials: ResMut>, mut commands: Commands, asset_server: Res, ) { - diagnostics.add(Diagnostic::new(TEXT_MESH_UPDATES, "text_mesh_updates", 20)); - let state = SceneState { font: asset_server.load("fonts/FiraMono-Medium.ttf#mesh"), text_count: 0, @@ -187,7 +197,7 @@ fn spawn_meshes( } fn update_text_mesh( - mut diagnostics: ResMut, + mut diagnostics: Diagnostics, mut text_meshes: Query<&mut TextMesh, With>, time: Res