Canvas not doing what I want it to do

Hello,

currently I´m working on an AR-project using ARToolkit in Unity3D.
When it comes to the UI design, Unity3D is driving me nuts since I cannot understand its behaviour - please see the scene and game window on the left side.

What I have are 2 canvas - one with the “X”-button on the bottom right and one with the sprite in the center.
I cannot understand why the 2 canvas do not lie on top of each other but instead one is somewhat shifted down.

The canvas that is selected in the screenshot, includes the sprite, but in order to make it display, I have to move it outside its parent canvas - which makes it more confusing :frowning:

All I want to have is the sprite to be centered in the aspect ratios 16:9 and 16:10. :confused:

I hope that the description is detailed enough - If you have further questions, feel free to post them.

Many thanks,
Vulture_6

In Canvas : On Render mode Put in Screen Space Camera then Drag the Camera Below, so the canvas is set to the camera

Hope this is what you need

1 Like

Thank your for your answer - I should have mentioned, that I need this sprite to act as an overlay once i have clicked on my 3D-model in the AR-scene. See the attachment.

Does this make the only possible render mode for the canvas “Screen Space - Overlay”?

2774021--200567--Editor_Screenshot_2.jpg

Is there a reason you need 2 Canvas? It might be adding a level of difficulty you don’t need. Maybe have just one canvas in ScreenSpace - Overlay mode. Have the button and the Sprite both be children of the one canvas. You can always just enable/disable the sprite as needed and keep the button on all the time.

You can set the sprite’s RectRansform to be centered in the middle and Anchor the button to the bottom right.

1 Like

The problem is that the canvas with the sprite only becomes active, once the user clicks on a 3D-Model in the AR-scene.
If the button, that leads back to the main menu, becomes a child of that canvas, the user will only be able to return to the main menu when that canvas is visible - which is not exactly what I wish.

Instead, I would like the button to be visible at any given time - this is why I´m using a 2nd canvas outside the AR-hierachy. But for some reason, Unity3D apparently assigns random coordinates to my canvas when it is created with the render mode “Screen Space Overlay” (what I think I need for my purposes), causing these weird image shifts within the canvas (See attachment in post #1)

Thank you all for looking into this :slight_smile:

Issue resolved - it turns out that a canvas with a sprite does not have to be part of the AR-toolkit-tree in the hierachy in order to be displayed in the AR-scene. :slight_smile:

Now I´m able to use the rect-transform tool normally without any random offsets. hooray