Keyboard Arrows XZ#
Input / Keyboard Arrows XZ
Can Read
Cannot Write
Description#
Returns the value of the Arrow keys on the X and Z axes
Code#
using System;
using UnityEngine;
using UnityEngine.InputSystem;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Title("Keyboard Arrows XZ")]
[Category("Input/Keyboard Arrows XZ")]
[Description("Returns the value of the Arrow keys on the X and Z axes")]
[Image(typeof(IconWASD), ColorTheme.Type.Blue)]
[Keywords("Move", "Keys", "Plane", "Ground")]
[Serializable]
public class TypeVector3InputKeyboardArrows : TypeVector3
{
[NonSerialized] private UnityEngine.InputSystem.InputAction m_InputAction;
~TypeVector3InputKeyboardArrows()
{
this.m_InputAction?.Disable();
this.m_InputAction?.Dispose();
}
public UnityEngine.InputSystem.InputAction InputAction
{
get
{
if (this.m_InputAction == null)
{
this.m_InputAction = new UnityEngine.InputSystem.InputAction(
"Arrows",
InputActionType.Value
);
this.m_InputAction.AddCompositeBinding("2DVector")
.With("Up", "<Keyboard>/upArrow")
.With("Down", "<Keyboard>/downArrow")
.With("Left", "<Keyboard>/leftArrow")
.With("Right", "<Keyboard>/rightArrow");
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 "Keyboard Arrows XZ";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}