How to animate an object from World canvas to Overlay Canvas - unity3d

I have a bar on the top of my game with some objects plus the game score, pretty basic and usual. I have some coins (similar to Mario's game) that I would like to animate from the world canvas to the top of my bar that is in a canvas overlay.
By design, the Canvas Overlay is drawn after the camera, so it is on top of my world canvas, so the animation happens to the right position but the object passes behind my menu, not on top of it.
How can I achieve that? To animate an object from my world canvas to the top of an object in a canvas overlay?
This is the my "BAR", the big blue quad behind is the equivalent of my coin and I wish to draw it on top of the small bar.
This is the inspector, the big quad is the object "PieceOfShapeIClone" and the bar in front of it is the "ShapeI" object. Since the "PieceOfShapeIClone" is below it should be rendered on top of the previous objects.

The "Screen Space - Overlay" does not have any dependency on the camera and it is rendered on top of everything.
The solution was to use "Screen Space - Camera" instead, this will require a camera plus set the "depth" of your canvas to the camera, giving the ability to interact with the objects from the scene.
Hope that this help to assist others with the same issue.
Manual -> https://docs.unity3d.com/Manual/class-Canvas.html

Related

How to stop Screen Space Overlay canvas from blocking UI button presses on World Space canvas?

I'm using Unity 2022.1.23f1 and the Universal Render Pipeline. I have a render texture, set to 480x270 with point filtering, to get a cool pixelated effect. In my scenes, I output the camera into the pixelated render texture and render it in a raw image under a Screen Space Overlay canvas. This makes it so that everything is rendered in 480x270.
Everything worked perfectly fine in the main gameplay, as there aren't any UI buttons to press. However, in my main menu scene I have three UI buttons for starting the game, accessing the options menu and quitting the game. The main menu is in 3D, featuring a desk with a monitor on it. I thought it would be cool to have the UI buttons look like they're on the monitor, which is why I made a World Space canvas, where I positioned the three UI buttons on the monitor.
I thought it would be easy to make the buttons interactable, but they don't work. I'm sure it's because the pixelation effect is blocking the UI buttons on the World Space canvas.
I removed the pixelation effect, along with the Screen Space Overlay canvas which holds it, and the buttons worked perfectly.
I googled the problem and found someone saying to remove the Graphic Raycaster component in the Scren Space Overlay Canvas, but that didn't work. I also turned off "Raycast Target" in the pixelation effect's raw image gameobject, but that also didn't work.
Is there any way to make it so that I can interact with the UI buttons in the World Space canvas, while also having the Screen Space Overlay canvas with the pixelation effect? Any help - or even suggestions to make a better pixelation effect - would be appreciated!

Why the cube is transparent on the canvas/panel ui?

I want to animate the cube over the ui panel.
The Canvas is set to Render Mode : Screen Space - Overlay
The Panel have my own source image
The Camera Clear Flags set to Skbox and Culling Mask to UI only
The Cube layer is set to UI
But the Cube is transparent and I want it to be full like a regular Cube.
I think #Draco18s is right, for you to render UI behind stuff you need to change the Canvas to Camera or World space and then configure Z position in transform of the background (or depth in canvas component) to make it stay behind your cube.
Remember to add a camera to the canvas.

Unity2D layering multiple canvas'

I have two canvas' set up for my project, one to act as a background and one to hold foreground UI elements. Originally they were set to world space, and I had no problems, but now I am optimizing my game, I must change the space so they adjust to mobile phones. How can I design the canvas' so that one acts in the background and the other in the foreground? I have tried changing the z-pos and other quick fixes I found online but none have worked.
Ok, you have background canvas, sprites and foreground canvas, and background canvas should be behind everything including sprites.
The idea is to render at first only background with one camera, and then render everything with another.
To do that, we should:
Add a layer for background canvas. Change layer of background canvas and children to that layer.
To add a layer, select any gameObject and in top of the inspector you will see:
Click on a dropdown list labeled "Layer" and select "Add Layer". Then create new layer and give it a name:
Select your background canvas and change layer for it and its children. When adding gameObjects, keep in mind that if you add them to background canvas, their layer must be the same as the layer of canvas, otherwise they will be rendered by the wrong camera.
Disable that layer in main camera's culling mask.
Now the camera should no longer render background UI, and it will disappear in the game view.
Add a camera for rendering background UI.
Cameras with higher depth render on top of those with lower depth, so we should set its depth to less than depth of main camera. We should also set its culling mask to only layer for background UI, otherwise all objects on scene will be rendered twice. Copy other setting from main camera. Set main camera's clear mode to Don't Clear or Depth Only to prevent it from erasing background.
Set mode of the background canvas to Screen Space - Camera and drag newly created camera into field "Render Camera" there.
It should work now.

Match Canvas with Main Camera - Unity

I want to use the Canvas and UI Text to constantly show the score of my game on the top right corner of the screen. How can I initialize the Canvas so that its position and dimensions perfectly match the border of the camera? (2D Setup)
To see the canvas fit into the camera's size in the scene, change the Canvas component's Render Mode to Screen Space - Camera, and drag the camera from the hierarchy to it.

How to change canvas position in Unity?

I'm very new in Unity and in GameDevelopment at all. So I've started with Roll-a-Ball tutorial. And now I have a trouble with UI Lesson. When I create Text element Canvas parent creates in strange position.
But in lesson I see that Canvas is near Player object. How can I move it?
If you want to see the canvas fit inside your scene camera's view, change the Canvas's Render Mode to Screen Space - Camera; then drag the Main Camera onto the newly visible Render Camera field in the inspector.
See the bit in your canvas inspector about it being "screen space - overlay"?
That means:
"This render mode places UI elements on the screen rendered on top of the scene. "
And what THAT means, is that you don't have to worry about where the Canvas and child Text show up in your scene view. When you run the game the UI elements will overlay on the background world objects and it'll all be fine.
Source:
http://docs.unity3d.com/Manual/UICanvas.html
It shouldn't matter where the canvas is located, but you can select the child object called 'text' and change the X and Y values to move it around the screen. I hope this helps!