Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Robota on October 17, 2014, 05:11:44 AM

Title: Scroll bar appears white
Post by: Robota on October 17, 2014, 05:11:44 AM
Hi,
I working with scroll view and scroll bar.
Everything works great except the color of my scroll bar.

I start with a empty scroll view. Then I add some elements with the code:

  1.         public GameObject cell;
  2.         private UIScrollView _scrollView;
  3.         private UIGrid _grid;
  4.  
  5.         public void AddCell()
  6.         {
  7.                 NGUITools.AddChild(_grid.gameObject, cell);
  8.                 _grid.Reposition();
  9.                 _scrollView.ResetPosition();
  10.         }
   
When the scroll bar appears it is white and it is not supposed to be white. If I click on it it becomes to correct color.

I can't figure why.
Any idea?
Title: Re: Scroll bar appears white
Post by: ArenMook on October 17, 2014, 05:23:18 AM
Well, what changes its color to white then? NGUI won't just change colors for you. Check what else you have attached to it, like a button component.
Title: Re: Scroll bar appears white
Post by: Robota on October 17, 2014, 06:33:29 AM
Ok, I removed, the buttons component on both part of may scroll bar (foreground and background).
In fact they where useless because I didn't wanted colors effects, so all colors where the same...

But the glitch effect remained and I think i understand why.
My foreground got the color 255 255 255 77. So it was transparent. When you hide the bar you set to the color an alpha value of zero, but when you show it the alpha is set to 255.
So the transparency value is lost and the color was pure white.

But maybe I missed something to bypass this ?
Title: Re: Scroll bar appears white
Post by: ArenMook on October 18, 2014, 08:28:19 AM
Sounds right. Remember, alpha is cumulative, so you can always have something like this:

UIWidget (alpha 255)
- Sprite (alpha 70)
Title: Re: Scroll bar appears white
Post by: Robota on October 19, 2014, 08:51:22 AM
Of course, it makes sense!
Thank you.