Skip to content

Commit

Permalink
Bevy 0.15 (#21)
Browse files Browse the repository at this point in the history
* Comment out egui-dependant stuff for now

* Migrate asset loader to 0.15

* Migrate bundles to required components

* delta_seconds -> delta_secs

* Temporarily use egui-dependent PR branches.

* Uncomment the egui stuff.

* Update InspectorEguiImplFnMany to match the bevy-inspector-egui definition.

* Bump deps

---------

Co-authored-by: andriyDev <[email protected]>
  • Loading branch information
villor and andriyDev authored Dec 3, 2024
1 parent 7bf5420 commit 103129f
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 36 deletions.
50 changes: 34 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,57 @@ edition = "2021"
default = ['editor_bevy', 'bevy_reflect']
serialize = ['dep:serde', 'bevy_math/serialize']
ron = ['serialize', 'dep:ron', 'dep:thiserror']
bevy_reflect = ['dep:bevy_reflect', 'bevy_math/bevy_reflect', 'bevy_app?/bevy_reflect', 'bevy_ecs?/bevy_reflect']
bevy_reflect = [
'dep:bevy_reflect',
'bevy_math/bevy_reflect',
'bevy_app?/bevy_reflect',
'bevy_ecs?/bevy_reflect',
]
bevy_app = ['dep:bevy_app', 'dep:bevy_log']
bevy_asset = ['ron', 'bevy_app', 'bevy_reflect', 'dep:bevy_asset']
bevy_egui = ['dep:bevy_egui', 'dep:bevy_winit', 'bevy_winit/x11']
editor_egui = ['dep:egui']
editor_bevy = ['bevy_app', 'bevy_ecs', 'bevy_asset', 'bevy_egui', 'editor_egui']
inspector-egui = ['bevy_reflect', 'bevy_app', 'bevy_ecs', 'bevy_asset', 'bevy_egui', 'editor_egui', 'dep:bevy-inspector-egui', 'dep:egui_plot']
inspector-egui = [
'bevy_reflect',
'bevy_app',
'bevy_ecs',
'bevy_asset',
'bevy_egui',
'editor_egui',
'dep:bevy-inspector-egui',
'dep:egui_plot',
]

[dependencies]
bevy_math = { version = "0.14", default-features = false }
bevy_reflect = { version = "0.14", default-features = false, optional = true }
bevy_app = { version = "0.14", default-features = false, optional = true }
bevy_ecs = { version = "0.14", default-features = false, optional = true }
bevy_asset = { version = "0.14", optional = true }
bevy_log = { version = "0.14", default-features = false, optional = true }
bevy_winit = { version = "0.14", default-features = false, optional = true }
bevy_math = { version = "0.15", default-features = false }
bevy_reflect = { version = "0.15", default-features = false, optional = true }
bevy_app = { version = "0.15", default-features = false, optional = true }
bevy_ecs = { version = "0.15", default-features = false, optional = true }
bevy_asset = { version = "0.15", optional = true }
bevy_log = { version = "0.15", default-features = false, optional = true }
bevy_winit = { version = "0.15", default-features = false, optional = true }

thiserror = { version = "1.0", optional = true }
serde = { version = "1.0", optional = true }
ron = { version = "0.8", optional = true }

egui = { version = "0.28", optional = true }
bevy_egui = { version = "0.29", default-features = false, features = ["render"], optional = true }
egui = { version = "0.29", optional = true }
bevy_egui = { version = "0.31", default-features = false, features = [
"render",
], optional = true }

bevy-inspector-egui = { version = "0.26.0", default-features = false, features = ["bevy_render"], optional = true }
egui_plot = { version = "0.28", optional = true }
bevy-inspector-egui = { version = "0.28.0", default-features = false, features = [
"bevy_render",
], optional = true }
egui_plot = { version = "0.29", optional = true }

[dev-dependencies]
bevy = "0.14"
bevy-inspector-egui = "0.26.0"
bevy = "0.15"
bevy-inspector-egui = { version = "0.28.0" }
criterion = "0.5.1"
rand = "0.8.5"
eframe = "0.28"
eframe = "0.29"

[[example]]
name = "dev"
Expand Down
11 changes: 4 additions & 7 deletions examples/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@ struct AnimationCache(LookupCache);
struct EditorWindow(LookupCurveEguiEditor);

fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn(Camera2dBundle::default());
commands.spawn(Camera2d);
commands.spawn((
SpriteBundle {
texture: asset_server.load("bevy_icon.png"),
transform: Transform::from_xyz(0., -200., 0.).with_scale(Vec3::splat(0.5)),
..default()
},
Sprite::from_image(asset_server.load("bevy_icon.png")),
Transform::from_xyz(0., -200., 0.).with_scale(Vec3::splat(0.5)),
AnimateX {
from: -400.0,
to: 400.0,
Expand Down Expand Up @@ -82,7 +79,7 @@ fn update(
for (entity, mut transform, mut animate, mut curve, mut cache, mut editor) in animate.iter_mut()
{
// update t
animate.t += animate.dir * animate.speed * time.delta_seconds();
animate.t += animate.dir * animate.speed * time.delta_secs();
if animate.t >= 1.0 {
animate.dir = -1.0;
animate.t = 1.0;
Expand Down
2 changes: 1 addition & 1 deletion examples/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn move_sample(
} else if dev_state.sample <= -0.5 {
dev_state.sample_dir = 1.0;
}
dev_state.sample += time.delta_seconds() * 0.3 * dev_state.sample_dir;
dev_state.sample += time.delta_secs() * 0.3 * dev_state.sample_dir;
}
editor.sample = Some(dev_state.sample)
}
Expand Down
12 changes: 6 additions & 6 deletions src/asset.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy_app::{App, Plugin};
use bevy_asset::{io::Reader, AssetApp, AssetLoader, AsyncReadExt, LoadContext};
use bevy_asset::{io::Reader, AssetApp, AssetLoader, LoadContext};

use crate::{LookupCurve, LookupCurveLoadError};

Expand All @@ -20,11 +20,11 @@ impl AssetLoader for LookupCurveAssetLoader {
type Settings = ();
type Error = LookupCurveLoadError;

async fn load<'a>(
&'a self,
reader: &'a mut Reader<'_>,
_settings: &'a (),
_load_context: &'a mut LoadContext<'_>,
async fn load(
&self,
reader: &mut dyn Reader,
_settings: &(),
_load_context: &mut LoadContext<'_>,
) -> Result<Self::Asset, Self::Error> {
let mut bytes = Vec::new();
reader.read_to_end(&mut bytes).await?;
Expand Down
14 changes: 8 additions & 6 deletions src/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ use std::{
use crate::{editor::LookupCurveEguiEditor, LookupCache, LookupCurve};
use bevy_app::{App, Plugin};
use bevy_asset::{Assets, Handle};
use bevy_inspector_egui::inspector_egui_impls::InspectorEguiImpl;
use bevy_inspector_egui::reflect_inspector::InspectorUi;
use bevy_reflect::{Reflect, TypeRegistry};
use bevy_inspector_egui::{
inspector_egui_impls::InspectorEguiImpl, reflect_inspector::ProjectorReflect,
};
use bevy_reflect::{PartialReflect, TypeRegistry};

pub(crate) struct InspectorPlugin;

Expand Down Expand Up @@ -44,8 +46,8 @@ type InspectorEguiImplFnMany = for<'a> fn(
&dyn Any,
egui::Id,
InspectorUi<'_, '_>,
&mut [&mut dyn Reflect],
&dyn Fn(&mut dyn Reflect) -> &mut dyn Reflect,
&mut [&mut dyn PartialReflect],
&dyn ProjectorReflect,
) -> bool;

fn add_raw<T: 'static>(
Expand All @@ -65,8 +67,8 @@ fn many_unimplemented(
_options: &dyn Any,
_id: egui::Id,
_env: InspectorUi<'_, '_>,
_values: &mut [&mut dyn Reflect],
_projector: &dyn Fn(&mut dyn Reflect) -> &mut dyn Reflect,
_values: &mut [&mut dyn PartialReflect],
_projector: &dyn ProjectorReflect,
) -> bool {
ui.label("LookupCurve does not support multi-editing.");
false
Expand Down

0 comments on commit 103129f

Please sign in to comment.