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

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

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 to set Camera View a Specific Area in UI

My all project works in UI. One of my scene has videoPlayer and I would like to set my MainCamera to that specific Area. This scene is my Recording scene but for recording I have to use canvas Render Mode and has to be "Screen Space - Camera". How I can set my camera view to that specific area.
I tried 2nd camera with culling mask but didn't work because videoplayer is already my UI's child when camera Renders UI showing all children objects.
Is it possible show to camera whereever I want in UI?
enter image description here
Yessir it sure is. I literally had to do this a couple of days ago. Here is a tutorial/video I followed to figure out how to do it for my application. From the sounds of it, all you need to do is follow the video up to ~3 minutes. Then utilize the end product of getting a camera to showcase something in a UI window for your application.
For reference if the video gets deleted the process is as follows:
Create a new GameObject within the Canvas
Add a Raw Image as a child to to the new GameObject
We want a raw image because Raw Images in particular support the addition of a 2d Texture and this is what we need in order to display the Camera view.
Add a new Camera as a child to the GameObject
Create a new Render Texture in you Project Folder
Add the Render Texture to your Camera's Camera Component in the Target Texture field
Add the Render Texture to you Images Raw Image Component in the Texture field
Move the Camera to what you want to view and it should project to your UI GameObject.
If it doesn't do this correctly or the image has weird aspect ratios, check the dimensions in the Render Texture and your Image. It took me a while to get everything to look normal but it really just takes dimension adjustments.
Hope this helps!

How to play 3D animation on a 2D canvas in Unity

I like to play animation on a Canvas.
I made a canvas as shown in the following image.
I like to play a golfer animation on the green color canvas.
Is it possible?
I have animation model as shown in the second figure.
I like to play that golfer animation on the canvas.
How can I do that?
I drag and put under canvas as child object, it doesn't work.
As I explained in my comment, I would do as follow :
Put your object in a specific layer (called MyLayer for the sake of the example)
Set the Culling mask of a new camera to render only this specific layer
Uncheck the MyLayer in the Culling mask of your main camera in order to prevent the latter to render your model
Set the Clear flags to Depth only of the camera to prevent the latter from rendering the skybox
Create a new Render texture in your project, and drag & drop it in the Render Texture field of your new Camera
Add a new Raw Image to your UI canvas and assign the render texture in the Texture field
Run your 3D animation
Your camera will render the animation into the image on your UI

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.