ImGui UI
This example demonstrates how to integrate ImGui with the Stride game engine to render an immediate‑mode UI overlay for in‑game tools, debugging, and live controls.
This project will show how to:
- Initialize and configure the ImGui integration
- Draw ImGui windows, menus, and controls every frame
- Handle input events and toggle UI visibility
- Display real‑time stats or debug panels
Note
This example requires the additional NuGet packages Stride.CommunityToolkit.Bepu
, Stride.CommunityToolkit.Skyboxes
and Stride.CommunityToolkit.Windows
. Make sure to install all before running the code.
View on GitHub.
using Stride.CommunityToolkit.Bepu;
using Stride.CommunityToolkit.Engine;
using Stride.CommunityToolkit.Games;
using Stride.CommunityToolkit.ImGui;
using Stride.CommunityToolkit.Renderers;
using Stride.CommunityToolkit.Skyboxes;
using Stride.Engine;
using var game = new Game();
game.Run(start: Start);
void Start(Scene scene)
{
// Setup the base 3D scene with default lighting, camera, etc.
game.SetupBase3DScene();
// Add debugging aids: entity names, positions
game.AddEntityDebugSceneRenderer(new()
{
EnableBackground = true
});
game.AddSkybox();
game.AddProfiler();
new ImGuiSystem(game.Services, game.GraphicsDeviceManager);
new HierarchyView(game.Services);
new PerfMonitor(game.Services);
Inspector.FindFreeInspector(game.Services).Target = game.SceneSystem.SceneInstance;
// makes the profiling much easier to read.
game.SetMaxFPS(60);
}