using UnityEngine;

public class GetAxis : MonoBehaviour
{
    [SerializeField] RectTransform _stick;
    RectTransform _this;

    void Start()
    {
        _this = GetComponent<RectTransform>();
    }

    void Update()
    {
        // Input Manager で定義した軸名を指定して、値を取得する
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");
        Vector3 input = new Vector3(h, v, 0);
        _stick.anchoredPosition = input * (_this.sizeDelta.x / 2);
    }
}
