gpt4 book ai didi

c# - WebCamTexture 不显示在 Unity3D 中?

转载 作者:行者123 更新时间:2023-11-30 16:10:42 27 4
gpt4 key购买 nike

我正在尝试使用 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com