### Setup with WorldInspectorPlugin Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/README.md Demonstrates the basic setup for using bevy-inspector-egui with the `WorldInspectorPlugin` for automatic world inspection. Requires registering types with `InspectorOptions`. ```rust use bevy::prelude::*; use bevy_inspector_egui::prelude::*; use bevy_inspector_egui::quick::WorldInspectorPlugin; #[derive(Reflect, Resource, Default, InspectorOptions)] #[reflect(Resource, InspectorOptions)] struct GameConfig { #[inspector(min = 0.0, max = 1.0)] volume: f32, } fn main() { App::new() .add_plugins(DefaultPlugins) .add_plugins(EguiPlugin::default()) // Register type with options .init_resource::() .register_type::() // Add quick plugin (auto-adds DefaultInspectorConfigPlugin) .add_plugins(WorldInspectorPlugin::new()) .run(); } ``` -------------------------------- ### Minimal Configuration Setup Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/configuration.md Set up bevy-inspector-egui with minimal configuration, including only the 'documentation' feature and disabling default features. ```toml [dependencies.bevy-inspector-egui] default-features = false features = ["documentation"] ``` -------------------------------- ### Full Bevy Inspector Egui Initialization Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/api-reference/core-plugin.md This snippet shows the complete setup for Bevy Inspector Egui, including core Bevy plugins, Egui integration, inspector setup, type registration, and basic game systems. Ensure all necessary plugins and types are registered for a functional inspector. ```rust use bevy::prelude::*; use bevy_egui::EguiPlugin; use bevy_inspector_egui::quick::WorldInspectorPlugin; use bevy_inspector_egui::prelude::*; #[derive(Reflect, Resource, Default, InspectorOptions)] #[reflect(Resource, InspectorOptions)] struct GameSettings { #[inspector(min = 0.0, max = 1.0)] volume: f32, } fn main() { App::new() // Step 1: Core Bevy .add_plugins(DefaultPlugins) // Step 2: Egui integration .add_plugins(EguiPlugin::default()) // Step 3: Inspector setup .add_plugins(WorldInspectorPlugin::new()) // ^ This adds DefaultInspectorConfigPlugin automatically // Step 4: Type registration .init_resource::() .register_type::() // Step 5: Game systems .add_systems(Startup, setup) .add_systems(Update, game_logic) .run(); } fn setup(mut commands: Commands) { commands.spawn(Camera2d::default()); } fn game_logic(settings: Res) { println!("Volume: {}", settings.volume); } ``` -------------------------------- ### Minimal Bevy Inspector Egui Setup Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/api-reference/core-plugin.md Use this minimal setup to quickly add the inspector to your Bevy application. It includes the essential plugins for Bevy, Egui, and the World Inspector. ```rust App::new() .add_plugins(DefaultPlugins) .add_plugins(EguiPlugin::default()) .add_plugins(WorldInspectorPlugin::new()) .run(); ``` -------------------------------- ### 2D-Only Setup with Documentation Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/configuration.md Configure bevy-inspector-egui for 2D-only inspection, including the 'documentation' feature and disabling default features. ```toml [dependencies.bevy-inspector-egui] default-features = false features = ["2d", "documentation"] ``` -------------------------------- ### NumberOptions::with_speed() Example Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/api-reference/inspector-options.md Demonstrates how to customize the drag sensitivity of a numeric input using the `with_speed` method, applied to a slider in this example. ```rust let opts = NumberOptions::between(0.0, 100.0) .with_speed(0.5); // Slider with custom drag speed ``` -------------------------------- ### Filter Usage Example Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/types.md Shows how to create and use a Filter to display entities in the inspector, with an example of filtering by name using fuzzy matching. ```rust use bevy_inspector_egui::bevy_inspector::Filter; let filter = Filter::from_ui_fuzzy(ui, egui::Id::new("filter")); // Filter by name: entities match if name contains "Player" (fuzzy) bevy_inspector::ui_for_entities_filtered(world, ui, true, &filter); ``` -------------------------------- ### 3D and Gizmos Setup with Documentation Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/configuration.md Configure bevy-inspector-egui for 3D inspection with gizmos enabled, including the 'documentation' feature and disabling default features. ```toml [dependencies.bevy-inspector-egui] default-features = false features = ["3d", "bevy_gizmos", "documentation"] ``` -------------------------------- ### NumberOptions::between() Example Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/api-reference/inspector-options.md Demonstrates how to use the `between` method to create NumberOptions that render as a slider within a specified range. ```rust use bevy_inspector_egui::inspector_options::std_options::NumberOptions; let opts = NumberOptions::between(0.0, 1.0); // Renders as a slider from 0 to 1 ``` -------------------------------- ### Example: Inspecting a Custom Resource Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/api-reference/quick-plugins.md Demonstrates how to use ResourceInspectorPlugin to display a custom resource 'MyConfig' in an egui window. It includes setting up the Bevy app, initializing the resource, registering its type, and adding the plugin. ```rust use bevy::prelude::*; use bevy_inspector_egui::prelude::*; use bevy_inspector_egui::quick::ResourceInspectorPlugin; #[derive(Reflect, Resource, Default, InspectorOptions)] #[reflect(Resource, InspectorOptions)] struct MyConfig { name: String, #[inspector(min = 0.0, max = 1.0)] volume: f32, } fn main() { App::new() .add_plugins(DefaultPlugins) .init_resource::() .register_type::() .add_plugins(ResourceInspectorPlugin::::default()) .run(); } ``` -------------------------------- ### Manual UI Setup with Bevy Inspector Egui Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/README.md This snippet shows how to set up a Bevy application to use bevy-inspector-egui for manual UI creation. It includes adding necessary plugins and defining a system to render the inspector UI. ```rust use bevy::prelude::*; use bevy_egui::EguiPlugin; use bevy_inspector_egui::prelude::*; use std::any::TypeId; fn main() { App::new() .add_plugins(DefaultPlugins) .add_plugins(EguiPlugin::default()) .add_plugins(bevy_inspector_egui::DefaultInspectorConfigPlugin) // adds default options and `InspectorEguiImpl`s .add_systems(EguiPrimaryContextPass, inspector_ui) .run(); } fn inspector_ui(world: &mut World) { let Ok(egui_context) = world .query_filtered::<&mut EguiContext, With>() .get_single(world) else { return; }; let mut egui_context = egui_context.clone(); egui::Window::new("UI").show(egui_context.get_mut(), |ui| { egui::ScrollArea::vertical().show(ui, |ui| { // equivalent to `WorldInspectorPlugin` bevy_inspector_egui::bevy_inspector::ui_for_world(world, ui); egui::CollapsingHeader::new("Materials").show(ui, |ui| { bevy_inspector_egui::bevy_inspector::ui_for_assets::(world, ui); }); ui.heading("Entities"); bevy_inspector_egui::bevy_inspector::ui_for_world_entities(world, ui); }); }); } ``` -------------------------------- ### RangeOptions Usage Example Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/types.md Demonstrates applying RangeOptions to a Range field to set custom minimum and maximum bounds for the slider. ```rust use bevy_inspector_egui::prelude::*; #[derive(Reflect, InspectorOptions)] struct Spawner { #[inspector(start(min = 1.0), end(max = 10.0))] spawn_delay: std::ops::Range, } ``` -------------------------------- ### Minimal Plugin Setup Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/INDEX.md Use this snippet for the simplest integration of the inspector plugin into your Bevy application. It requires adding `WorldInspectorPlugin::new()` to your app's plugins. ```rust App::new() .add_plugins(DefaultPlugins) .add_plugins(WorldInspectorPlugin::new()) .run(); ``` -------------------------------- ### Complex InspectorOptions Example Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/configuration.md Demonstrates various inspector attributes for numeric fields like min, max, speed, prefix, and suffix. ```rust use bevy::prelude::* use bevy_inspector_egui::prelude::* #[derive(Reflect, InspectorOptions)] struct GameConfig { #[inspector(min = 0.0, max = 1.0)] volume: f32, #[inspector(min = 10, max = 1000, suffix = "ms")] frame_time_limit: u32, #[inspector(min = 0.1, speed = 0.1)] physics_timestep: f64, #[inspector(prefix = "$", min = 0, max = 10000)] player_health: i32, } ``` -------------------------------- ### Inspecting Bevy Values with Options Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/docs/MIGRATION_GUIDE_0.15_0.16.md This example demonstrates how to use `InspectorUi::for_bevy` to create an inspection environment with custom context and options, suitable for Bevy applications. It shows how to pass specific options like `NumberOptions::positive()` and handle potential stateful types. ```rust let world: &mut World; let context = Context { // can also be None or Context::default() world: Some(world.into()), }; // InspectorUi::new_no_short_circuit can be used if you don't need to be able to resolve bevy_asset handles. let env = InspectorUi::for_bevy(type_registry, context); let changed = env.ui_for_reflect_with_options( &mut value, ui, // some types like `Quat`s may store state. If you have display multiple values next to each other, make sure to pass different IDs. Otherwise you can use `egui::Id::null()`. egui::Id::new("ui"), // whatever options you want to pass. Look at the `inspector_options` docs for more info. &NumberOptions::positive(), ); ``` -------------------------------- ### Configure ResourceInspectorPlugin Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/configuration.md Use ResourceInspectorPlugin to inspect a specific Bevy resource. This example shows how to inspect a custom GameSettings resource and toggle its visibility with a key press. ```rust use bevy::prelude::* use bevy_inspector_egui::quick::ResourceInspectorPlugin; #[derive(Reflect, Resource, Default)] struct GameSettings { volume: f32, difficulty: u32, } App::new() .init_resource::() .register_type::() .add_plugins(ResourceInspectorPlugin::::new() .run_if(input_toggle_active(KeyCode::Escape))) ``` -------------------------------- ### NumberOptions::normalized() Example Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/api-reference/inspector-options.md Illustrates the use of the `normalized` method to create options for values between 0.0 and 1.0, suitable for properties like opacity or intensity, with a default step speed. ```rust let opts = NumberOptions::normalized(); // 0.0 to 1.0 with 0.01 step speed (good for opacity/intensity) ``` -------------------------------- ### Configure AssetInspectorPlugin for StandardMaterial Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/configuration.md Use AssetInspectorPlugin to inspect specific asset types. This example shows how to add the plugin for StandardMaterial assets. ```rust use bevy::prelude::* use bevy_inspector_egui::quick::AssetInspectorPlugin; App::new() .add_plugins(AssetInspectorPlugin::::new()) ``` -------------------------------- ### NumberOptions::positive() Example Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/api-reference/inspector-options.md Shows how to use the `positive` method to ensure that a numeric field's value is always non-negative. ```rust let opts = NumberOptions::positive(); // f32::from_f64(0.0) minimum // Prevents negative values ``` -------------------------------- ### Example Error Message Display Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/errors.md Illustrates the visual representation of an error message in the UI, featuring an icon and colored text. ```text ⚠️ Resource `MyConfig` not found in the world ``` -------------------------------- ### Configure AssetInspectorPlugin for Image Assets Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/configuration.md Use AssetInspectorPlugin to inspect specific asset types. This example shows how to add the plugin for Image assets. ```rust use bevy::prelude::* use bevy_inspector_egui::quick::AssetInspectorPlugin; App::new() .add_plugins(AssetInspectorPlugin::::new()) ``` -------------------------------- ### Deriving Reflect and InspectorOptions with Attributes Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/docs/MIGRATION_GUIDE_0.15_0.16.md This example shows the updated way to define struct fields with inspection options like min, max, and step. You must derive `Reflect` and `InspectorOptions`, and register the type with `app.register_type::()`. ```rust #[derive(Reflect, InspectorOptions)] #[reflect(InspectorOptions)] struct MyStruct { #[inspector(min = 0.0, max = 10.0, step = 0.01)] value: f32, } app.register_type::(); ``` -------------------------------- ### Insert Target Field Example Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/types.md Demonstrates how to use the Target enum with InspectorOptions to apply specific display settings, such as number ranges, to struct fields. ```rust use bevy_inspector_egui::inspector_options::{InspectorOptions, Target, std_options::NumberOptions}; let mut options = InspectorOptions::new(); let number_opts = NumberOptions::between(0.0, 1.0); options.insert(Target::Field(0), number_opts); // apply to first field ``` -------------------------------- ### Numeric Field Options Registration Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/api-reference/inspector-options.md Demonstrates how to register default options for numeric types using Bevy Inspector Egui. Includes examples for creating sliders, setting minimum bounds, enabling positive values, normalizing ranges, and customizing drag sensitivity. ```rust use bevy_inspector_egui::inspector_options::std_options::* // Numeric types support: // - between(min, max) — creates slider options // - at_least(min) — minimum bound only // - positive() — 0.0 minimum // - normalized() — 0.0 to 1.0 with 0.01 speed // - with_speed(speed) — customize drag sensitivity let slider = NumberOptions::between(0.0, 100.0); let positive = NumberOptions::positive(); let normalized = NumberOptions::normalized().with_speed(0.01); ``` -------------------------------- ### Add ResourceInspectorPlugin for Custom Resource Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/README.md Use ResourceInspectorPlugin to display a specific Bevy resource in a window. Ensure the resource is initialized and registered with Bevy's type system. This example shows inspection of a custom `Configuration` resource. ```rust use bevy::prelude::*; use bevy_inspector_egui::prelude::*; use bevy_inspector_egui::quick::ResourceInspectorPlugin; // `InspectorOptions` are completely optional #[derive(Reflect, Resource, Default, InspectorOptions)] #[reflect(Resource, InspectorOptions)] struct Configuration { name: String, #[inspector(min = 0.0, max = 1.0)] option: f32, } fn main() { App::new() .add_plugins(DefaultPlugins) .init_resource::() // `ResourceInspectorPlugin` won't initialize the resource .register_type::() // you need to register your type to display it .add_plugins(EguiPlugin::default()) .add_plugins(ResourceInspectorPlugin::::default()) // also works with built-in resources, as long as they are `Reflect` .add_plugins(ResourceInspectorPlugin::`: Facilitates the inspection of assets of type `A`. ### Methods - `.new()`: Creates a new instance of the plugin. - `.run_if(condition)`: Specifies a condition for when the plugin should run. ### Constants - `DEFAULT_SIZE`: The default size for the world inspector window. ``` -------------------------------- ### ui_for_resource() Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/api-reference/bevy-inspector.md Displays a single resource of a specified type `R` within the egui UI. This is useful for inspecting and potentially modifying a specific resource. ```APIDOC ## ui_for_resource() ### Description Display a single resource of type `R`. ### Signature ```rust pub fn ui_for_resource + Reflect>( world: &mut World, ui: &mut egui::Ui ) ``` ### Parameters #### Path Parameters - **world** (`&mut World`) - Required - The Bevy world - **ui** (`&mut egui::Ui`) - Required - The egui UI context ### Type Parameters - `R: Resource + Reflect` — The resource type to display ### Returns `()` — marks resource as changed if modified ### Example ```rust use bevy::prelude::*; use bevy_inspector_egui::bevy_inspector; fn inspect_time(world: &mut World, ui: &mut egui::Ui) { bevy_inspector::ui_for_resource::() Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/api-reference/bevy-inspector.md Displays all assets of a specific type `A`. This function is generic and allows specifying the exact asset type to be inspected, providing a focused view. ```APIDOC ## ui_for_assets() ### Description Display all assets of a specific type `A`. ### Function Signature `pub fn ui_for_assets(world: &mut World, ui: &mut egui::Ui)` ### Type Parameters - `A: Asset + Reflect` — The asset type to display ### Parameters #### Path Parameters - **world** (`&mut World`) - Required - The Bevy world - **ui** (`&mut egui::Ui`) - Required - The egui UI context ### Returns `()` — modifies assets in-place when edited ### Example ```rust use bevy::prelude::*; use bevy_pbr::StandardMaterial; use bevy_inspector_egui::bevy_inspector; fn inspect_materials(world: &mut World, ui: &mut egui::Ui) { egui::CollapsingHeader::new("Materials").show(ui, |ui| { bevy_inspector::ui_for_assets::(world, ui); }); } ``` ``` -------------------------------- ### ui_for_all_assets Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/api-reference/bevy-inspector.md Displays all asset types in a grouped view within the egui UI. This function iterates through all registered asset types in the Bevy world and presents them for inspection. ```APIDOC ## ui_for_all_assets() ### Description Display all asset types in a grouped view. ### Function Signature `pub fn ui_for_all_assets(world: &mut World, ui: &mut egui::Ui)` ### Parameters #### Path Parameters - **world** (`&mut World`) - Required - The Bevy world - **ui** (`&mut egui::Ui`) - Required - The egui UI context ### Returns `()` — modifies assets in-place when edited ### Example ```rust egui::CollapsingHeader::new("Assets").show(ui, |ui| { bevy_inspector::ui_for_all_assets(world, ui); }); ``` ``` -------------------------------- ### Configure WorldInspectorPlugin to Show on Key Press Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/configuration.md Configure WorldInspectorPlugin to be toggled by a specific key press. The inspector will only appear when the specified key (e.g., F12) is active. ```rust use bevy::prelude::* use bevy_inspector_egui::quick::WorldInspectorPlugin; // Show when F12 pressed App::new() .add_plugins(WorldInspectorPlugin::new() .run_if(input_toggle_active(KeyCode::F12))) ``` -------------------------------- ### Integration Points Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/api-reference/bevy-inspector.md Key integration points for using Bevy Inspector Egui, detailing how UI functions interact with the Bevy world and its components. ```APIDOC ## Integration Points - All UI functions take `&mut World`, allowing full access to world state. - Call `guess_entity_name()` to get human-readable entity names (includes `Name` component if present). - Functions create temporary `CommandQueue` instances to safely apply mutations. - All functions use the world's `AppTypeRegistry` for type information. - Asset name resolution uses `AssetServer::get_path()` when available. ``` -------------------------------- ### Create Filter with Exact Matching UI Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/api-reference/bevy-inspector.md Creates a filter instance using a UI for exact matching, including toggles for fuzzy matching and observers. ```rust pub fn from_ui(ui: &mut egui::Ui, id: egui::Id) -> Self ``` -------------------------------- ### Custom Option Type Definition Source: https://github.com/jakobhellermann/bevy-inspector-egui/blob/main/_autodocs/api-reference/inspector-options.md Illustrates the creation of a custom option type `MyCustomOptions` for specialized UI rendering within the inspector. ```rust use bevy_reflect::TypeData; #[derive(Clone)] pub struct MyCustomOptions { pub enabled: bool, pub precision: u32, } impl TypeData for MyCustomOptions {} ```