If your tablet, phone or laptop has a gyroscope device then you can used with Unity 3D game engine.
Create your project and use this C# script to test and show info about your gyroscope device.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class GyroDevice : MonoBehaviour { private bool gyroEnable; private Gyroscope gyro; // Use this for initialization void Start () { // enable the gyroscope gyroEnable = EnableGyro(); } private bool EnableGyro() { // test the gyroscope if (SystemInfo.supportsGyroscope) { gyro = Input.gyro; gyro.enabled = true; return true; } return false; } // Update is called once per frame void Update () { if (gyroEnable) { // show info from gyroscope Debug.Log("attitude "+gyro.attitude); Debug.Log("gravity " + gyro.gravity); Debug.Log("userAcceleration " + gyro.userAcceleration); } } } |