Author Topic: UISlider OnValueChange Call Multiple Methods  (Read 4859 times)

freesmith

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
UISlider OnValueChange Call Multiple Methods
« on: March 12, 2014, 11:36:42 AM »
Hi all,
I'm using unity 4.3.2f1 and NGUI  Version 3.0.9 f5

And I have a problem with OnValueChange notify feature in UISlider.
on ui slider value changed ,I want to notify more than one object, and call some of its methods.
only the first referenced object (in the notify slot) and method works, i can add manually more objects and methods, but they dont get called.(or notified)
i tried with this code, to call 2 methods from the same class , and one from different one...
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Test : MonoBehaviour
  5. {
  6.         public Game gamescript;
  7.         public UILabel label;
  8.         void Awake()
  9.         {
  10.                 UIProgressBar pg = GetComponent<UIProgressBar>();
  11.                 EventDelegate.Add(pg.onChange, MyFunc);//1
  12.                 EventDelegate.Add(pg.onChange, gamescript.MyFunc);//trying to call method from other class//2
  13.                 EventDelegate.Add(pg.onChange, Func);//3
  14.         }
  15.         void MyFunc ()
  16.         {
  17.                 float NegativeOneToOne = UIProgressBar.current.value * 100.0F - 50.0F; // make 0 to 1 slider value mapped to -1 to 1
  18.                 label.text = NegativeOneToOne.ToString("F");
  19.         }
  20.         void Func()
  21.         {
  22.                 Debug.Log ("Called");
  23.         }
  24. }
And again, whatever the method, the first one on the list is called ,the others not.
Anyone any ideas how to solve this?
Thank you

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISlider OnValueChange Call Multiple Methods
« Reply #1 on: March 12, 2014, 06:49:58 PM »
Please update to the latest version before posting about issues. It's likely been fixed long ago as 3.0.9 is many months out of date.

freesmith

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UISlider OnValueChange Call Multiple Methods
« Reply #2 on: March 13, 2014, 10:55:27 AM »
I updated to the latest version and the feature works as it should. Thanks for update and reply!