Author Topic: popup window problem  (Read 3795 times)

xikky

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 46
    • View Profile
popup window problem
« on: March 23, 2013, 12:19:10 PM »
I am creating my GUI which includes a number of main panels. These are all under one centered anchor. When I press a left or right button, one panel disappears and another appears using UIButtonPlayAnimation. I need to display a popup window (another panel, for reference i'll call it sub panel) to show error messages when the user does something wrong . I'm having trouble though.

1. I cannot find how to disable the main panel's widgets when the sub panel appears without having to check through all panel widgets and disabling them one by one. Is there some other smarter way for this?

2. I cannot find how to cleanly control the sub panel to show or hide. What I did to display the sub panels when the game starts and on start I save an instance of each and hide them again. When I need to pop up a window, I'll check which one I need from the sub panels and display it using NGUITools.SetActive(popupWindow.gameObject, true);

I feel like I'm missing something which I'm not using.  Is there any way better to handle these issues?

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: popup window problem
« Reply #1 on: March 23, 2013, 08:30:21 PM »
This is really more of a structural problem than an NGUI problem. There's no magic bullet, I'm afraid.

If you setup your hierarchy such that you have an easy parent to disable, then it would be easier than to have to run through each individual widget -- you really don't want to be doing that.

Consider a setup like this

*mypanel
**content1
***widget
***widget
***widget
***widget
**content2
***widget
***widget
***widget

If content 1 has to stay on, while content 2 widgets have to turn off, it's easy to keep references to the parents and just SetActive on the correct ones.

I hope that helps.

xikky

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 46
    • View Profile
Re: popup window problem
« Reply #2 on: March 24, 2013, 03:39:14 AM »
Thank you for your help. The problem is that SetActive to false will not only disable the other panel, but also hide it. Is there any other way to just disable widgets on the panel behind?

xikky

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 46
    • View Profile
Re: popup window problem
« Reply #3 on: March 24, 2013, 06:19:31 AM »
Is there a way to disable (gray out) all widgets on a panel?

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: popup window problem
« Reply #4 on: March 24, 2013, 12:42:20 PM »
So wait, you don't want to actually disable (deactivate) the widgets, you just want them to gray out?

Ah, well that's an entirely different problem.

Make your popup in a different layer than the others (it's own panel, move it a bit closer to the camera on Z axis or depth depending on how many atlases you are working with).

Make a dark background (full screen black with alpha ~50%) that you put in between your popup and the other stuff on the screen.

Put a touch catcher (collider) on the dark background so you can't click stuff in the background.

You'll end up with something like this:

-- normal widgets --
-- dark background --
-- popup --

ordered after closeness to the camera.

Does that make sense?

broken

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 140
    • View Profile
Re: popup window problem
« Reply #5 on: March 25, 2013, 12:16:37 AM »
Hi!

If we have:

* ...
** Some Panel
*** Clipped Panel
**** Content

and want to make a TweenAlpha for the main panel (Some Panel) means it is necessary to use the TweenAlpha of each child panel?

for example:

  1. TweenAlpha.Begin(clippedPanel, ...);
  2. TweenAlpha.Begin(somePanel, ...);

or

  1. UIPanel[] panels = somePanel.GetComponentsInChildren<UIPanel>();
  2. foreach (UIPanel p in panels)
  3. {
  4.         TweenAlpha.Begin(p.gameObject, 1f, 0f);
  5. }
  6.  

Thanks!
« Last Edit: March 25, 2013, 12:28:49 AM by broken »

xikky

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 46
    • View Profile
Re: popup window problem
« Reply #6 on: March 25, 2013, 02:18:29 AM »
Thanks a lot for the help! I will try these as soon as I can. But for now I have to continue with my studies :/

xikky

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 46
    • View Profile
Re: popup window problem
« Reply #7 on: March 25, 2013, 04:42:06 AM »
haha couldn't help not trying this morning! I tried your way Nicki and it's exactly how I want it to be. The only difference is that the popup window should still be kept in the same layer :) Thank you!