0

I am trying to transform object into VR app using google cardboard sdk in Unity3d. I write a script and comparing input buttons on Update method. So my code is below.

void Update () {

    if (Input.GetButtonDown("Fire1"))
    {
        onObjectDown();
    }

    if (Input.GetButtonDown("Fire2"))
    {
        onObjectExit();
    }

    if (Input.GetButtonDown("Fire3"))
    {
        onObjectExit();
    }

    if (dragging)
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        Vector3 rayPoint = ray.GetPoint(distance);
        transform.position = rayPoint;
    }
}

onObjectDown() & onObjectExit() method are as follows

public void onObjectDown()
{
    Debug.Log(name + " Game Object Down!");
    distance = Vector3.Distance(transform.position, Camera.main.transform.position);
    dragging = true;
}

public void onObjectExit()
{
    dragging = false;
    Debug.Log(name + " Game Object Exit!");
    GetComponent<Renderer>().material.color = originalColor;
}

This coding is perfectly working on play mode on desktop. But on emulator only onObjectDown is executing. This means only "Fire1" button is pressed. Is anyone know how to get input from button "Fire2" & "Fire3" via bluetooth controller ?

For reference, my input setting in project is as below

enter image description here

4

1 回答 1

0

蓝牙控制器上的按钮 1 您可以使用 Input.GetMouseButton(0) 或 Fire 1 进行初始化,因为它模拟了显示点击。但是另一个控制器按钮模拟(在我的情况下)Android 设备上的后退按钮,所以你可以使用 Input.GetKeyDown(KeyCode.Escape) 进行初始化。

于 2018-03-29T12:38:36.197 回答