Unity 3d 2017.2.1 相机源在 iPad 中看起来已放大


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraFeed : MonoBehaviour {
// Use this for initialization
public Renderer rend;
void Start () {

    WebCamDevice[] devices = WebCamTexture.devices;
    // for debugging purposes, prints available devices to the console
    for(int i = 0; i < devices.Length; i++)
    {
        print("Webcam available: " + devices[i].name);
    }
    Renderer rend = this.GetComponentInChildren<Renderer>();
    // assuming the first available WebCam is desired
    WebCamTexture tex = new WebCamTexture(devices[0].name);
    rend.material.mainTexture = tex;
    //rend.material.SetTextureScale("tex", new Vector2(1.2f, 1.2f));
    tex.Play();
}
// Update is called once per frame
void Update () {
}
}

我使用上面的代码在平面上渲染相机馈送。代码工作正常,但是当部署到iPad时,我看到了缩放的提要(约1.2倍(。我怎样才能获得正常的饲料。或者如何缩小相机源

根据

https://answers.unity.com/questions/1421387/webcamtexture-zoomed-in-on-ipad-pro.html,如果您插入此代码,它应该可以正确缩放:

rend.material.SetTextureScale("_Texture", new Vector2(1f, 1f))

此外,似乎您正在尝试这样的事情,但是您的向量已关闭(0.2f(,尽管您也注释掉了该行。 您可以进一步缩小比例,但如果相机不支持缩小:),这可能会使图像变小。

相关内容

最新更新