Download

Slate Debugging Tips

Sep 17, 2020.Knowledge
When developing user interfaces for your project, it can be beneficial to take a look under the hood to see how input events are being processed, or inspect the state of different users and widgets and see their properties at a given moment. There are a variety of tools available in the engine to help with this, providing a good place to start debugging potential issues and visualize how your interface is being laid out.

Slate Debugger
When diagnosing issues with widgets not working as expected when clicked, it can be helpful to see which widget the event is being routed towards. To help with this, you can enable the Slate Debugger by typing “SlateDebugger.Start” in the console. After doing so, you’ll see log messages describing all input events, including mouse clicks, key presses, navigation events, and focus changes. With this information, you can see if some other widget is consuming the event, or track down if a function responsible for processing an event is making a change to the currently focused widget.

Focus Target Visuals
Most widgets don’t have any sort of visual indication that they are the focus target, which can be a challenge when setting up keyboard or gamepad navigation. To assist with this, you can set the Render Focus Rule to Always in your project settings. After doing so, you’ll see a dashed line around the currently focused widget at all times, and can visualize which widget focus moves to when different navigation events occur.

Widget Reflector
Since the editor itself is built with Slate, it can be helpful to find an existing widget in the editor that is similar to your goal and inspect the code to see how it was built. To aid with this, you can summon the Widget Reflector in Window->Developer Tools. With this tool, you can click “Pick Painted Widget” and mouse over a widget anywhere in your game or the editor to see the entire widget hierarchy for that widget. You’ll also be able to see the source file where the widget is created, and in the case of UMG widgets, you can inspect their properties. When working in standalone games, the Widget Reflector can capture snapshots for offline inspection.