Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created January 8, 2019 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/e4b87b270b3725d00950568275676ad5 to your computer and use it in GitHub Desktop.
Save tsubaki/e4b87b270b3725d00950568275676ad5 to your computer and use it in GitHub Desktop.
Input Systemの簡易な運用
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