Unity XR Interaction Toolkit multiple cameras shows mirrored pixelated mess - unity3d

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

Related

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.

Oculus Unity VR - Separate UI Camera Not Working

I have a VR project for which I am trying to render a canvas to be "always on top" of everything using a separate UI camera as noted here.
I made my UICamera object a child of the main camera - which is the centerEyeAnchor object in the OVRCameraRig.
And I set the culling mask for my UICamera to only show its layer and removed that layer from the main camera (CenterEyeAnchor).
But in fact the perspective is weird and it seems like the UICamera is offset a little bit but its transform is zero'd out in the inspector, so I don't why it's displaying so weird.
If I set the culling mask to "Everything" for both cameras it's still offset a little.
In general you don't need the UI camera to be a child of CenterEyeAnchor. Move it out to to the top level and zero out the coordinates. The Oculus rig might be doing some magic with IPD or something else and it screws up the pixel-perfectness of UI.

Second camera does not show UI Image element (but does show sprite)

I am working on a Unity 2D board game similar to WordFeud: a gameboard with tiles (UI Image prefabs generated with code), with underneath the board a user interface with draggable tiles, buttons, scores etc. I want to zoom in on the game board by double tap on the screen.
The game scales with the device resolution using the canvas scaler option as demonstrated here:Charger Games. For the zoom I have added a second camera that renders its output to a render texture as explained here:Gamasutra. The render texture will eventually take the position of the game board. In the example screens attached it is a bit smaller than the full board to show what's happening.
In the trial setup I am able to perform the zoom with the second camera on a sprite (dragged to the scene) but the second camera fails to render a UI Image element if added to the scene. Yet this is what my game is composed of: UI Image elements.
Question: how do I get the second camera to show UI Image elements on the render texture?
Attached an image with combined screen dumps of the setup. From left to right: 1) the main canvas with the scaler enabled (it uses the UI image - game board to fill the background), 2) second camera setup (note that camera preview shows the Wordfeud sprite, but not the UI Image test), 3) params of WordFeud sprite, 4) params of UI Image test, 5) params of RawImage - render texture (this is a child of Minimap canvas).
I does not matter if I put the sprite or the UI Image in the default layer or the UI layer, the result in both cases is the same: the sprite is rendered, the UI Image is not.
Unity version 5.3.3.f1

how to render static 3d object in certain coordinates unity

This is my first time with unity, I need to make a 3d object in the camera of the device (vr) in certain coordinates of a map, do you know any links that can help me? Is only a static object will always be in the same position and users will be able to see it on their devices
If this is to be overlayed above a 3D scene use a renderTexture, then add the rendered texture to the UI using a Raw Image component.
Another way to do this is to use a canvas set to screen space overlay rendering. You can create a canvas by going to GameObject > UI > Image.
(see page for UI>canvas on Unity manual site, I can only post 2 links as a new user)
The canvas in this rendering mode is described this way on the unity manual page for the UI Canvas:
Screen Space - Overlay
This render mode places UI elements on the screen rendered on top of the scene. If the screen is resized or changes resolution, the Canvas will automatically change size to match this.
I am assuming this is a UI element over a 3D scene, because you mentioned VR.
Credit: I got some of my links and info from the unity forum thread "What is the best way to display 3D models as UI elements?"

Unity3D - Embedding a 3d scene in a 2d scene

I'm fairly new to Unity and I'm trying to embed a 3d view inside a 2d one.
I'm working on an emulation app that has a 2d UI for controls and a preview of the result in a 3d box that should be embedded in the 2d one, sort of as a player.
What's the right approach to doing that in Unity? Is there a way of "embedding" one scene in another?
Thanks!
If you want to create 3D effect with UI canvas, you should look to this link.
If you are using 2D project, it is basically 3D scene with camera set to use ortographic projection, not perspective. So you can use 3D models as well.
You should look into Render Texture. Those allows to render a camera view onto a texture in a scene. Say you have a part of a scene an dyou want to render onto a TV screen in your game. You would place the TV scene somewhere and place your camera to view it. Then you create a render texture and apply onto the mesh that is making your tv screen.
Now if you wish to make a UI system, like a radar with a top view, you would modify the viewport of your top view camera (0,0,.2,.2 would place it bottom left corner with 20% height and width) and make the depth higher so that it renders on top of the main camera.