Author Topic: Fading out a scene with UILabels  (Read 4576 times)

Gmotagi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Fading out a scene with UILabels
« 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

3DMagicVR

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
  • Think, Analysis, and then do it, can you do it?
    • View Profile
Re: Fading out a scene with UILabels
« Reply #1 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)
3D Magic VR - Living in a digital world -
3D Modeler, Digital Animator and 2D Designer.

stephan7

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: Fading out a scene with UILabels
« Reply #2 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

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fading out a scene with UILabels
« Reply #3 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.