Home > database >  Keep object, attached to parent Camera, visible in front of canvas
Keep object, attached to parent Camera, visible in front of canvas

Time:11-13

I have a canvas that displays an inventory screen. The canvas has alpha 140 (so it's translucent).

When selecting items, an instance of the item will appear on the screen (for example, the pink box in the centre of my photo). This object instance is a child of the camera.

I want the item to be visible "on top / in front" of the canvas, so it's visible without the "filter" of the translucent canvas.

How can I achieve this?

enter image description here

CodePudding user response:

To solve my problem, I did the following:

  • Set canvas Render Mode to Screen Space - Camera
  • Set the canvas Plane Distance to 10
  • Added a RawImage as a child of the canvas, which fills the screen and has the opacity desired.

Then objects which are at a distance less than 10 from the camera are not obscured by the RawImage. This works for my use case as my game will never place any other objects within 10 from the camera.

  • Related