Unity基础-Input接口

input

底层的设备输入接口,在开发中很少用到

Input.GetKey()

// Update is called once per frame
void Update () {
    if (Input.GetKey(KeyCode.A))
    {
        Debug.Log("get key a");
    }
    if (Input.GetKeyDown(KeyCode.A))
    {
        Debug.Log("get key down a");
    }
    if (Input.GetKeyUp(KeyCode.A))
    {
        Debug.Log("get key up a");
    }
}

Input.GetButton(),Input.GetButtonDown(),GetButtonUp()类似

Input.touches 触屏

Touch[] touches Input.touches;
foreach(Touch t in touches)
{
    t.fingerId;
    t.deltaPosition;
    t.deltaTime;
    t.phase;
    t.position;
}

TouchScreenKeyboard.Open 触屏输入

TouchScreenKeyboard t = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default);
    
posted @ 2019-05-06 16:46  cicarius  阅读(624)  评论(0编辑  收藏  举报