Unity VideoPlayer无法将视频正确呈现为纹理 [英] Unity VideoPlayer not rendering Video correctly to Texture

查看:985
本文介绍了Unity VideoPlayer无法将视频正确呈现为纹理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用VideoPlayer组件(以URL源和RenderTexture作为目标)在我的Unity手机游戏中显示视频.视频已加载并开始播放,但是生成的纹理只有1种颜色.颜色的确会将每一帧更改为与视频看起来像该帧的颜色相同的颜色,但这只是第一种颜色.音频工作正常.在VideoPlayer组件上,纵横比"设置为"Fit Inside",但是我在这里尝试了所有选项,结果相同.对于RenderTexture,将其设置为与输入视频相同的分辨率,并将颜色格式"设置为RGB565(Android和iOS均应根据SystemInfo.SupportRenderTextureFormat()支持).我全都没主意,任何帮助将不胜感激.

I'm trying to use a VideoPlayer component, with a URL source and a RenderTexture as the target, to show a video in my Unity mobile game. The video is loaded and starts playing, however the resulting texture is only 1 color. The color does change every frame to something matching what the video would look like that frame, but it's just the 1 color. Audio is working fine. On the VideoPlayer component, the Aspect Ratio is set to "Fit Inside", but I have tried all options here with the same result. As for the RenderTexture, it's set to the same resolution as the input video, and the Color Format is set to RGB565 (which both Android and iOS should support according to SystemInfo.SupportRenderTextureFormat()). I'm all out of ideas, any help would be appreciated.

一种解决方法可能是使用材质替代",而不是渲染到纹理.但是,如果您要专门使用纹理而不是仅在材质上显示视频,那么这将不起作用,而且材质覆盖"不支持具有多个渲染器/材质的对象.并不是真正的解决方法,但是对于在找到解决方案之前发现此问题的人来说,这是一种解决方法.

A workaround could be using "material override" instead of rendering to a texture. This doesn't work though if you want to use the texture specifically instead of only showing the video on a material, plus the fact that Material Override doesn't support objects with multiple renderers/materials. Not really a fix, but a workaround for those who find this question before a solution has been found.

推荐答案

我自己已经解决了这个问题. 在原始图像"中,搜索"UV矩形"并将其W和H设置为1.我更改了它,使其仅采样了1个像素.

I just had this myself and fixed it. In the Raw Image, search UV Rect and set its W and H to 1. I had changed that, which made it only sample 1 pixel.

这篇关于Unity VideoPlayer无法将视频正确呈现为纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆