Screen Space - Overlay Canvas for VR in Unity - unity3d

How can I get the effect of Screen Space - Overlay Canvas on VR?
I want both of the eye cameras to have menus in the exact same positions.
I don't want to mix it with world space, so the only option I can think of is having a duplicate of each UI element, one for each camera.
Am I missing a simpler solution?

Related

Unity XR Interaction Toolkit multiple cameras shows mirrored pixelated mess

New to unity so hoping this is a dumb / quick fix.
I'm using XR Interaction Toolkit's XR Origin camera (device-based if it matters) and want to add a second camera to overlay my UI elements so the canvases appear on top of walls / elements instead of intersecting and being hidden by them.
I've duplicated my main camera and removed all scripts except the main camera one, set it as a child to the previous main camera, and adjusted the culling masks to be UI-only and Everything-but-UI. I've also set the depth of the ui camera to be higher than the main camera, and set Clear Flags to Depth only. My UI elements are in the correct layer and the camera of the canvas is the child UI camera.
The result is a disaster. When I click the button to bring up my UI overlay, me view becomes a 360 pixelated block of tiny mirrored rectangles.
Any help would be appreciated, or workarounds not using 2 cameras.
Thanks all

How do I get the 2d sprite gameObject in front of the UI Canvas?

hierarchy
2d sprite
panel UI
in game
Fist make sure your canvas' Render Mode is not set to Screen Space - Overlay.
If it is, then switch it to Screen Space - Camera and then change its Render Camera property to point to your main camera.
You can then use the following canvas' properties to control where it appears in relation to other sprites (which appears on top of which), the same way you control any other 2D Sprite:
Sorting Layer
Order in Layer
Also worth noting that 2D Sprites with same Sorting Layer and Order in Layer will use the distance to the camera to decide which one appears on top of which, and the same is true for the canvas:
If your canvas' Render Mode is set to Screen Space - Camera, it will always be positioned in front of your camera and you need to use its Plane Distance property in order to position it correctly.
If your canvas' Render Mode is set to World Space, you can position it freely in the world in the same way you position any other sprite.
First of all the hierarchy window in unity is completely irrelevant when its about positioning.
In Unity everything is 3D, even if you switch to 2D perspective.
So in your case you still have your camera, your sprite and your canvas in a 3D Dimension.
To set your sprite in front of the canvas you only need to increase the positioning stats (seen in your "panel UI" screenshot) at least slightly closer to your camera than the canvas is.

Unity - Screen overlay canvas is visible through wall

How do i properly use Overlay Canvas so that it is not visible over walls. As seen in the image below the canvas is seen through the wall(the white line in Game view). I am using a free roam camera that you can freely move in the Game. I tried using Screen Space - Camera canvas but when i move my camera in Game the edges are flikering.
What you are seeing in your game view is the "Gizmo", which shows the canvas outline. If you disable gizmos in the game view (top right of the game view, just click the "Gizmos" text", the white line will no longer be visible. This wouldn't show in a build of the game even if you have it enabled in your editor.
As Robin said, what you're seeing is just the canvas gizmo in the scene view. It's so big because it's scaled in world units to the resolution of your game view.
If it's getting in your way you can hide it without disabling it or turning off gizmos by clicking the little eye icon in the left of the hierarchy. The little finger icon will disable selecting it by clicking in the game world, so it doesn't get in the way of trying to select other objects.
If you're using an older version of unity, you may need to just disable the canvas and remember to turn it back on before you build, or disable gizmos.

Game design is scaled when exporting to iOS/Android from unity3d

I am new to unity and trying to build a simple game. When I work on unity Editor it seems to work fine.
Say in unity I am checking with dimension 1334x750:
And in phone it looks different - iphone7 - 750*1334
As you see, the text on top basket, the pink ball placement and other balls alignment all are different
I am assuming everything here is under the Canvas GameObject.
In the Canvas Scaler Component of the Canvas select Scale with screen size.
If everything is not under Canvas the issue might be that the barrels are in world space whereas the letters are in Screen Space and hence they vary at different points.
You can use WorldtoScreenPoint() to set the position of the points

What is the relation between the Camera and the Canvas in Unity?

I'm not understanding the relationship between these two objects. I'm searching for a good explanation but I can't find anything simple.
We need to define in a simple way what is Canvas and Camera.
The Canvas is the area that all UI elements (buttons, panels, text...) should be inside.(https://docs.unity3d.com/Manual/UICanvas.html)
A Camera is a device through which the player views the world (player, enemies, props, buttons...).
(https://docs.unity3d.com/ScriptReference/Camera.html)
Everything the camera sees is the screen space or world space. The canvas is overlapped on the Camera. So the relation between them are Render modes of Canvas, they allow you to represent the user interface in different ways (screen space - overlay, screen space - camera or world space).
I hope it's helpful.
Regards!