I want a composite with vector2 and button inputs to produce a vector 2.
The button is a modifier, where it will only return the input vector 2 with pressed, otherwise zero.
Trouble I have is with context.ReadValue(int partNum) doesn’t take a vector2:
public override Vector2 ReadValue(ref InputBindingCompositeContext context)
{
Vector2 moveValue = context.ReadValue<Vector2>(Move);
float buttonValue = context.ReadValue<float>(Button);
Line 3 - Compile error:
Anyone know how to read in the Vector2?
full file
#if UNITY_EDITOR
[InitializeOnLoad] // Automatically register in editor.
#endif
public class ClickNMoveBinding : InputBindingComposite<Vector2>
{
[InputControl(layout = "Value")]
public int Move;
[InputControl(layout = "Button")]
public int Button;
public override Vector2 ReadValue(ref InputBindingCompositeContext context)
{
Vector2 moveValue = context.ReadValue<Vector2>(Move);
float buttonValue = context.ReadValue<float>(Button);
if (buttonValue>0)
{
return moveValue;
}
return Vector2.zero;
}
static ClickNMoveBinding()
{
InputSystem.RegisterBindingComposite<ClickNMoveBinding>();
}
[RuntimeInitializeOnLoadMethod]
static void Init() { } // Trigger static constructor.
}