#bevy-inspector-egui

1094 messages Β· Page 2 of 2 (latest)

fierce yarrow
#

i recently disabled default feature to not depend on pbr

#

thanks sorry about that

kindred ingot
#

it's annoying, I've had such issues many times.
ideally the crate would automatically copy which features bevy has enabled but that's not something cargo can do

kindred ingot
#

I also dislike the default inspector's drop downs and am working on a better navigator for the hierarchy. It is currently pretty tied to my editor, but I'm planning to clean it up into something that can be used seperately

karmic jacinth
#

Hi, it looks like WorldInspectorPlugin is tied to first camera and once that camera is gone it's gone too.

How do I make it apply to all cameras ?

karmic jacinth
boreal sedge
#

how can i Reflect an enum that is 'States' such that it will show up in bevy_egui_inspector ??

nocturne prawn
# boreal sedge how can i Reflect an enum that is 'States' such that it will show up in bevy_egu...

This is what I do (in Bevy 0.16).

macro_rules! add_and_register_sub_state {
    ($app:expr, $state:ty) => {
        $app.add_sub_state::<$state>();
        $app.enable_state_scoped_entities::<$state>();
        #[cfg(feature = "reflect")]
        {
            $app.register_type::<State<$state>>();
            $app.register_type::<NextState<$state>>();
            $app.register_type::<DespawnOnExitState<$state>>();
        }
    };
}

// in a plugin
add_and_register_sub_state!(app, FooState);
weary bobcat
#

I'm having issues editing resources in the inspector

#

Specifically, I have a Resource with one field: a HashMap<String, Option<usize>>

#

I try to edit one of the entries in the HashMap, but the value won't change

#

Any ideas?

lost beacon
#

Hm, not off the top of my head

#

I'll have to reproduce it and check it out

#

Entirely possible that I broke that code during the 0.17 update

kindred ingot
#

Thinking about trying to rewrite the inspector to use reflection paths and defered (command based) mutation through the whole chain.

#

This would allow stuff like having a window which just shows Transform.translation. And means a normal &World could be passed around, instead of RestrictedWorldView

#

Does anyone see any immediate problems with this?

agile rain
grave lava
#

Hello, is there a way to keep the inspector in multiple cameras? I have a two camera setup, but only one of them is active at a any given time, but the inspector only shows on one of them. For the bevy_ui we can use IsDefaultUiCamera. Is there a way to do the same with the inspector?

kindred ingot
heady stag
#

Regardless, I think you will still need to tinker with bevy_egui directly.

faint plover
#

How do I make it so Entity (and other types) aren't reflect(opaque) ?

faint plover
#
  app
        .register_type_data::<u32, bevy_inspector_egui::inspector_egui_impls::InspectorEguiImpl>()
        .register_type_data::<u64, bevy_inspector_egui::inspector_egui_impls::InspectorEguiImpl>()
        .register_type_data::<std::borrow::Cow<str>, bevy_inspector_egui::inspector_egui_impls::InspectorEguiImpl>()
        .register_type_data::<Entity, bevy_inspector_egui::inspector_egui_impls::InspectorEguiImpl>()

I have to add this now? I didn't have to do this before.

lost beacon
#

are you doing your own custom UI? I'm not sure why you didn't have to do this before then

lost beacon
lost beacon
#

the quick inspectors just render to the PrimaryEguiContext

#

which can be on any camera, and if you don't add it then it gets auto-created on one camera

lost beacon
#

I think deferred modification and reflection paths instead of recursion are pretty orthogonal to each other, right?

lost beacon
kindred ingot
kindred ingot
sullen ferry
#

the world inspector doesnt appear on my lightyear server

#

it does on the client

#

both have defaultplugins

lost beacon
#

the problem with doing reflection paths for everything is that they are not actually expressive enough

#

for example, bevy-inspector-egui can resolve handles and let you edit StandardMaterial.color through a Handle<StandardMaterial>

#

One possiblity would be not to use reflection paths, but recursively construct a &dyn Fn(&dyn PartialReflect) -> &dyn PartialReflect that projects the original value down to field.

#

That's what I do for ui_for_reflect_many where you can edit multiple Transforms at the same time when you select multiple enemies

#

(this is not implemented in the quick world inspector, but in the egui_dock example and bevy_editor_pls)

#

it's a bit cursed but it works

kindred ingot
#

It's perhaps a design question whether the path for a value in the ui should be recursive like the ui, or if recursive ui should reset the path
in either case at minimum a path would require an extra bit of info for what component/asset it is associated with

#

I am tempted to have the paths reset. That way they are more directly tied to the ECS and component definitions than they are to the UI

#

I have been thinking though about how to deal with windows that are dynamic to the selection, vs windows that are tied to a specific entity / asset, vs windows that are tied to a defined query...

#

One of the bigger considerations is persistence: I want to be able to restore the editor state when restarting the game. Part of that is a question of how to represent the state of the inspector (what windows are visible... what entities and components are selected.)
And the other harder part is how to deal with scene loading (restoring a selection when the entity IDs don't persist, and scenes take time to load).

wraith bloom
viral prism
#

I'm currently upgrading to 0.17 using version 0.35.0, but as soon as I add the EguiPlugin I receive:

thread 'main' panicked at .cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_egui-0.38.0/src/lib.rs:1903:13:
Each Egui context running in the multi-pass mode must have a unique schedule (attempted to reuse schedule EguiPrimaryContextPass)
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: bevy_egui::run_egui_context_pass_loop_system
   3: bevy_ecs::system::system::System::run
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Encountered a panic in system `bevy_egui::run_egui_context_pass_loop_system`!
ERROR bevy_egui pass output has not been prepared (if EguiSettings::run_manually is set to true, make sure to call egui::Context::run or egui::Context::begin_pass and egui::Context::end_pass)
at .cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_egui-0.38.0/src/output.rs:39
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!
fatal runtime error: failed to initiate panic, error 5, aborting

Has anyone encountered a similar issue?

#

It happens when I spawn a camera with the PrimaryEguiContext component.

viral prism
#

Ok simply needed to set:

    mut egui_global_settings: ResMut<EguiGlobalSettings>
) {
    egui_global_settings.auto_create_primary_context = false;

Before spawning the first camera

wind kiln
#

Anyone got this error while using bevy_egui_inspector 0.35?
I am using nightly of for 9th of november?

   --> /home/lyndonm/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/egui-0.33.0/src/plugin.rs:219:32
    |
219 |             profiling::scope!(*_debug_name);
    |                                ^^^^^^^^^^^ non-constant value
    |
help: consider using `let` instead of `static`
   --> /home/lyndonm/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.41/src/macros.rs:58:13
    |
 58 -             static __CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
 58 +             let __CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
    |

error[E0435]: attempt to use a non-constant value in a constant
   --> /home/lyndonm/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/egui-0.33.0/src/plugin.rs:228:32
    |
228 |             profiling::scope!(*_debug_name);
    |                                ^^^^^^^^^^^ non-constant value
    |
help: consider using `let` instead of `static`
   --> /home/lyndonm/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tracing-0.1.41/src/macros.rs:58:13
    |
 58 -             static __CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
 58 +             let __CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {```
#

it's an egui error but I only use egui via the inspector?

fluid yew
#

woah, bevy docs in the inspector are cool

empty fiber
#

How can I specify what camera the inspector should be rendered to? I have the main Camera3d, and a Camera2d used for a texture. By default the inspector is rendering to the texture when I want it to be rendering to the main Camera3d view.

#

Somehow this wasn't an issue until bevy 0.17

kindred ingot
empty fiber
#

However, looking at the source code of one giving me issues, it already uses EguiPrimaryContextPass, so that doesn't seem to be helping.

kindred ingot
#

Docs are borked

empty fiber
#

Ok, so I added PrirmaryEguiContext to my Camera3d Entity, and inserted EguiGlobalSettings as a resource before any of my systems or plugins with auto_create_primary_context set to false, but i'm still getting the error.

wind kiln
white scroll
nocturne prawn
#

I added a PR for support for Disabled entities in the bevy egui inspector if anyone would like to review. https://github.com/jakobhellermann/bevy-inspector-egui/pull/302

Don't think the failing CI is due to my change.

cc @lost beacon if you are happy with this change, I'd (selfishly) love to get this merged and released before Bevy 0.18 (i.e., in a Bevy 0.17 bevy-inspector-egui release).

lost beacon
hazy finch
#

got an error on bevy 0.18 (bie 0.36):

error[E0599]: no method named `generate_tangents` found for mutable reference `&mut bevy_mesh::Mesh` in the current scope
   --> /Users/thierryberger/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bevy-inspector-egui-0.36.0/src/inspector_egui_impls/bevy_impls.rs:136:26
    |
136 |             let _ = mesh.generate_tangents();
    |                          ^^^^^^^^^^^^^^^^^ method not found in `&mut bevy_mesh::Mesh`

generate_tangents is gated behing bevy's feature bevy_mikktspace ; I'll add it manually, but it's probably best to add it as a dependency to bie and/or challenge its necessity, or gate it too.

mild vapor
#

sorry, having trouble searching .. i assumed this is a common question

#

is there a way to inspect a MeshMaterial2d?

amber atlas
#

Something changed in Bevy 0.18 and the inspector ui scale is WAY smaller on my 4k screen. It's fine on my desktop. I don't recall it being that bad before.
I've been trying UiScale but it doesn't seem to react to it. Any help here would be very appreciated. My debug UI is basically useless on my 4k screen.

#

Oh it's EguiSettings scale_factor.

royal frost
#

Hi. How can I create a filter for bevy_inspector_egui::bevy_inspector::ui_for_entities_filtered?
There is no example for this unfortunately

sage oriole
# royal frost Hi. How can I create a filter for bevy_inspector_egui::bevy_inspector::ui_for_en...

Hello, that function takes a Filter<F> argument, I made my own implementation of the ui_for_entities_filtered function for reasons, but for example to hide bevy's annoying Observers you should be able to do something like this:

pub type DefaultFilterNoObservers = (Without<ChildOf>, Without<Observer>);

// ...
let filter = Filter::<DefaultFilterNoObservers>::from_ui_fuzzy(ui, egui::Id::new("default_world_entities_filter"));
ui_for_entities_filtered(world, ui, true, &filter);

I do something similar and it works just fine, this example should work as well.

lime meadow
#

Hello, can I view curves in the world inspector? I am looking for something like unitys Animation Curves πŸ€”

sage oriole
#

Hello @lime meadow, technically speaking egui is able to render graphs and curves but AFAIK this plugin does not provide something like Animation Curves out-of-the-box :/

hot mulch
#

Does this func only work with uuid AssetIDs?
https://docs.rs/bevy-inspector-egui/latest/bevy_inspector_egui/bevy_inspector/by_type_id/fn.ui_for_asset.html

When using it with a UntypedHandle, it doesn't display anything (not even an error). When looking at it's implementation, it seems to only handle the uuid variants of the asset id

Is there a way I can display the ui based on a UntypedHandle obtained via assets.add().untyped() ?

hot mulch
#

or maybe there is a way to convert the handle into a uuid handle that I'm not seeing?

#

ok figured something out, copied the implementation and now instead I just pass the handle directly (not the AssetID) and do this:


/// Display a given asset by handle and asset [`TypeId`]
pub fn ui_for_asset(
    world: &mut World,
    asset_type_id: TypeId,
    handle: UntypedHandle,
    ui: &mut egui::Ui,
    type_registry: &TypeRegistry,
) -> bool {
    let Some(registration) = type_registry.get(asset_type_id) else {
        return false;
    };
    let Some(reflect_asset) = registration.data::<ReflectAsset>() else {
        return false;
    };
    let Some(reflect_handle) =
        type_registry.get_type_data::<ReflectHandle>(reflect_asset.handle_type_id())
    else {
        return false;
    };

    // Create a context with access to the entire world. Displaying the `Handle<T>` will short circuit into
    // displaying the T with a world view excluding Assets<T>.
    let world_view = RestrictedWorldView::new(world);
    let mut queue = CommandQueue::default();
    let mut cx = Context {
        world: Some(world_view),
        queue: Some(&mut queue),
    };

    let id = egui::Id::new(UntypedAssetId::from(&handle));

    let mut handle = reflect_handle.typed(handle).into_partial_reflect();

    let mut env = InspectorUi::for_bevy(type_registry, &mut cx);
    let changed = env.ui_for_reflect_with_options(&mut *handle, ui, id, &());

    queue.apply(world);

    changed
}
#

seems to work

#

conversely, simply doing ui_for_value(handle , ...) shows errors that the StrongHandle is not reflected or something, but this works for some reason πŸ€·β€β™‚οΈ

mild vapor
hot mulch
#

probably also was looking for something like it a long time ago and likely didn't find it because it was in the by_type_id module which is quite hidden in the docs I feel

#

probably found it through rust analyzer auto-import suggestions