Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: karsnen on October 19, 2013, 05:33:41 PM

Title: UISlider callback and how to change the value externally?
Post by: karsnen on October 19, 2013, 05:33:41 PM
Hello,

I have a UISlider and I want to register a callback for OnValue change.
I tried it, but I am stuck and I think it is just a small issue.
I also want to change the Slider value too.

My Methodology:

I have a public UISlider variable which I used to drag and drop the GameObject on top it.

  1.         public UISlider MySlider;

Then in OnEnable()

  1. MySlider.onChange +=OnSliderValueChange;

I am trying to register a callback. My callback method is like this.

  1.         public void OnSliderValueChange(float val)
  2.         {
  3.                 Debug.Log("Sound Value = " + val);     
  4.         }

I think it is a syntax error.

As it say this
Quote
Operator `+=' cannot be applied to operands of type `System.Collections.Generic.List<EventDelegate>' and `method group'

How can I register a callback?

My Secondary Question:
As now I have cached the UISlider - how can I change the value on the slider from an external script.


Thank you very much!!!


EDIT :

Even when I try this - http://s11.postimg.org/yl2ljcpyr/Screen_Shot_2013_10_19_at_7_05_35_PM.png (http://s11.postimg.org/yl2ljcpyr/Screen_Shot_2013_10_19_at_7_05_35_PM.png)

I do not have any public methods shown up on the drag list. The gameobject which is attached to "Notify" monobehaviour has more than 1 script attached.
Title: Re: UISlider callback and how to change the value externally?
Post by: ArenMook on October 19, 2013, 08:32:27 PM
http://www.tasharen.com/forum/index.php?topic=11.msg27296#msg27296

There is an explicit example of how to do it with a slider...