Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: soofaloofa on November 23, 2013, 11:05:59 PM

Title: Bug: UISlider does not move thumb when foreground is FilledSprite - NGUI 3.0.6
Post by: soofaloofa on November 23, 2013, 11:05:59 PM
Hi,

I upgraded my NGUI 2.7 project to NGUI 3.0.6 and my Slider is no longer working. Specifically the thumb is no longer being moved when the UISprite on the slider foreground is a FilledSprite.

Kevin
Title: Re: Bug: UISlider does not move thumb when foreground is FilledSprite - NGUI 3.0.6
Post by: ArenMook on November 24, 2013, 01:33:09 AM
Thanks, I've fixed it locally. You can fix it by replacing UISlider.ForceUpdate function with this one:
  1.         public override void ForceUpdate ()
  2.         {
  3.                 base.ForceUpdate();
  4.  
  5.                 if (mFG != null && thumb != null)
  6.                 {
  7.                         Vector3[] corners = mFG.worldCorners;
  8.  
  9.                         if (isHorizontal)
  10.                         {
  11.                                 if (mSprite != null && mSprite.type == UISprite.Type.Filled)
  12.                                 {
  13.                                         Vector3 v0 = Vector3.Lerp(corners[0], corners[1], 0.5f);
  14.                                         Vector3 v1 = Vector3.Lerp(corners[2], corners[3], 0.5f);
  15.                                         thumb.position = Vector3.Lerp(v0, v1, isInverted ? 1f - value : value);
  16.                                 }
  17.                                 else
  18.                                 {
  19.                                         thumb.position = isInverted ?
  20.                                                 Vector3.Lerp(corners[0], corners[1], 0.5f) :
  21.                                                 Vector3.Lerp(corners[2], corners[3], 0.5f);
  22.                                 }
  23.                         }
  24.                         else
  25.                         {
  26.                                 if (mSprite != null && mSprite.type == UISprite.Type.Filled)
  27.                                 {
  28.                                         Vector3 v0 = Vector3.Lerp(corners[0], corners[3], 0.5f);
  29.                                         Vector3 v1 = Vector3.Lerp(corners[1], corners[2], 0.5f);
  30.                                         thumb.position = Vector3.Lerp(v0, v1, isInverted ? 1f - value : value);
  31.                                 }
  32.                                 else
  33.                                 {
  34.                                         thumb.position = isInverted ?
  35.                                                 Vector3.Lerp(corners[0], corners[3], 0.5f) :
  36.                                                 Vector3.Lerp(corners[1], corners[2], 0.5f);
  37.                                 }
  38.                         }
  39.                 }
  40.         }
Title: Re: Bug: UISlider does not move thumb when foreground is FilledSprite - NGUI 3.0.6
Post by: jeldrez on November 25, 2013, 03:22:38 PM
I'm having this issue:

  1. Assets/MNT/Scripts/Characters/Cooldown.cs(57,53): error CS0122: `UISlider.foreground' is inaccessible due to its protection level

when trying to get the UISlider foreground:

  1. public UISlider sliderAsset;
  2.  
  3. public void SomeFunction()
  4. {
  5.    UISprite slider = sliderAsset.foreground.gameObject.GetComponent<UISprite>();
  6. }
Title: Re: Bug: UISlider does not move thumb when foreground is FilledSprite - NGUI 3.0.6
Post by: ArenMook on November 25, 2013, 06:25:38 PM
Change it to 'foregroundWidget'. I left a note about it on the now-hidden property.
Title: Re: Bug: UISlider does not move thumb when foreground is FilledSprite - NGUI 3.0.6
Post by: jeldrez on November 25, 2013, 07:18:34 PM
Ok.
Thanks Aren.