Skip to content

Commit ed159b5

Browse files
DOCS: Update InputSystemUIInputModule documentation (#2081)
1 parent f7d9f60 commit ed159b5

File tree

4 files changed

+264
-63
lines changed

4 files changed

+264
-63
lines changed

Packages/com.unity.inputsystem/DocCodeSamples.Tests/DocCodeSamples.asmdef

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"references": [
55
"GUID:75469ad4d38634e559750d17036d5f7c"
66
],
7-
"includePlatforms": [],
7+
"includePlatforms": [
8+
"Editor"
9+
],
810
"excludePlatforms": [],
911
"allowUnsafeCode": false,
1012
"overrideReferences": true,
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#if UNITY_INPUT_SYSTEM_ENABLE_UI
2+
3+
using UnityEngine;
4+
using UnityEngine.InputSystem.UI;
5+
6+
namespace DocCodeSamples.Tests
7+
{
8+
internal class InputSystemUIInputModuleAssignActionsExample : MonoBehaviour
9+
{
10+
// Reference to the InputSystemUIInputModule component, needs to be provided in the Inspector
11+
public InputSystemUIInputModule uiModule;
12+
13+
void Start()
14+
{
15+
// Assign default actions
16+
AssignActions();
17+
}
18+
19+
void AssignActions()
20+
{
21+
if (uiModule != null)
22+
uiModule.AssignDefaultActions();
23+
else
24+
Debug.LogError("InputSystemUIInputModule not found.");
25+
}
26+
27+
void UnassignActions()
28+
{
29+
if (uiModule != null)
30+
uiModule.UnassignActions();
31+
else
32+
Debug.LogError("InputSystemUIInputModule not found.");
33+
}
34+
35+
void OnDestroy()
36+
{
37+
// Unassign actions when the object is destroyed
38+
UnassignActions();
39+
}
40+
}
41+
}
42+
#endif

Packages/com.unity.inputsystem/DocCodeSamples.Tests/InputSystemUIInputModuleAssignActionsExample.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)