Unity VideoPlayer 全屏到 FGUI

需求:

利用VideoPlayer将视频全屏显示到FGUI上。


解决方案:

在FGUI上创建一个全屏UI,创建一个装载器,大小设置为全屏。

设置 VideoPlayer 的渲染方式为 RenderMode.RenderTexture.

创建RenderTexture,(将视频加载到 RenderTexture 上)

动态创建 RenderTexture

复制代码
 public void CreateVideoRender()
    {
        VideoRenderTexture = RenderTexture.GetTemporary(1920,1080,32, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);    
    }

然后将 videoPlayer 的 targetTexture 赋值

复制代码
      videoPlayer.targetTexture = ClientCameraManager.Inst.VideoRenderTexture;

最后设置 fugui的装载器的url为 创建的 VideoRenderTexture就好了。

self.fullScreen.texture = xxx.VideoRenderTexture

相关推荐
怣疯knight5 小时前
Cocos creator判断节点是否能用的方法
unity·cocos2d
tealcwu5 小时前
Google Play的Keystore不可用时的解决方法
unity
呼呼突突6 小时前
Unity使用TouchSocket的RPC
unity·rpc·游戏引擎
qq 1808095120 小时前
从零构建一个多目标多传感器融合跟踪器
unity
平行云21 小时前
实时云渲染支持在网页上运行UE5开发的3A大作Lyra项目
unity·云原生·ue5·webgl·虚拟现实·实时云渲染·像素流送
鹏飞于天21 小时前
Shader compiler initialization error: Failed to read D3DCompiler DLL file
unity
wonder135791 天前
UGUI重建流程和优化
unity·游戏开发·ugui
那个村的李富贵1 天前
Unity打包Webgl后 本地运行测试
unity·webgl
nnsix1 天前
Unity OpenXR开发HTC Vive Cosmos
unity·游戏引擎
nnsix1 天前
Unity OpenXR,扳机键交互UI时,必须按下扳机才触发
unity·游戏引擎