Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: pankus61 on March 16, 2014, 09:26:09 PM

Title: UIslider EventDelegate.Add Error..
Post by: pankus61 on March 16, 2014, 09:26:09 PM
Hello i want make UISlider volume changing but two error;
My script;

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class VolumeOption : MonoBehaviour {
  5.        
  6.  
  7.         void Start ()
  8.         {
  9.                 UISlider _Volumeslider = GetComponent<UISlider>();
  10.                 _Volumeslider.sliderValue = AudioListener.volume;
  11.                 EventDelegate.Add(_Volumeslider.onChange,OnToggleChange);
  12.  
  13.         }
  14.        
  15.         void OnToggleChange (float val)
  16.         {
  17.                 AudioListener.volume = val;
  18.         }
  19. }

ERRORS;

  1. Assets/ScriptOther/VolumeOption.cs(11,31): error CS1502: The best overloaded method match for `EventDelegate.Add(System.Collections.Generic.List<EventDelegate>, EventDelegate)' has some invalid arguments

  1. Assets/ScriptOther/VolumeOption.cs(11,31): error CS1503: Argument `#2' cannot convert `method group' expression to type `EventDelegate'

How to fix? Thanks in advance. :)

(Sorry for bad english.)
Title: Re: UIslider EventDelegate.Add Error..
Post by: ArenMook on March 17, 2014, 01:38:03 AM
Remove "float val".

The callback doesn't have any parameters. Change it to:
  1. void OnTogleChange () { AudioListener.volume = UISlider.current.value; }