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

Use the most recent PRs on the bevy_egui and bevy-inspector-egui crates for Bevy 0.15. #22

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
58 changes: 30 additions & 28 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@ version = "0.5.1"
edition = "2021"

[features]
#default = ['editor_bevy', 'bevy_reflect']
default = ['bevy_asset']
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_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']
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']

[dependencies]
bevy_math = { version = "0.15.0-rc.2", default-features = false }
Expand All @@ -36,38 +35,38 @@ 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 = { git = "https://github.com/Vrixyz/bevy_egui.git", branch = "bevy_main", 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 = { git = "https://github.com/Vrixyz/bevy-inspector-egui.git", branch = "bevy_0.15", default-features = false, features = ["bevy_render"], optional = true }
egui_plot = { version = "0.29", optional = true }

[dev-dependencies]
bevy = "0.15.0-rc.2"
# bevy-inspector-egui = "0.26.0"
bevy-inspector-egui = { git = "https://github.com/Vrixyz/bevy-inspector-egui.git", branch = "bevy_0.15" }
criterion = "0.5.1"
rand = "0.8.5"
# eframe = "0.28"
eframe = "0.29"

# [[example]]
# name = "dev"
# path = "examples/dev.rs"
# required-features = ["editor_bevy", "bevy_reflect"]
[[example]]
name = "dev"
path = "examples/dev.rs"
required-features = ["editor_bevy", "bevy_reflect"]

# [[example]]
# name = "animation"
# path = "examples/animation.rs"
# required-features = ["editor_egui"]
[[example]]
name = "animation"
path = "examples/animation.rs"
required-features = ["editor_egui"]

# [[example]]
# name = "egui_only"
# path = "examples/egui_only.rs"
# required-features = ["editor_egui", "ron"]
[[example]]
name = "egui_only"
path = "examples/egui_only.rs"
required-features = ["editor_egui", "ron"]

# [[example]]
# name = "inspector_egui"
# path = "examples/inspector_egui.rs"
# required-features = ["inspector-egui"]
[[example]]
name = "inspector_egui"
path = "examples/inspector_egui.rs"
required-features = ["inspector-egui"]

# [[bench]]
# name = "lookup_curve"
Expand All @@ -78,3 +77,6 @@ rand = "0.8.5"
name = "knot_search"
path = "benches/knot_search.rs"
harness = false

[patch.crates-io]
bevy_egui = { git = "https://github.com/Vrixyz/bevy_egui.git", branch = "bevy_main" }
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
38 changes: 18 additions & 20 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,33 @@ use knot_search::KnotSearch;
#[cfg(feature = "bevy_asset")]
pub mod asset;

//#[cfg(feature = "editor_egui")]
//pub mod editor;
#[cfg(feature = "editor_egui")]
pub mod editor;

// #[cfg(feature = "inspector-egui")]
// mod inspector;
#[cfg(feature = "inspector-egui")]
mod inspector;

/// Registers the asset loader and editor components
// #[cfg(any(
// feature = "bevy_asset",
// feature = "editor_bevy",
// feature = "inspector-egui"
// ))]
#[cfg(feature = "bevy_asset")]
#[cfg(any(
feature = "bevy_asset",
feature = "editor_bevy",
feature = "inspector-egui"
))]
pub struct LookupCurvePlugin;

// #[cfg(any(
// feature = "bevy_asset",
// feature = "editor_bevy",
// feature = "inspector-egui"
// ))]
#[cfg(feature = "bevy_asset")]
#[cfg(any(
feature = "bevy_asset",
feature = "editor_bevy",
feature = "inspector-egui"
))]
impl bevy_app::Plugin for LookupCurvePlugin {
fn build(&self, app: &mut bevy_app::App) {
#[cfg(feature = "bevy_asset")]
app.add_plugins(asset::AssetPlugin);
// #[cfg(feature = "editor_bevy")]
// app.add_plugins(editor::EditorPlugin);
// #[cfg(feature = "inspector-egui")]
// app.add_plugins(inspector::InspectorPlugin);
#[cfg(feature = "editor_bevy")]
app.add_plugins(editor::EditorPlugin);
#[cfg(feature = "inspector-egui")]
app.add_plugins(inspector::InspectorPlugin);
}
}

Expand Down
Loading