Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: catlard on December 15, 2013, 09:44:13 PM

Title: Fading in UIGrid items?
Post by: catlard on December 15, 2013, 09:44:13 PM
Hi there!

So, I'm working on a project that requires I add items to a UIGrid during runtime. I'm doing this by fading the alpha of the UISprites and UILabels using iTween. However, I'm running into a problem -- if I instantiate the object and then try to fade it up starting in the same frame, the UISprite seems to believe that its default color's alpha value is 0, and I can't seem to reset it in any way. So that means when I stop hovering over the object for the first time, the object fades to invisible -- its default. If I instantiate the object and then yield a frame and THEN start changing the alpha, it looks ugly, no matter what I do.

Is there a preferred method for fading in UISprites or UIGrid items? What is it?

S
Title: Re: Fading in UIGrid items?
Post by: ArenMook on December 16, 2013, 08:57:49 AM
Quote
I'm doing this by fading the alpha of the UISprites and UILabels using iTween.
This raises red flags to me. What are you tweening, private member variables such as "MColor"? NGUI has tweeners that use properties correctly such as TweenAlpha. To fade in a sprite:
  1. sprite.alpha = 0f;
  2. TweenAlpha.Begin(sprite.gameObject, duration, 1f);
Title: Re: Fading in UIGrid items?
Post by: catlard on December 22, 2013, 09:21:30 PM
Thanks, Aren.

I guess the reason I was using iTween is because TweenAlpha, and TweenScale and such didn't have an obvious place to input different easing types -- which I wanted.

I'm not sure what the problem was before, but I've tried again to use alpha, and this time I got it working. Doy. Thanks!
Title: Re: Fading in UIGrid items?
Post by: ArenMook on December 23, 2013, 02:02:54 PM
To change the easing types, adjust the curve. You can do anything you want with the curve, including bounce effects, if you're so inclined.
Title: Re: Fading in UIGrid items?
Post by: catlard on May 07, 2014, 02:13:18 AM
Thanks! I got it a while ago. I wasn't aware that I could use Tween____.Begin on things.

Thanks!

Simon