- Cardboard SDKを入れたらGazeInputModuleも入る
- これをEventSystemに付ければuGUIを見つめるだけでインタラクションできる
- UI側にはEventTriggerをつけて、PointerEnter, PointerExitで発火できる
- uGUI, 3D ObjectどちらもOK
- 最初はシーンのマネージャークラスをEventTriggerのObjectとして設定したが、EventSystem.current.currentSelectedGameObjectがなぜかnullでオブジェクトを引けなかった
- そこで、各UIそのもの(Buttonや3D Cube)をEventTriggerのObjectとして登録する
- これならthisで自身が取得できる
- サンプルとして、下記コードをButtonオブジェクトに付けると、GIFの通り動かせた
using UnityEngine; using UnityEngine.UI; using System.Collections; public class VR2DGUISample : MonoBehaviour { public void OnPointerEnter(){ this.GetComponent<Image> ().material.color = Color.red; } public void OnPointerExit(){ this.GetComponent<Image> ().material.color = Color.white; } }