LoginSignup
2
2

More than 5 years have passed since last update.

【Unity Remote 5】実機の画面が動かない

Last updated at Posted at 2017-11-21

ジャイロを有効にしていないだけだった

構成
VR Player
  ┗ Main Camera

VR Playerに以下のスクリプトをアタッチ

GyroRotate.cs
using UnityEngine;
using System.Collections;
public class GyroRotate : MonoBehaviour {

    private Gyroscope gyro;

    void Start () 
    {
        if (SystemInfo.supportsGyroscope)
        {
            gyro = Input.gyro;
            gyro.enabled = true;
        }
        else
        {
            Debug.Log("Phone doesen't support");
        }
    }

    void Update () 
    {
        transform.Rotate (-Input.gyro.rotationRateUnbiased.x, -Input.gyro.rotationRateUnbiased.y, 0);
    }

    void OnGUI()
    {
        GUILayout.Label ("Gyroscope attitude : " + gyro.attitude);
    }
}

これでUnity側でGame Windowを見ている間、スマホ実機のジャイロを取得して画面を動かすことができる。

参考
【Unity】「Unity Remote 5」の使い方
How to enable head tracking in Gear VR via Unity Remote 5 on android?

2
2
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
2
2