diff --git a/crates/bevy-inspector-egui/examples/basic/inspector_options.rs b/crates/bevy-inspector-egui/examples/basic/inspector_options.rs index a439a125..57904d66 100644 --- a/crates/bevy-inspector-egui/examples/basic/inspector_options.rs +++ b/crates/bevy-inspector-egui/examples/basic/inspector_options.rs @@ -1,5 +1,3 @@ -use std::time::Duration; - use bevy::prelude::*; use bevy_egui::EguiContext; use bevy_inspector_egui::inspector_options::std_options::NumberDisplay; diff --git a/crates/bevy-inspector-egui/src/inspector_egui_impls/mod.rs b/crates/bevy-inspector-egui/src/inspector_egui_impls/mod.rs index 0cc8741f..1c8139b0 100644 --- a/crates/bevy-inspector-egui/src/inspector_egui_impls/mod.rs +++ b/crates/bevy-inspector-egui/src/inspector_egui_impls/mod.rs @@ -1,6 +1,7 @@ //! Custom UI implementations for specific types. Check [`InspectorPrimitive`] for an example. use crate::reflect_inspector::{errors::no_multiedit, InspectorUi, ProjectorReflect}; +use bevy_log::info; use bevy_reflect::{FromType, PartialReflect, Reflect, TypePath, TypeRegistry}; use bevy_utils::Instant; use std::{ @@ -225,6 +226,13 @@ fn add_of_with_many( type_registry: &mut TypeRegistry, fn_many: InspectorEguiImplFnMany, ) { + // Despite this running for f32 ; we then fail to retrieve it. + // TODO: check if their type id is similar, if not investigate why. + info!( + "registering InspectorEguiImpl for {} ({:?}", + std::any::type_name::(), + TypeId::of::() + ); type_registry .get_mut(TypeId::of::()) .unwrap_or_else(|| panic!("{} not registered", std::any::type_name::())) diff --git a/crates/bevy-inspector-egui/src/reflect_inspector/mod.rs b/crates/bevy-inspector-egui/src/reflect_inspector/mod.rs index f2da385f..29757b6f 100644 --- a/crates/bevy-inspector-egui/src/reflect_inspector/mod.rs +++ b/crates/bevy-inspector-egui/src/reflect_inspector/mod.rs @@ -226,19 +226,17 @@ impl InspectorUi<'_, '_> { } } - if let Some(s) = self - .type_registry - .get_type_data::(Any::type_id(value)) - { - if let Some(value) = value.try_as_reflect_mut() { - return s.execute(value.as_any_mut(), ui, options, id, self.reborrow()); + if let Some(reflected) = value.try_as_reflect_mut() { + if let Some(s) = self + .type_registry + .get_type_data::(reflected.reflect_type_info().type_id()) + { + if let Some(value) = value.try_as_reflect_mut() { + return s.execute(value.as_any_mut(), ui, options, id, self.reborrow()); + } } } - if let Some(changed) = (self.short_circuit)(self, value, ui, id, options) { - return changed; - } - match value.reflect_mut() { ReflectMut::Struct(value) => self.ui_for_struct(value, ui, id, options), ReflectMut::TupleStruct(value) => self.ui_for_tuple_struct(value, ui, id, options), @@ -273,21 +271,25 @@ impl InspectorUi<'_, '_> { ) { let mut options = options; if options.is::<()>() { - if let Some(data) = self - .type_registry - .get_type_data::(Any::type_id(value)) - { - options = &data.0; + if let Some(value_reflect) = value.try_as_reflect() { + if let Some(data) = self + .type_registry + .get_type_data::(value_reflect.type_id()) + { + options = &data.0; + } } } - if let Some(s) = self - .type_registry - .get_type_data::(Any::type_id(value)) - { - if let Some(value) = value.try_as_reflect() { - s.execute_readonly(value.as_any(), ui, options, id, self.reborrow()); - return; + if let Some(value_reflect) = value.try_as_reflect() { + if let Some(s) = self + .type_registry + .get_type_data::(value_reflect.type_id()) + { + if let Some(value) = value.try_as_reflect() { + s.execute_readonly(value.as_any(), ui, options, id, self.reborrow()); + return; + } } }