Har*_*hen 2 camera unity-game-engine rawimage
我想从Unity3d虚拟相机中捕获帧,然后让它们显示在另一个原始图像上。结果是原始图像屏幕闪烁得非常厉害。
using UnityEngine;
using UnityEngine.UI;
public class RawImageVirtualWebCamTexture : MonoBehaviour
{
private RawImage rawimage;
void Start()
{
GameObject obj = GameObject.Find("RawImageTransform");
rawimage = obj.GetComponent<RawImage>();
}
void OnRenderImage(RenderTexture source, RenderTexture destination)
{
if (source != null)
{
rawimage.texture = source;
}
Graphics.Blit(source, destination);
}
}
Run Code Online (Sandbox Code Playgroud)
我想看到流畅的图片。但如何做到这一点呢?
如果是关于 Unity,Camera则无需捕获任何内容。
只需创建一个新的RenderTexture
Assets-> right click-> Create->RenderTexture
让你的Camera渲染进入其中RenderTexture,而不是通过简单地引用创建的游戏视图来渲染游戏视图RenderTexture(Target Texture这使得它Camera不再渲染到游戏视图,而是渲染到引用的RenderTexture)
最后简单地使用创建RenderTexture的TextureRawImage
如果您需要Camera同时渲染到普通游戏视图,只需Camera在子对象上使用另一个即可执行上述过程。
结果
| 归档时间: |
|
| 查看次数: |
8866 次 |
| 最近记录: |