Author Topic: UIPlayTween with TweenAlpha  (Read 2029 times)

tibithegreat

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
UIPlayTween with TweenAlpha
« on: July 14, 2014, 04:20:12 AM »
Hello,

I think there is a small issue when using UIPlayTween in combination with TweenAlpha. I have a sprite with a TweenAlpha on it which goes from 0 to 1, and I put a UIPlayTween on it which toggles the TweenAlpha and is triggered on click. The problem is that when the sprite is invisible the click trigger is no longer registered, thus the Tween doesn't play anymore, remaining completed faded out.

I checked the collider and it's just the same (at first I thought the collider got resized to match the sprite which being invisible resulted in 0 size collider but that is not the case).

I also wanted to see if there wasn't any issue with the way I set up the playtween and I put "Debug.Log('object clicked')" on the first line of the OnClick method in UIPlayTween, to see if the PlayTween gets the event but somehow doesn't trigger the TweenAlpha. However the OnClick method is not called at all when the sprite has alpha = 0.

TL;DR UIPlayTween OnClick doesn't trigger if the sprite is invisible.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPlayTween with TweenAlpha
« Reply #1 on: July 15, 2014, 12:15:37 AM »
When the sprite's alpha is 0, its collider is effectively invisible. This is done so that you can fade out your UI and not worry about having to go through all the colliders and deactivating them manually.

If you want an invisible area that still reacts to events, create a plain widget instead. (ALT+SHIFT+W). Also remember that alpha is cumulative. You can do something like this:

UIWidget (collider, UIPlayTween)
- UISprite (tweened to alpha of 0)