🐎BLOG🐎

Unity: Input Systemについて

pulished:

まずは入れよう

Package Manager

ストア

Player

player

Script

using UnityEngine.InputSystem;

    [SerializeField] InputAction movement;

例えば

矢印キーを登録 SerializeFieldから

最終

    private void OnEnable()
    {
        movement.Enable();
    }

    private void OnDisable()
    {
        movement.Disable();
    }

    // Update is called once per frame
    void Update()
    {
        float horizontalThrow = movement.ReadValue<Vector2>().x;
        float verticalThrow = movement.ReadValue<Vector2>().y;
        Debug.Log(horizontalThrow + verticalThrow);
    }

参考