Skip to content

Commit 3efea32

Browse files
committed
Improve UIInputModule documentation and examples
Only the examples that are reused across the class are in a "external" file so that they can be reference in multiple examples. I'd like to be consistent about this and have all examples in files. but this is a much bigger effort at the moment.
1 parent 6798213 commit 3efea32

File tree

3 files changed

+260
-62
lines changed

3 files changed

+260
-62
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using UnityEngine;
2+
using UnityEngine.InputSystem.UI;
3+
using UnityEngine.Serialization;
4+
5+
namespace DocCodeSamples.Tests
6+
{
7+
internal class InputSystemUIInputModuleAssignActionsExample : MonoBehaviour
8+
{
9+
// Reference to the InputSystemUIInputModule component, needs to be provided in the Inspector
10+
[FormerlySerializedAs("inputModule")]
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+
}

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)