Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Render UI on the top of everything

Discussion in 'VR' started by jimmychen0123, Feb 21, 2023.

  1. jimmychen0123

    jimmychen0123

    Joined:
    May 17, 2020
    Posts:
    12
    Hello everyone,

    In VR, sometimes when opening up the UI, it is blocked by the objects in the scene. I wonder if there is any solution out there using URP render object?

    How to Make Physics Hands in VR - PART 2 - Unity VR Tutorial - YouTube

    In the video, it used the Render Object in the forward renderer for an object, however, it does not work for me when using this approach on UI.
     
  2. Niter88

    Niter88

    Joined:
    Jul 24, 2019
    Posts:
    112
    Check if your canvas are rendered as overlay
    Check if the shader of that object is being rendered after the UI render pass
     
  3. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    3,437
    For world space canvases you can use a custom shader to render on top of everything. Can be found online
     
    jimmychen0123 likes this.
  4. jimmychen0123

    jimmychen0123

    Joined:
    May 17, 2020
    Posts:
    12
    Hello DevDunk,

    Thanks for the reply, I am aware of having a custom shader may solve the issue, I was wondering if there are ways without using a custom shader since I am not familiar with shader stuff.
     
  5. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,578
    if URP supports multiple cameras, can put UI in different layer and render with UI camera on top of main camera.
    (at least in BiRP this is good way to avoid post processing in world space UI elements and to draw UI on top)
     
  6. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    3,437
    1. You can have 1 camera which only renders UI. This is less performant however
    2. You don't have to write a shader yourself, since this has been done a lot already. Just google the shader, right click in your project -> create -> shaders -> unlit, open the file, replace the code with the shader from online, profit. It's not hard
     
    jimmychen0123 likes this.
  7. jimmychen0123

    jimmychen0123

    Joined:
    May 17, 2020
    Posts:
    12
    We tried that, however this approach affect the performant quite a bit...
     
  8. Niter88

    Niter88

    Joined:
    Jul 24, 2019
    Posts:
    112
    Use just one camera for all UI. You can render your canvas as overlay on the main camera.
    It should not be expensive, unless you're rendering on a calculator or you have done something wrong on your game.
     
  9. jimmychen0123

    jimmychen0123

    Joined:
    May 17, 2020
    Posts:
    12
    My development experience in VR is that an overlay canvas does not work in VR. And the solution I am looking for is too use an world space canvas and render it on the top of everything. And I think using a custom shader is the best so far.
     
    Niter88 likes this.
  10. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,578