Android 在Unity VR应用程序中更改视野

Android 在Unity VR应用程序中更改视野,android,unity3d,virtual-reality,Android,Unity3d,Virtual Reality,我正试图改变一个VR相机的视野值。在编辑器中工作得很好,但当我把应用程序放在手机上时,摄像头有污损的FOV值。有人能告诉我怎样才能有效地改变手机上的视场值吗? 谢谢您可以通过代码来完成。这里有一个脚本,可以让你点击实时调整视场 using UnityEngine; using System.Collections; using UnityEngine.VR; // you always need this to use special VR functions public class VR

我正试图改变一个VR相机的视野值。在编辑器中工作得很好,但当我把应用程序放在手机上时,摄像头有污损的FOV值。有人能告诉我怎样才能有效地改变手机上的视场值吗?
谢谢

您可以通过代码来完成。这里有一个脚本,可以让你点击实时调整视场

using UnityEngine;
using System.Collections;

using UnityEngine.VR; // you always need this to use special VR functions

public class VRUtility : MonoBehaviour {
public GameObject camGroup;
public Camera leftCam;
public Camera rightCam;

public float fov;
private float fovMin = 40;
private float fovMax = 100;

private float camGroupX = 0;
private float camGroupXMin = 0;
private float camGroupXMax = 100;
private float camGroupXStep = 20;


// Use this for initialization
public void Start () {
    // set render quality to 50%, sacrificing speed for visual quality
    // this is pretty important on laptops, where the framerate is often quite low
    // 50% quality actually isn't that bad
    VRSettings.renderScale = 3.0f;

    OVRTouchpad.Create();
    OVRTouchpad.TouchHandler += HandleTouchHandler;

    leftCam.fieldOfView = fov;
    rightCam.fieldOfView = fov;
}

// Update is called once per frame
void Update () {

    if ( Input.GetKeyDown(KeyCode.R) ) {
        InputTracking.Recenter(); // recenter "North" for VR, so that you don't have to twist around randomlys
    }

    // dynamically adjust VR visual quality in-game
    if ( Input.GetKeyDown(KeyCode.RightBracket) ) { // increase visual quality
        VRSettings.renderScale = Mathf.Clamp01( VRSettings.renderScale + 0.1f);
    }
    if ( Input.GetKeyDown(KeyCode.LeftBracket) ) { // decrease visual quality
        VRSettings.renderScale = Mathf.Clamp01( VRSettings.renderScale - 0.1f);
    }
}

private void HandleTouchHandler(object sender, System.EventArgs e){

    var touchArgs = (OVRTouchpad.TouchArgs)e;
    if (touchArgs.TouchType == OVRTouchpad.TouchEvent.SingleTap) {

        fov += 10;
        if (fov > fovMax) {
            fov = fovMin;
        }

        leftCam.fieldOfView = fov;
        rightCam.fieldOfView = fov;
    }

    if (touchArgs.TouchType == OVRTouchpad.TouchEvent.Left || touchArgs.TouchType == OVRTouchpad.TouchEvent.Right){

        camGroupX += camGroupXStep;
        if (camGroupX > camGroupXMax){
            camGroupX = camGroupXMin;
        }

        camGroup.transform.position = new Vector3(camGroupX, 0, 0);
    }
}
}


我也在不同位置之间移动相机,但忽略它。

您可以通过代码来完成。这里有一个脚本,可以让你点击实时调整视场

using UnityEngine;
using System.Collections;

using UnityEngine.VR; // you always need this to use special VR functions

public class VRUtility : MonoBehaviour {
public GameObject camGroup;
public Camera leftCam;
public Camera rightCam;

public float fov;
private float fovMin = 40;
private float fovMax = 100;

private float camGroupX = 0;
private float camGroupXMin = 0;
private float camGroupXMax = 100;
private float camGroupXStep = 20;


// Use this for initialization
public void Start () {
    // set render quality to 50%, sacrificing speed for visual quality
    // this is pretty important on laptops, where the framerate is often quite low
    // 50% quality actually isn't that bad
    VRSettings.renderScale = 3.0f;

    OVRTouchpad.Create();
    OVRTouchpad.TouchHandler += HandleTouchHandler;

    leftCam.fieldOfView = fov;
    rightCam.fieldOfView = fov;
}

// Update is called once per frame
void Update () {

    if ( Input.GetKeyDown(KeyCode.R) ) {
        InputTracking.Recenter(); // recenter "North" for VR, so that you don't have to twist around randomlys
    }

    // dynamically adjust VR visual quality in-game
    if ( Input.GetKeyDown(KeyCode.RightBracket) ) { // increase visual quality
        VRSettings.renderScale = Mathf.Clamp01( VRSettings.renderScale + 0.1f);
    }
    if ( Input.GetKeyDown(KeyCode.LeftBracket) ) { // decrease visual quality
        VRSettings.renderScale = Mathf.Clamp01( VRSettings.renderScale - 0.1f);
    }
}

private void HandleTouchHandler(object sender, System.EventArgs e){

    var touchArgs = (OVRTouchpad.TouchArgs)e;
    if (touchArgs.TouchType == OVRTouchpad.TouchEvent.SingleTap) {

        fov += 10;
        if (fov > fovMax) {
            fov = fovMin;
        }

        leftCam.fieldOfView = fov;
        rightCam.fieldOfView = fov;
    }

    if (touchArgs.TouchType == OVRTouchpad.TouchEvent.Left || touchArgs.TouchType == OVRTouchpad.TouchEvent.Right){

        camGroupX += camGroupXStep;
        if (camGroupX > camGroupXMax){
            camGroupX = camGroupXMin;
        }

        camGroup.transform.position = new Vector3(camGroupX, 0, 0);
    }
}
}

我也在不同地点之间移动相机,但忽略这一点