Plugin Example
Overview
This example is focused to produce this result:
Input Keys Data
-
At first creating a Input Keys Data. To create a Input Keys Data:
- Right Click on the Content Browser
- Search for Data Asset
- Select Data Asset and Select Input Keys Data
-
An empty Input Keys Data is created. And now populate those textures of the corresponding keys. For this example, I am using this Key's Texture
Input Action Keys Image - Plugin Settings
-
To setup some Plugin Default Values for the Project for this example;
Edit >> Project Settings >> Plugins >> Input Action Keys Image
Setting Value Description Supports Gamepad true Enables gamepad input for the project Change All Input keys Data to Default true A single Input Keys Data will be used Default Input Keys Data Created Instance Instance created in step 1
Input Action Key Image
-
After creating the Input Keys Data, Now we can create a
User WidgetBlueprint
. For example, here I will name itWBP_InputActionKeyImageExample
-
After opening the
WBP_InputActionKeyImageExample
blueprint window, First add theCanvas Panel
and then add the widget Input Action Key Image to the user widget.
-
For this example, Setting the following values:
Setting Value Description Anchors Middle of the screen with both alignment and position We want our image to be at the center Size to Content true For making the size of the widget according to the texture Input Action IA_Interact I want this image to be shown on the interactable objects Input Mapping Context IMC_Default Since, the IA_Interact is defined in the IMC_Default
Input Keys Data Set to Default Input Keys by default Input Keys Data are stored in the given Input Keys Data instance created recently Selected Input Key Texture Index 0 for both Keyboard Mouse
andGamepad
Select Input Device
toGamepad
to change the index forGamepad
. Here using 0 because we have only one key mapped for eachKeyboard Mouse
andGamepad
Is Selected Input Device Only false Since, this Input Action Key Image is gonna use both input devices i.e. Keyboard Mouse
andGamepad
Widget Switched On Input Device Changed
-
Now for showing the
Move
hint where theKeyboard Mouse
has 4 different keysWASD
andGamepad
has only one keyLeft Joystick
, we are gonna use Widget Switched on Input Device. So, to use the Widget Switched on Input Device, we will create a newUser Widget Blueprint
namedWBP_WidgetSwitchedOnInputDeviceChangedExample
.
-
After opening
WBP_WidgetSwitchedOnInputDeviceChangedExample
, Add the followings in the respective order:
-
Input Action Key Image Properties for
Keyboard Mouse
Input DeviceFor the
Selected Input Key Texture Index
of Input Action Key Image inside theHorizontal Box = Keyboard Mouse
, Use index in the order:0 for W 1 for A 2 for S 3 for D
-
Input Action Key Image Properties for
Gamepad
Input Device
-