Gamepad Left Stick XZ#
Input / Gamepad Left Stick XZ
Can Read
Cannot Write
Description#
Returns the value of the Left Stick on the X and Z axes
Code#
using System;
using UnityEngine;
using UnityEngine.InputSystem;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Title("Gamepad Left Stick XZ")]
[Category("Input/Gamepad Left Stick XZ")]
[Description("Returns the value of the Left Stick on the X and Z axes")]
[Image(typeof(IconJoystick), ColorTheme.Type.Blue, typeof(BadgeArrowLeft))]
[Keywords("Move", "Joystick", "Plane", "Ground")]
[Serializable]
public class TypeVector3InputGamepadLeftStick : TypeVector3
{
[NonSerialized] private UnityEngine.InputSystem.InputAction m_InputAction;
~TypeVector3InputGamepadLeftStick()
{
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 Vector3 Get(Args args)
{
Vector2 value = this.InputAction?.ReadValue<Vector2>() ?? default;
return new Vector3(value.x, 0f, value.y);
}
public override string ToString()
{
return "Gamepad Left Stick XZ";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}