Inspect your game hierarchy and logs at runtime — just press F8

Posted on

Castle Game Engine Inspector - Mousey glTF animation
Castle Game Engine Inspector - Platformer
Castle Game Engine Inspector - Escape from the Universe

Initial version of this post said we use F12. We had to change this shortcut to F8 though, because when running the application in Delphi debugger on Windows — F12 breaks the process (this is a feature of Windows+Delphi…).

I’m happy to announce a feature that may forever change how you use Castle Game Engine! Simply recompile your game with the latest engine version, press F8 and behold… a powerful tool to see your log and hierarchy of objects in the game.

Watch a presentation:

Yes, this looks effectively like a (very minimalistic) editor-at-runtime. It is cross-platform and automatically available for all your games. Invoke it at any point, and inspect (soon: even edit) the visible CGE objects (UI, transformations, scenes…).

Features:

  • View the hierarchy of TCastleUserInterface and TCastleTransform at runtime (just like in CGE editor)

  • Select any component (by picking it from hierarchy, or hovering mouse over it with various “Auto-Select” options) to see its properties, updated in real-time

  • View logs (each time you press F8, we show 10 last logs, and we’ll collect any more logs that will be submitted while the inspector is open)

  • All panels (hierarchy, properties, profiler, log) can be hidden and shown independently

  • Inspector opacity can be controlled, to better see your game content underneath. The current opacity and panels are remembered when you toggle inspector by F8 repeatedly.

  • Powerful frame profiler shows where do you spend most of the time each frame: update, render, physics, swap. It also shows FPS history.

  • The key to invoke the inspector can be configured, you can also make it available in the release mode. By default, we assign {$ifdef DEBUG} keyF8 {$else} keyNone {$endif}.

Note: long time ago I had a plan for a different approach to “editor at runtime” : compile with CASTLE_WINDOW_LCL backend, and add LCL UI — reused between “editor at runtime” and actual CGE editor. Downside: it would work only on desktops. For Delphi devs, it would also mean that we need to compile the game with FPC too. Upside: It would be easier to support 100% of editor features. What is the ideal approach? We’ll see 🙂 For now we develop CGE editor using LCL, and in-game inspector using CGE UI, and we’ll see how these 2 approaches converge.

Start the discussion at Castle Game Engine Forum