Gamepad Left Stick#
Input / Gamepad Left Stick
Can Read
Cannot Write
Description#
Returns the value of the Left Stick of the current Gamepad
Code#
using System;
using UnityEngine;
using UnityEngine.InputSystem;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Title("Gamepad Left Stick")]
[Category("Input/Gamepad Left Stick")]
[Description("Returns the value of the Left Stick of the current Gamepad")]
[Image(typeof(IconJoystick), ColorTheme.Type.Blue, typeof(BadgeArrowLeft))]
[Keywords("Move", "Joystick")]
[Serializable]
public class TypeVector2InputGamepadLeftStick : TypeVector2
{
[NonSerialized] private UnityEngine.InputSystem.InputAction m_InputAction;
~TypeVector2InputGamepadLeftStick()
{
this.m_InputAction?.Disable();
this.m_InputAction?.Dispose();
}
private UnityEngine.InputSystem.InputAction InputAction
{
get
{
if (this.m_InputAction == null)
{
this.m_InputAction = new UnityEngine.InputSystem.InputAction(
name: "Left Stick",
type: InputActionType.Value,
binding: "<Gamepad>/leftStick"
);
this.m_InputAction.Enable();
}
return this.m_InputAction;
}
}
public override Vector2 Get(Args args)
{
return this.InputAction?.ReadValue<Vector2>() ?? default;
}
public override string ToString()
{
return "Gamepad Left Stick";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}