Module bevy_inspector_egui::reflect_inspector
source · Expand description
General-purpose machinery for displaying Reflect
types using egui
Examples
Basic usage
use bevy_reflect::{Reflect, TypeRegistry};
use bevy_inspector_egui::reflect_inspector::{ui_for_value, InspectorUi, Context};
#[derive(Reflect)]
struct Data {
value: f32,
}
fn ui(data: &mut Data, ui: &mut egui::Ui, type_registry: &TypeRegistry) {
let mut cx = Context::default(); // empty context, with no access to the bevy world
let mut env = InspectorUi::new_no_short_circuit(type_registry, &mut cx); // no short circuiting, couldn't display `Handle<StandardMaterial>`
let _changed = env.ui_for_reflect(data, ui);
// alternatively, if you are using an empty `Context`:
let _changed = ui_for_value(data, ui, type_registry);
}
Bevy specific usage
use bevy_reflect::{Reflect, TypeRegistry};
use bevy_inspector_egui::reflect_inspector::{InspectorUi, Context};
use bevy_ecs::prelude::*;
use bevy_asset::Handle;
use bevy_pbr::StandardMaterial;
#[derive(Reflect)]
struct Data {
material: Handle<StandardMaterial>,
}
fn ui(mut data: Mut<Data>, ui: &mut egui::Ui, world: &mut World, type_registry: &TypeRegistry) {
let mut cx = Context {
world: Some(world.into()),
};
let mut env = InspectorUi::for_bevy(type_registry, &mut cx);
// alternatively
// use crate::bevy_inspector::short_circuit;
// let mut env = InspectorUi::new(type_registry, &mut cx, Some(short_circuit::short_circuit), Some(short_circuit::short_circuit_readonly));
let changed = env.ui_for_reflect(data.bypass_change_detection(), ui);
if changed {
data.set_changed();
}
}
Structs
Functions
Display the value without any
Context
or short circuiting behaviour.
This means that for example bevy’s Handle<StandardMaterial>
values cannot be displayed,
as they would need to have access to the World
.Display the readonly value without any
Context
or short circuiting behaviour.
This means that for example bevy’s Handle<StandardMaterial>
values cannot be displayed,
as they would need to have access to the World
.Type Definitions
Function which will be executed for every field recursively, which can be used to skip regular traversal.
Function which will be executed for every field recursively, which can be used to skip regular traversal,
_many
variantFunction which will be executed for every field recursively, which can be used to skip regular traversal,
_readonly
variant