Canvas is not rendering on top

こ雲淡風輕ζ 提交于 2020-01-22 14:55:27

问题


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


回答1:


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

Canvas:

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

Default/Main Camera:

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

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

3.Change Depth to 0.

New Camera:

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

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

3.Change the Culling Mask to UI.

4.Change Depth to 1.

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".

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.




回答2:


Thanks to @Programmer ı understand the general logic but if you're working on a Virtual Reality , you have to do something more .

1-) Copy the Virtual Reality Camera and apply changes @Programmer says



来源:https://stackoverflow.com/questions/37704248/canvas-is-not-rendering-on-top

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!