Author Topic: Popup message boxes  (Read 9459 times)

jdwieber

  • Guest
Popup message boxes
« on: June 30, 2012, 02:00:41 PM »
I'm using a UIButton with a scale tween as a popup message box that scales in from the center of the screen.  I have it attached to my 2D UICamera tree and it's not enabled by default.  When the player completes a level, my trigger enables it recursively and it grows in with the message displayed.  I have a UIStretch attached to the background, and the label.  Everything works well except one crucial piece.  The collider on the button lives one level above the background and label and is not scaled with the two.  If I put a UIStretch on the parent node of the UIButton, then the label text and background are blown way out of proportion.  I'm using a button to simulate the textbox because I want the user to click to dismiss it (and that part works fine too when the tiny collider is hit).  What is a better way to approach this?  Should I remove the default collider and place one on the background sprite?  Or, should I create a new UI script and start from scratch?  I'd like to stick with the tools already available in NGUI if possible.  Thanks.

Regards,

Joseph

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Popup message boxes
« Reply #1 on: June 30, 2012, 05:36:22 PM »
Just make the background collider really big to start with. Something like 3000x2000 should cover everything.

jdwieber

  • Guest
Re: Popup message boxes
« Reply #2 on: July 02, 2012, 11:02:39 AM »
That will work for this particular instance since I want the popup to behave as a modal dialog.  However, for other applications where I want the button to have a relative scale this solution would make for an unnatural UI experience.  Fortunately for me, with NGUI it is very easy to move things around.  I was just wondering if there is a preferred way. Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Popup message boxes
« Reply #3 on: July 02, 2012, 12:47:46 PM »
For Windward I have a "dimmer" object that covers the entire screen (and also dims it). When I show a popup, if I want it to be modal, I also show the dimmer. This also means the giant collider is not a part of the dialog box, but a different UI component, which lets me use it with certain other windows as well (for example when the talent window shows up).