What’s this? #
The Layout Subsystem is a Local Player Subsystem which is automatically created and associated to each player (ULocalPlayer). This subsystem will allow you to add the touch interface with desired layout for each player. Therefore, touch interface designer is ready for multiplayer!
It contains a number of useful functions, such as displaying or hiding the touch interface, getting the layout instance or transforming an absolute position into a local position.
How to use Layout Subsystem? #
In Blueprint

Right click to bring up the context menu and type Layout. You should see two entries.
In some cases, the context can be resolved automatically, for example if you’re in the player controller class (APlayerController).

If you’re in a pawn class (APawn) or one derived from it (ACharacter, for example), you’ll need to retrieve the controller instance and cast it to the PlayerController class. This will enable you to retrieve the subsystem associated with the player in the case of a multiplayer game (local or online).

If you’re in a class other than a pawn, or if your game/application contains no multiplayer elements, you may need to retrieve the player controller instance directly by specifying the player index. Work in local multiplayer.

In C++
Inside Pawn or derived class (work in online multiplayer)

Inside Player Controller class

Inside other class. Be careful with player index.

FUNCTIONS #
TOUCH INTERFACE

Add Touch Interface
Adds the touch interface widget with desired layout to the player screen.
- Layout : Layout you want to use
- Return : Layout instance
Load Touch Interface
Load touch interface with configuration saved in disk. Modify existing touch interface or create new one.
- User Index : Index of user (usually player index)
- Config Index : Index of saved configuration
- Return : Layout instance
Remove from Player Screen
Remove the touch interface currently added to the player screen.
Layout instance is nulled.
Reset to Default
Remove all touch interface modifications.
Uses the default parameters of the layout used to create the touch interface.
Get Touch Interface Geometry
Get geometry of slate widget
- Return : FGeometry. Can be null if there is no widget added to the screen.
Get Layout Instance
Get instance of layout
When a new touch interface is created, the layout you’ve chosen is duplicated to avoid modifying the asset and make the function compatible with multiplayer.
- Return : the layout instance (duplicated asset). Can be null if there is no widget added to the screen
Register Touch Listener Component
Register component (Gesture Recognizer, Shape Recognizer, etc) to receive input.
- Listener : Component that you want to receive input from touch interface. Should be a class that inherit from Touch Interface Listener (UTouchInterfaceListener).
- Return : True if component is successfully registered.
Unregister Touch Listener Component
Unregister component. The unregistered component will no longer receive input.
- Listener : Component that you want to unregister.
- Return : True if component is successfully unregistered
INPUT

Enable Input
Enable interaction with the touch interface.
Disable Input
Disable interaction with the touch interface.
Try Recognize Shape
Launch Shape Recognition on all Shape Recognizer.
This is a global call, you can call Try Recognize Shape on each Shape Recognizer component. For now, DO NOT CALL this function until the user has finished drawing.
VISIBILITY

Hide Touch Interface
Hide touch interface widget. Disable all interactions including recognizer.
Show Touch Interface
Display touch interface widget. All interactions including recognizer is enabled.
DRAWER

Add Drawer
Add drawer for virtual shape representation to player screen.
- Drawer Class : Class you want to use.
- ZOrder : Specify the zorder for this widget.
- Return : Virtual Shape Drawer instance (UUserWidget)
Remove Drawer
Remove drawer from player screen.
Show Drawer
Display drawer widget
Shape Recognizer is independant.
Hide Drawer
Hide drawer widget
Shape Recognizer is independant and receive input even if drawer is hidden.
UTILITY

Is Interface Active
Return true if the touch interface is currently active (interaction with user)
Touch Interface Layout Exist
Return true if the touch interface exist and was added to player screen.
Is Visible
Return true if the touch interface is currently visible
Absolute to Local
Transform absolute position (desktop, window or screen position) to local position (touch interface geometry)
- Input : Absolute Position
- Return : Local Position
Local to Absolute
Transform local position from touch interface geometry to absolute position
- Input : Local Position
- Return : Absolute Position
Normalized to Local
Transform normalized (0 to 1) to local position (touch interface geometry)
- Input : Normalized position (0 to 1)
- Return : Local Position
Local to Normalized
Transform local position to normalized position (0 to 1)
- Input : Local Position
- Return : Normalized Position (0 to 1)
SAVE & LOAD

Save Layout
Save the layout parameters in disk.
- User Index : Index used with configuration (usually player index).
- Config Index : Index used to identify configuration.
- Layout : Layout parameters saved in configuration. If null, the layout instance is saved.
- Return : True if configuration is successfully saved in disk.
Currently saved settings
- Active Opacity
- Inactive Opacity
- Inactive Lerp Rate
- Time Until Deactivated
- Time Until Reset
- Component position
- Component size
Layout Save File Exist
Check if the save game slot dedicated to built-in save system exist in disk.
- User Index : Index used to create save game slot. Ignored on some platform.
- Return : True if a file was found.
Layout Configuration Exist
Check if a configuration with specified config index exist in disk.
- User Index : Index used with configuration.
- Config Index : Index used to identify configuration in save game slot.
- Return : True if specified configuration exist.
Delete Configuration
Delete configuration saved in save game object.
- User Index : Index used with configuration.
- Config Index : Index used to identify configuration.
- Return : True is configuration is successfully deleted.
Delete Layout Save File
Delete save game object used for built-in save system.
- User Index : Index used with configuration.
- Return : True if save game object is successfully deleted from disk.
EVENTS #

On Active State Changed
Called when interface active state was changed
- Return : True if interface is active (a touch input is currently pressed)
On Touch Interface Created
Called when subsystem create new layout and add to player screen
On Touch Interface Removed
Called when subsystem remove layout from player screen
On Visibility State Changed
Called when visibility state of interface was changed
- Return : true if currently visible
