我正在尝试使用 WebCamTexture 在场景中显示网络摄像头输入。我创建了一个带有一些默认纹理的 Sprite 并附加了以下脚本:

public class CameraTexture : MonoBehaviour {

    void Start () {
        WebCamTexture webcamTexture = new WebCamTexture();
        renderer.material.mainTexture = webcamTexture;
        webcamTexture.Play();
    }
}

但是,当我运行场景(在 PC 上)时,不显示相机输入,只显示默认纹理。
这是我所知道的:
  • webcamTexture 不为空,设备被正确找到
  • 相机设备正常工作
  • 其他应用程序没有阻挡相机

  • 为什么不显示相机输入?

    最佳答案

    我自己找到了解决办法。
    webcamTexture 无法显示在 Sprite 上。
    我不得不创建一个 GUITexture,然后我附加了相同的脚本,一切正常。

    关于c# - WebCamTexture 未显示在 Unity3D 中?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25339994/

    10-13 06:20