Author Topic: Bug: UISlider does not move thumb when foreground is FilledSprite - NGUI 3.0.6  (Read 4055 times)

soofaloofa

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 27
    • View Profile
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

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
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.         }

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
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. }

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Change it to 'foregroundWidget'. I left a note about it on the now-hidden property.

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Ok.
Thanks Aren.