Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: legend411 on May 08, 2012, 07:45:23 AM

Title: Best way to fade in/out a UIPanel and all its children?
Post by: legend411 on May 08, 2012, 07:45:23 AM
I tried using a tween color component on the parent UIPanel and activating it with a UIButtonTween in another panel, but I get really odd results.

Also, is NGUITools.SetActive() in the latest version of the free package? I've been trying to do it by hand as an alternative, looping through all the GetComponentsInChildren.<UIWidget>() of the panel and lerping their color.a, but I'm getting weird results with SetActiveRecursively(), and its telling me NUGITools.SetActive() doesn't exist. I just downloaded the package over the weekend?
Title: Re: Best way to fade in/out a UIPanel and all its children?
Post by: matix on May 08, 2012, 07:56:11 AM
  1. private static void SetNguiVisible(GameObject gameObject, bool visible)
  2.         {
  3.                 foreach(var widget in gameObject.GetComponents<UIWidget>())
  4.                 {
  5.                         widget.enabled = visible;
  6.                 }
  7.         }
Title: Re: Best way to fade in/out a UIPanel and all its children?
Post by: legend411 on May 08, 2012, 08:09:37 AM
I don't just want to set it invisible, I want to fade the alpha from 255-0 over time, then disable it entirely so it can't be interacted with.
Title: Re: Best way to fade in/out a UIPanel and all its children?
Post by: matix on May 08, 2012, 08:40:19 AM
do u tryed?
  1. widget.alpha = Mathf.Lerp(0,255,Time.deltaTime);
  2. widget.color = new Color(0,0,0,  Mathf.Lerp(0,255,Time.deltaTime));
Title: Re: Best way to fade in/out a UIPanel and all its children?
Post by: cayou on May 08, 2012, 09:46:21 AM
You can also use iTween or HOTween to perform this in one line.
Title: Re: Best way to fade in/out a UIPanel and all its children?
Post by: legend411 on May 08, 2012, 10:14:44 AM
As I mentioned in the OP, it works fine when I do it manually... but I need to disable/enable the panel and all its children whenever it fades out/in, and SetActiveRecursively() is giving me weird issues or not working at all, and apparently NGUITools.SetActive() doesn't exist in the free version, unless I'm missing something.

Either way, if doing it by hand works, it'd be nice if you could make the TweenColor work, too (on the panel and all child widgets); not sure why it doesn't. I really like how intuitive using the built-in tweens is.
Title: Re: Best way to fade in/out a UIPanel and all its children?
Post by: ArenMook on May 08, 2012, 11:42:34 AM
TweenColor works on individual components -- a single widget, light, or renderer. A panel has many widgets, and as such -- many colors. Keep in mind the free version of NGUI comes as-is, it's not supported due to it being so far behind the current version.