画布不在顶部渲染 [英] Canvas is not rendering on top

查看:71
本文介绍了画布不在顶部渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了画布和Unity UI元素作为HUD.我希望HUD摆在一切面前,但事实并非如此.

I used a canvas and Unity UI elements as a HUD. I want HUD to be in front of everything but it's not.

推荐答案

以前没有使用Cardboard,但我相信您可以通过相机剔除来解决此问题.只需执行以下步骤:

Haven't worked with Cardboard before but I beleive you can fix this with camera culling. Just follow the steps below:

画布:

1.选择Canvas并将``图层''更改为UI.默认值为UI,但请确保仍将其设置为UI.

1.Select the Canvas and change the Layer to UI. The default is UI but make sure that it is still set to UI.

默认/主摄像头:

1.选择已经存在的主摄像机,然后将Clear Flags更改为Skybox.

1.Select the Main Camera that was there already there and change the Clear Flags to Skybox.

2.将Culling Mask更改为Everything.单击设置为Culling MaskEverything,然后取消选择/取消选中 UI.

2.Change the Culling Mask to Everything. Click on Everything which is a setting of Culling Mask and de-select/uncheck UI.

3.将Depth更改为 0 .

新相机:

1.创建一个新的Camera并将其命名为UI Camera.

1.Create a new Camera and name it UI Camera.

2.选择UI相机,将Clear Flags更改为Depth Only.

2.Select the UI Camera, change the Clear Flags to Depth Only.

3.将Culling Mask更改为UI.

4.将Depth更改为 1 .

5.如果要在顶部显示的Canvas将"Render Mode"设置为"World Space"或"Screen Space - Camera",则将UI Camera拖动到Canvas的"Render Camera/Event Camera"插槽.如果将"Render Mode"设置为"Screen Space - Overlay",则不必这样做.

5.If the Canvas you want to display on top has the "Render Mode" set to "World Space" or "Screen Space - Camera" then drag the UI Camera to the Canvas' Render Camera/Event Camera slot. You don't have to do this if the "Render Mode" is set to "Screen Space - Overlay".

就是这样.这将始终在前面显示UI.默认情况下,它应该可以使用,但是由于某种原因它对您不起作用.

That's it. This will always display the UI in the front. It should on default but its not working for you for some reason.

这篇关于画布不在顶部渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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