Author Topic: Define minimum value for UIScrollBar.cs  (Read 2100 times)

Oinobareion

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Define minimum value for UIScrollBar.cs
« 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.

Oinobareion

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: Define minimum value for UIScrollBar.cs
« Reply #1 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? 

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Define minimum value for UIScrollBar.cs
« Reply #2 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...