"UI Mode"
Last updated
Was this helpful?
Last updated
Was this helpful?
We commonly use the concept of "UI Mode", as an equivalent for Unreal's Input Mode
s. We switch between a "game mode" (where the mouse is captured and used as camera rotation), and a "UI mode", where the mouse is released, and users are allowed to click on things.
We have introduced an example helper library: BPFL_UIModeHelpers
, which provides a unified way of making external systems request UI mode, and make it handle them in a single place.
In various UI elements, we call RequestUIMode
, and provide the widget as the context. When done, we call ReleaseUIModeRequest
Each request made is passed in to the BP_UIModeService
, which tracks how many different context objects are requiring UI mode. If there are any objects that do, we want to be in UI mode. If all the objects needing UI mode have released their requests, we no longer need to be in UI mode.
The example player controller listens to these UI mode requests using BindToUIModeChangeRequests
, setting the input mode accordingly.
The "input mode: Game vs UI vs Game & UI" doesn't really hold when using mobile controls, since all input goes through the touch screen. In our example content we therefore ignore this UI mode system on mobile, setting ourselves to always be in "UI mode".
SetInputModeGameAndUI
, and show the mouse cursor, and use SetInputModeGameOnly
when we want to capture the cursor.