Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: enhilljr on September 29, 2015, 05:26:13 PM

Title: Scroll Bar frequently disappears during color tween
Post by: enhilljr on September 29, 2015, 05:26:13 PM
I have a ScrollView with a vertical Scroll Bar.  The scrollbar background object (to which the UIScrollBar script is attached) has a BoxCollider and a UIButton with NO Tween Target and Transition=0.  The scrollbar foreground object is a child of the background object and very similar to it with a BoxCollider and a UIButton with NO Tween Target and Transition=0 and a green square set in the UISprite.

At runtime, when I move the mouse left and right over the foreground button it fades in an out as I move over it.  If I do this enough, it's not hard to make the button disappear altogether and it will not reappear.

What I discovered by running in the editor is that at runtime TweenColor scripts are being added to the foreground and background objects even though Tween Target is set to None and Transition=0 for both.  I also noticed that when the button disappears, the Color Tint of the UISprite of the background object has an Alpha value of 0.  The value of TweenColor.To.alpha=0 for both background and foreground objects.  If I reset the Alpha of Color Tint of the background object to 255, the foreground button reappears until the next time I move over it enough to make the problem reoccur.

So I have 2 questions:
1. Why is the Alpha of the To color of this magically appearing TweenColor being changed to 0 at runtime (when created, it's 255)?
2. How can I prevent these TweenColor scripts from being added to my scrollbar objects since I don't want any tweening?

Thanks for any guidance for this NGUI nubie.
Title: Re: Scroll Bar frequently disappears during color tween
Post by: ArenMook on October 01, 2015, 01:59:20 AM
When you specify that the scroll bar should fade out when it's not needed (it's a choice on UIScrollView), it will do just that -- fade it out using TweenAlpha. UIButtonColor/UIButton scripts also use tweens (TweenColor), which changes alpha as well. The "from" color is chosen when the tween is added, and if the alpha happens to be 0 at the time, that's going to be your "from" value on the tween.

As for target being "none"... when you don't specify a target, it finds one. Assuming you don't want this behaviour, comment out line 117 of UIButtonColor.cs.
  1. //if (tweenTarget == null) tweenTarget = gameObject;