Пример #1
0
    void Update()
    {
        if (gyroBool || Application.isEditor)
        {
            #if UNITY_IPHONE
            quatMap = gyro.attitude;
             #endif

            #if UNITY_ANDROID
            if (gyro != null)
            {
                quatMap = new Quaternion(gyro.attitude.x, gyro.attitude.y, gyro.attitude.z, gyro.attitude.w);
            }
            #endif

#if UNITY_EDITOR
            if (rGyro == null)
            {
                rGyro = GyroMote.gyro();
            }

            if (rGyro != null && !started)
            {
                OnStartedGyro();
                started = true;
                Debug.Log("Started");
            }

            if (rGyro != null)
            {
                quatMap = rGyro.attitude;
            }
            else
            {
            }
#endif

            transform.localRotation = quatMap * quatMult;
            m_GyroQuat  = transform.rotation;
            m_GyroEuler = transform.eulerAngles;
        }
    }
Пример #2
0
    public static RemoteGyroscope gyro()
    {
        //Debug.Log ("looking for remote Gyroscope");
        RemoteGyroscope _remoteGyroscope = null;

        GameObject[] gameObjects = UnityEngine.Object.FindObjectsOfType(typeof(GameObject)) as GameObject[];

        foreach (GameObject gameObject in gameObjects)
        {
            //Debug.Log (gameObject.name);

            if (gameObject.name == "RemoteGyroscope")
            {
                //Debug.Log("found remote Gyroscope");
                _remoteGyroscope = gameObject.GetComponent("RemoteGyroscope") as RemoteGyroscope;
            }
        }

        return(_remoteGyroscope);
    }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        if (SystemInfo.supportsGyroscope)
        {
            Vector3 position = new Vector3(gyroscope.gravity.x * -1, gyroscope.gravity.z, gyroscope.gravity.y);
            gravity.transform.position = position;
        }
        else
        {
            if (remoteGyroscope == null)
            {
                remoteGyroscope = GyroMote.gyro();
            }

            if (remoteGyroscope)
            {
                gravity.transform.position = new Vector3(remoteGyroscope.gravity.x * -1, remoteGyroscope.gravity.z, remoteGyroscope.gravity.y);
            }
        }

        transform.LookAt(gravity);
    }
Пример #4
0
 // Use this for initialization
 void Start()
 {
     gyroscope = GyroMote.gyro();
     //gyroscope.attitude;
 }