我已经下载了sdk并试图加载演示场景但是当我导出apk时没有头部跟踪,有什么建议吗?
在安装apk时,我得到立体声场景并且立方体正在旋转,但没有头部跟踪。我可以打开和关闭失真,但没有找到我可以启用头部跟踪的位置。
非常感谢任何帮助。
答案 0 :(得分:1)
1。)使用以下内容在Unity3D中创建一个新的c#脚本:
using UnityEngine;
using System.Collections;
public class VROneRotateAround : MonoBehaviour {
public Transform target;
public float distance = 5f;
public Vector3 offset = Vector3.zero;
public bool useAngleX = true;
public bool useAngleY = true;
public bool useAngleZ = true;
public bool useRealHorizontalAngle = true;
public bool resetViewOnTouch = true;
private Quaternion initialRotation = Quaternion.identity;
private Quaternion currentRotation;
private static Vector3 gyroAngles; // original angles from gyro
private static Vector3 usedAngles; // converted into unity world coordinates
private int userSleepTimeOut; // original device SleepTimeOut setting
private bool gyroAvail = false;
void Start() {
Input.compensateSensors = true;
transform.position = (target.position + offset) - transform.forward * distance;
}
void FixedUpdate() {
if (gyroAvail == false) {
if (Input.gyro.attitude.eulerAngles != Vector3.zero && Time.frameCount > 30) {
gyroAvail = true;
initialRotation = Input.gyro.attitude;
target.gameObject.SendMessage("StartFlight");
}
return; // early out
}
// reset origin on touch or not yet set origin
if(resetViewOnTouch && (Input.touchCount > 0))
initialRotation = Input.gyro.attitude;
// new rotation
currentRotation = Quaternion.Inverse(initialRotation)*Input.gyro.attitude;
gyroAngles = currentRotation.eulerAngles;
//usedAngles = Quaternion.Inverse (currentRotation).eulerAngles;
usedAngles = gyroAngles;
// reset single angle values
if (useAngleX == false)
usedAngles.x = 0f;
if (useAngleY == false)
usedAngles.y = 0f;
if (useAngleZ == false)
usedAngles.z = 0f;
if (useRealHorizontalAngle)
usedAngles.y *= -1;
transform.localRotation = Quaternion.Euler (new Vector3(-usedAngles.x, usedAngles.y, usedAngles.z));
transform.position = (target.position + offset) - transform.forward * distance;
}
public static Vector3 GetUsedAngles() {
return usedAngles;
}
public static Vector3 GetGyroAngles() {
return gyroAngles;
}
public void ResetView() {
initialRotation = Input.gyro.attitude;
}
void OnEnable() {
// sensor on
Input.gyro.enabled = true;
initialRotation = Quaternion.identity;
gyroAvail = false;
// store device sleep timeout setting
userSleepTimeOut = Screen.sleepTimeout;
// disable sleep timeout when app is running
Screen.sleepTimeout = SleepTimeout.NeverSleep;
}
void OnDisable() {
// restore original sleep timeout
Screen.sleepTimeout = userSleepTimeOut;
//sensor off
Input.gyro.enabled = false;
}
}
打开演示场景并将此脚本附加到VROneSDK预制件。
在属性编辑器中选择Cube as Target并输入6作为距离。
构建应用并在设备上测试它或使用UnityRemote在编辑器中测试行为。
答案 1 :(得分:0)
答案 2 :(得分:-1)
同样在这里:我在左/右分屏中看到演示场景(在网格背景和三个光源上旋转立方体),但没有头部跟踪。也没有预失真。 这是在带有Unity 4.5.3f3的三星Galaxy S3(Android 4.3)上。