Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Oinobareion on November 08, 2013, 08:55:21 AM

Title: Define minimum value for UIScrollBar.cs
Post by: Oinobareion on November 08, 2013, 08:55:21 AM
Hi,

I am using a UIScrollBar for a list I am displaying. The problem is: when the list gets very long, the foreground element of the scrollbar gets very small. How can I define a minimum value for the foreground element size so that it does not fall below a certain value?

Thanky for your help.
Title: Re: Define minimum value for UIScrollBar.cs
Post by: Oinobareion on November 08, 2013, 10:38:53 AM
For example, if I want to prevent the foreground element of my scrollbar from getting smaller than 100px. I (experimentally) changed line 349 of UIScrollBar.cs to the following:

  1. if (mFG.cachedTransform.localScale.x > 100)
  2. {
  3.         // this is the original line   
  4.         mFG.cachedTransform.localScale = new Vector3(fgs.x + fg.x + fg.z, fgs.y + fg.y + fg.w, 1f);
  5. }
  6.         else mFG.cachedTransform.localScale = new Vector3(100, fgs.y + fg.y + fg.w, 1f);
  7.  
  8.  

But this leads to some flickering of the foreground sprite, swithcing between my defined size and the calculated ngui size. How can I fix that? 
Title: Re: Define minimum value for UIScrollBar.cs
Post by: ArenMook on November 08, 2013, 10:47:42 AM
The fact that you are using localScale tells me that you are not using the latest version of NGUI. There is a sticky about that...