12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class TestStartScene : MonoBehaviour
- {
- bool state = true;
- Gyroscope gyro;
- public Text debug;
- private void Start()
- {
- gyro = Input.gyro;
- gyro.enabled = true;
- // debug.text = Vector3.zero.ToString();
- // transform.eulerAngles = new Vector3(0, 133, 0);
- }
- private void LateUpdate()
- {
-
- if(API_SVR.GetHead()!=null&&state)
- {
- state = false;
- transform.position = API_SVR.GetHead().position;
- // transform.eulerAngles = API_SVR.GetHead().eulerAngles;
- StartGyroscope();
- this.enabled = false;
- }
- }
- /// <summary>
- /// 调用陀螺仪 来确定物体摆放位置
- /// </summary>
- public void StartGyroscope()
- {
- if (SystemInfo.supportsGyroscope)
- {
- Vector3 a = gyro.attitude.eulerAngles;
- // a = new Vector3(-a.x, -a.y, a.z);
- Debug.Log(a);
- //transform.eulerAngles = a;
-
- transform.eulerAngles = new Vector3(0, (-a.y+(-a.y+110)), 0);
- debug.text = a.ToString();
- }
-
- }
- }
|