LoginSignup
5
5

More than 5 years have passed since last update.

Daydream入門

Posted at

準備

  1. Google VR SDK for Unityをインポートする。

  2. Android7.0以上に設定
    Other Settings > Minimum API Level > Android7.0

  3. SDKをDaydreamに設定
    XR Settings > Virtual Reality Supported > Virtual Reality SDKs > Daydream

ヘッドセットの動きをマウスで擬似的に表現する

GoogleVR/Prefabs/GvrEditorEmulatorをヒエラルキーに置く
https://developers.google.com/vr/unity/reference/prefab/GvrEditorEmulator

2台目のアンドロイド端末をコントローラにする(手元にコントローラがない場合)

The Controller Emulator
https://developers.google.com/vr/daydream/controller-emulator#game_engines

参考
Controller Emulatorを利用してDaydream実機なしでDaydream対応アプリを開発する方法

ビルドせずに実機でアプリの挙動を確認する

GoogleVR/Prefabs/InstantPreview/GvrInstantPreviewMainをヒエラルキーに置く
https://developers.google.com/vr/develop/unity/instant-preview

初回起動時にInstant Previewアプリが自動でインストールされる。
次回からはinstantPreview.csInstall Apk on Runのチェックを外す。

コントローラでクリック

コントローラでポインターを合わせたオブジェクトをクリックする、といった一番基本的な動作を実装する手順。
https://developers.google.com/vr/develop/unity/controller-support

コントローラのエントリポイントを設置する

GoogleVR/Prefabs/Controller/GvrControllerMainをヒエラルキーに置く
https://developers.google.com/vr/unity/reference/prefab/GvrControllerMain
接続状況、バッテリー残量、ジャイロ、加速度、ボタンの押下など、コントローラの状態を知るスクリプトがアタッチされているプレハブ

ポインターを設置する

GoogleVR/Prefabs/Controller/GvrControllerPointerをヒエラルキーに置く
https://developers.google.com/vr/unity/reference/prefab/GvrControllerPointer

子要素のLaserにアタッチされているGvrLaserVisual.csShrink Laserのチェックを外すとポインターまでの線が引かれる。
https://developers.google.com/vr/unity/reference/class/GvrLaserVisual

イベントを有効にする

GoogleVR/Prefabs/EventSystem/GvrEventSystemをヒエラルキーに置く
https://developers.google.com/vr/unity/reference/prefab/GvrEventSystem

レイキャストする

メインカメラにGvrPointerPhysicsRaycaster.csをアタッチ
https://developers.google.com/vr/unity/reference/class/GvrPointerPhysicsRaycaster

クリックされた時の処理を設定する

対象オブジェクトにEvent Triggerをアタッチ
Add New Event Type > PointerClickを選択
最後にクリックイベント(正規コントローラのタッチパッドを押し込む)が発火したときに呼びたい関数を設定して完成
https://docs.unity3d.com/ja/current/ScriptReference/EventSystems.EventTrigger.html

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5