Author Topic: Fading in UIGrid items?  (Read 2730 times)

catlard

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 24
    • View Profile
Fading in UIGrid items?
« 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

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fading in UIGrid items?
« Reply #1 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);

catlard

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 24
    • View Profile
Re: Fading in UIGrid items?
« Reply #2 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!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fading in UIGrid items?
« Reply #3 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.

catlard

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 24
    • View Profile
Re: Fading in UIGrid items?
« Reply #4 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