#Bringing up a canvas element from bottom of mobile screens

1 messages · Page 1 of 1 (latest)

stark patio
#

Hello everyone, I have canvas panel that has a height of 520 that I want to bring up from the bottom of the screen. It is currently anchored on bottom and stretches across the width. When testing different screen resolutions I'm noticing that even though I am setting the position Y at -520 when I programmatically confirm that number it it changes based on screen resolution? I was very surprised at that. So when I try to slide it up/down with code it doesn't work at all. I'm assuming I have to get its current position Y and then do things from there but I wanted to check to make sure I'm not missing something silly.

placid gale
#

One way is to set the pivot to the top of the panel but the anchor to the bottom of the screen so that y:0 is perfectly off screen. Then you can tween it in to the y-value of the rectTransforms height value and closing the panel would tween it back to 0.

stark patio
#

That sounds like what I was looking for. I tried to learn about pivots a while ago but couldn't find any good information about it...where is my pivot currently set right now?

#

I see pivot in the inspector X=0, Y=0 but I'm not clear what that means

placid gale
#

That would be the corner. You probably want to try 0.5 and 1to move it to the top middle.

stark patio
#

@placid gale : For some reason it is still not working as expected. So I set the pivot to 0,1. When I set the Pos-Y to 520 in the editor it works as expected

#

However, when I do it via code, if you look at the console it is setting the Pos-Y to 520 but in the inspector its actually a much lower number?

#

It makes no sense to me why they are different numbers

#

Ok...I think I got it...I'm basing my movement around rectTransform.anchoredPosition now and that seems to have fixed it. Thank you for your help.