Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Can I render a LineRenderer above a canvas that is in Screen Space - Overlay mode?

Discussion in 'UGUI & TextMesh Pro' started by sPYfromFranik, Mar 19, 2024.

  1. sPYfromFranik

    sPYfromFranik

    Joined:
    Mar 6, 2017
    Posts:
    18
    Hello, loving community of Unity!
    I have an issue. I'm using a canvas to display the UI of the player. This canvas is set to Screen Space - Overlay mode.
    It's comfy, because I'm sure no ingame object will show up between my camera and my inventory, pause menu or black screen.
    Currently I'm trying to make a minigame. A player interacts with an ingame object, a screen turns black and now a player has to draw a specific shape in order to do some action. So I have a black image in my hierarchy, that I enable and increase its alpha to 1. And I would like to draw that shape above that black screen.
    Currently I'm trying to render that shape using LineRenderer, which is rendered in the world, rather than on the canvas.
    Is there any way to either force LineRenderer to be rendered on the same canvas as my black screen (with different Z value) or somehow make Unity render that LineRenderer even above my Canvas?
    Thanks!
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,495
    You'll want a UI Line Renderer. There are some on github and some YouTube videos on how to create your own. This basically creates UI elements on the fly.

    You probably want a separate canvas for this activity, also Overlay, but set to appear on top of your other one by setting the sort ordering.