Test追加パックVol.2
This commit is contained in:
57
Assets/Scripts/InputManagerLR.cs
Normal file
57
Assets/Scripts/InputManagerLR.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class InputManagerLR : MonoBehaviour
|
||||
{
|
||||
static InputManagerLR instance;
|
||||
|
||||
[SerializeField]
|
||||
InputActionAsset ActionAsset;
|
||||
|
||||
InputActionMap ActionMap;
|
||||
InputAction m_PrimaryButtonR;
|
||||
InputAction m_SecondaryButtonR;
|
||||
InputAction m_PrimaryButtonL;
|
||||
InputAction m_SecondaryButtonL;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
GameObject.DontDestroyOnLoad(gameObject);
|
||||
ActionMap = ActionAsset.FindActionMap("Test");
|
||||
m_PrimaryButtonR = ActionMap.FindAction("XR_PrimaryButtonR", throwIfNotFound: true);
|
||||
m_PrimaryButtonL = ActionMap.FindAction("XR_PrimaryButtonL", throwIfNotFound: true);
|
||||
m_SecondaryButtonR = ActionMap.FindAction("XR_SecondaryButtonR", throwIfNotFound: true);
|
||||
m_SecondaryButtonL = ActionMap.FindAction("XR_SecondaryButtonL", throwIfNotFound: true);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
ActionMap?.Enable();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
ActionMap?.Disable();
|
||||
}
|
||||
|
||||
// Aボタン
|
||||
public static bool PrimaryButtonR() => instance.m_PrimaryButtonR.IsPressed();
|
||||
public static bool PrimaryButtonR_OnPress() => instance.m_PrimaryButtonR.WasPressedThisFrame();
|
||||
public static bool PrimaryButtonR_OnRelease() => instance.m_PrimaryButtonR.WasReleasedThisFrame();
|
||||
|
||||
// Xボタン
|
||||
public static bool PrimaryButtonL() => instance.m_PrimaryButtonL.IsPressed();
|
||||
public static bool PrimaryButtonL_OnPress() => instance.m_PrimaryButtonL.WasPressedThisFrame();
|
||||
public static bool PrimaryButtonL_OnRelease() => instance.m_PrimaryButtonL.WasReleasedThisFrame();
|
||||
|
||||
// Bボタン
|
||||
public static bool SecondaryButtonR() => instance.m_SecondaryButtonR.IsPressed();
|
||||
public static bool SecondaryButtonR_OnPress() => instance.m_SecondaryButtonR.WasPressedThisFrame();
|
||||
public static bool SecondaryButtonR_OnRelease() => instance.m_SecondaryButtonR.WasReleasedThisFrame();
|
||||
|
||||
// Yボタン
|
||||
public static bool SecondaryButtonL() => instance.m_SecondaryButtonL.IsPressed();
|
||||
public static bool SecondaryButtonL_OnPress() => instance.m_SecondaryButtonL.WasPressedThisFrame();
|
||||
public static bool SecondaryButtonL_OnRelease() => instance.m_SecondaryButtonL.WasReleasedThisFrame();
|
||||
}
|
||||
Reference in New Issue
Block a user