Created
September 23, 2019 02:40
-
-
Save inertiave/1082b5878d4f1766ba8c605a8b375174 to your computer and use it in GitHub Desktop.
New Input System
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.InputSystem; | |
namespace MyNamespace { | |
public class PlayerMovement : MonoBehaviour, MyControl.IMovementActions { | |
public MyControl control; | |
void Awake() | |
{ | |
control = new MyControl(); | |
control.Movement.SetCallbacks(this); | |
} | |
void OnEnable() | |
{ | |
control.Movement.Enable(); | |
} | |
void OnDisable() | |
{ | |
control.Movement.Disable(); | |
} | |
void Update() { } | |
public void OnJump(InputAction.CallbackContext ctx) | |
{ | |
if (ctx.performed) { | |
Debug.Log("Jumped"); | |
} | |
} | |
public void OnInteraction(InputAction.CallbackContext ctx) | |
{ | |
if (ctx.started) { | |
Debug.Log("Started"); | |
} else if (ctx.canceled) { | |
Debug.Log("Canceled"); | |
} else if (ctx.performed) { | |
Debug.Log("Performed"); | |
} | |
} | |
public void OnScroll(InputAction.CallbackContext context) | |
{ | |
if (context.performed) { | |
var value = context.ReadValue<float>(); | |
Debug.Log(value); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment