HPbarzissou
This commit is contained in:
58
Assets/Test/InputManagerLR.cs
Normal file
58
Assets/Test/InputManagerLR.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class InputManagerLR : MonoBehaviour
|
||||
{
|
||||
private static InputManagerLR instance;
|
||||
|
||||
[SerializeField] private InputActionAsset actionAsset;
|
||||
|
||||
private InputActionMap actionMap;
|
||||
private InputAction primaryButtonR;
|
||||
private InputAction secondaryButtonR;
|
||||
private InputAction primaryButtonL;
|
||||
private InputAction secondaryButtonL;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (instance != null && instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
|
||||
if (actionAsset != null)
|
||||
{
|
||||
actionMap = actionAsset.FindActionMap("Test");
|
||||
if (actionMap != null)
|
||||
{
|
||||
primaryButtonR = actionMap.FindAction("XR_PrimaryButtonR", throwIfNotFound: false);
|
||||
primaryButtonL = actionMap.FindAction("XR_PrimaryButtonL", throwIfNotFound: false);
|
||||
secondaryButtonR = actionMap.FindAction("XR_SecondaryButtonR", throwIfNotFound: false);
|
||||
secondaryButtonL = actionMap.FindAction("XR_SecondaryButtonL", throwIfNotFound: false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable() => actionMap?.Enable();
|
||||
private void OnDisable() => actionMap?.Disable();
|
||||
|
||||
public static bool PrimaryButtonR() => instance?.primaryButtonR?.IsPressed() ?? false;
|
||||
public static bool PrimaryButtonR_OnPress() => instance?.primaryButtonR?.WasPressedThisFrame() ?? false;
|
||||
public static bool PrimaryButtonR_OnRelease() => instance?.primaryButtonR?.WasReleasedThisFrame() ?? false;
|
||||
|
||||
public static bool PrimaryButtonL() => instance?.primaryButtonL?.IsPressed() ?? false;
|
||||
public static bool PrimaryButtonL_OnPress() => instance?.primaryButtonL?.WasPressedThisFrame() ?? false;
|
||||
public static bool PrimaryButtonL_OnRelease() => instance?.primaryButtonL?.WasReleasedThisFrame() ?? false;
|
||||
|
||||
public static bool SecondaryButtonR() => instance?.secondaryButtonR?.IsPressed() ?? false;
|
||||
public static bool SecondaryButtonR_OnPress() => instance?.secondaryButtonR?.WasPressedThisFrame() ?? false;
|
||||
public static bool SecondaryButtonR_OnRelease() => instance?.secondaryButtonR?.WasReleasedThisFrame() ?? false;
|
||||
|
||||
public static bool SecondaryButtonL() => instance?.secondaryButtonL?.IsPressed() ?? false;
|
||||
public static bool SecondaryButtonL_OnPress() => instance?.secondaryButtonL?.WasPressedThisFrame() ?? false;
|
||||
public static bool SecondaryButtonL_OnRelease() => instance?.secondaryButtonL?.WasReleasedThisFrame() ?? false;
|
||||
}
|
||||
Reference in New Issue
Block a user