Author Topic: UI Panel to full screen?  (Read 5710 times)

murteas

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
UI Panel to full screen?
« on: February 14, 2014, 11:29:12 AM »
Hi all.   I am trying to do something that I think should be simple, but in practice is eluding me.   I would like to have a UI Panel take the full screen, and the controls it contains to move relative to the position of the panel after it gets its resolution. 

I started out by anchoring (with the new system) the UI Panel to the UIRoot and simply setting left: 0, right: 0, bottom:0, top:0 thinking this would inherit the UIroot size and therefore be the fullscreen.   However, this isn't the case, I get the full screen in height, but not width (this is with pixel perfect or fixed on mobile with a height max of 900).   Also, when I do this my widgets move after I hover over them (especially buttons which have a tween scale on them), and go off screen.   

So, my real question is:  how do I get a panel to be full screen?   and should I even be trying to scale the UI to full screen, what is the best practice here?   I want a program that can be used on mobile, but also pc?

Thank you in advance.

 

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UI Panel to full screen?
« Reply #1 on: February 15, 2014, 01:06:16 AM »
Panel full screen? A panel is what collects and draws widgets. Panels have no size by default. They can have clipping if you enable it, but that's it. Only widgets always have a size, so I don't quite understand what you mean. If you're just trying to keep your UI the same size proportionally to screen height, then use a fixed size UIRoot.

murteas

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: UI Panel to full screen?
« Reply #2 on: February 15, 2014, 10:32:49 PM »
OK, maybe I am doing something I shouldn't...I use a UIPanel, set the clipping to constrain and then set it's size to the size of the UI Root (i.e. Anchor left, right, bottom, top to 0), then I set widgets as children of the panel, and then set their size relative to the panel.    My initial thought was that I could get the UI to take the full screen this way, but maybe I shouldn't do it that way?

Ignoring that I am using a panel then, how would I make a sprite the full size of the screen?  Say a background sprite that was tiled?   Should I have it anchored to UI root, or some other method?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UI Panel to full screen?
« Reply #3 on: February 16, 2014, 02:53:19 AM »
Anchor it to UIRoot, left to left, right to right, etc, with padding of 0.

murteas

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: UI Panel to full screen?
« Reply #4 on: February 18, 2014, 01:25:10 PM »
Ok...So if you look at my OP you should see that I was doing exactly as ArenMook suggested, i.e. anchor to UIRoot with left to left, right to right with padding of 0. 

So, why was I getting the wrong behavior?   The answer, I had left a camera in the scene that shouldn't have been there.  I had the UI camera in the scene, but I also had another camera (the default one from unity) in the scene.  It was causing the strange behavior I was seeing (i.e. the sprites not filling the screen).

So, for anyone looking in the future, chalk this up to user error, and watch out for the extra cameras.  :)