Unlit Sphere

Let’s discover a new world with Unity

【Unity】MirageSoloアプリ開発 2019edition - コントローラー入力

OverView

GVR SDK 2019年版におけるコントローラーのクリックイベント受取り

Environment

Windows10 64bit

Unity2018.2.14f1

Google VR SDK - GVR SDK for Unity v1.190.1 (2019-01-16)

Lenovo Mirage Solo - Android 8.0.0

Method

f:id:nagatsukimxi:20190317001409p:plain

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ControllerInput : MonoBehaviour {

    private static readonly GvrControllerHand[] AllHands =
    {
            GvrControllerHand.Right,
            GvrControllerHand.Left,
    };

    void Update () {
        foreach (var hand in AllHands)
        {
            GvrControllerInputDevice device = GvrControllerInput.GetDevice(hand);
            if (device.GetButtonDown(GvrControllerButton.TouchPadTouch))
            {
                Debug.Log("touch");  //(1)がタッチされたとき
            }

            if (device.GetButtonDown(GvrControllerButton.TouchPadButton))
            {
                Debug.Log("button"); //(1)が押されたとき
            }

            if (device.GetButtonDown(GvrControllerButton.App))
            {
                Debug.Log("app"); //(2)が押されたとき
            }
        }
    }
}

コントローラーの画像は  Daydream View のハードウェア - Daydream ヘルプ から拝借した.