Net-Game/Library/PackageCache/com.unity.inputsystem@e2c83221d2dc/DocCodeSamples.Tests/InputSystemUIInputModuleAssignActionsExample.cs
2025-03-28 08:33:16 -04:00

43 lines
1.0 KiB
C#

#if UNITY_INPUT_SYSTEM_ENABLE_UI
using UnityEngine;
using UnityEngine.InputSystem.UI;
namespace DocCodeSamples.Tests
{
internal class InputSystemUIInputModuleAssignActionsExample : MonoBehaviour
{
// Reference to the InputSystemUIInputModule component, needs to be provided in the Inspector
public InputSystemUIInputModule uiModule;
void Start()
{
// Assign default actions
AssignActions();
}
void AssignActions()
{
if (uiModule != null)
uiModule.AssignDefaultActions();
else
Debug.LogError("InputSystemUIInputModule not found.");
}
void UnassignActions()
{
if (uiModule != null)
uiModule.UnassignActions();
else
Debug.LogError("InputSystemUIInputModule not found.");
}
void OnDestroy()
{
// Unassign actions when the object is destroyed
UnassignActions();
}
}
}
#endif