Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Gmotagi on October 08, 2013, 02:25:46 PM

Title: Fading out a scene with UILabels
Post by: Gmotagi on October 08, 2013, 02:25:46 PM
Hi,

I want to fade out a scene with some UILabels and UISprites on.  I've been playing around with various ways of doing this but am unable to ever make the UILabels disappear.

The way that I thought would be easiest would be to just decrease the intensity of a light but the labels seem unaffected by this and always stay the same colour even when the UISprite background goes to black. 

Is there a way to make them be affected by a light?

Another way I tried was creating a black quad that I was going to alpha fade.  However this always draws in front of the UISprite but never in front of the labels even when its phyically behind them in the scene.

Thanks
Is there a way of making this go infront of the labels
Title: Re: Fading out a scene with UILabels
Post by: 3DMagicVR on October 08, 2013, 02:55:09 PM
Hello there, the way to fade the UILabels it's very simple:

UILabel label;
label.color = new Color(R,G,B,A);


The only thing you must do it's animate the Alpha Value from the Color and the UILabel will fade out.

Very simple in deed. ;)

If you are working with PlayMaker don't forget to download the NGUI-PlayMaker Actions. 8)
Title: Re: Fading out a scene with UILabels
Post by: stephan7 on October 08, 2013, 03:04:46 PM
Another possibility would be the use of OnGUI.

There you could use an animated alpha value and draw e.g. a simple black texture. Would work for the whole scene not only for NGUI elements.


    GUI.color = new Color(Color.black.r, Color.black.g, Color.black.b, Mathf.Lerp(1.0f, 0.0f, alpha));
    GUI.DrawTexture(new Rect(0f, 0f, Screen.width, Screen.height), theTexture);


Stephan
Title: Re: Fading out a scene with UILabels
Post by: ArenMook on October 09, 2013, 08:49:25 AM
To change the alpha of a widget, use its "alpha" property. No need to touch its color.

To fade out a widget, just use TweenAlpha.Begin(...) on it.

To fade out a group of widgets, fade out the panel that's drawing them either by modifying its "alpha" property, or again by using TweenAlpha.Begin(...) on the panel's game object.