Created
January 8, 2019 13:36
-
-
Save tsubaki/e4b87b270b3725d00950568275676ad5 to your computer and use it in GitHub Desktop.
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.Experimental.Input; | |
public class InputTest2 : MonoBehaviour | |
{ | |
public InputAction mouseInput; // マウスの入力 | |
public InputAction fireInput; // ボタンの入力 | |
private void OnEnable() | |
{ | |
mouseInput.Enable(); | |
fireInput.Enable(); | |
} | |
private void OnDisable() | |
{ | |
mouseInput.Disable(); | |
fireInput.Disable(); | |
} | |
private void Awake() | |
{ | |
mouseInput.performed += _ => | |
{ | |
var value = _.ReadValue<Vector2>(); | |
Debug.LogFormat("pos:{0}, time:{1}", value, _.time); | |
}; | |
fireInput.performed += _ => | |
{ | |
Debug.Log("Fire"); | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment