I have a gameobject with an toggle which I want to execute a function on change:
levelItem.GetComponent<Toggle>().onValueChanged.AddListener(SetSelectedLevel(levelList*.Number));*
public void SetSelectedLevel(int index) {
-
selectedLevel = index;*
- }*
thelevelList*.Number
is just an int.*
I am getting this error on theonValueChange
:
> error CS1502: The best overloaded
> method match for
>UnityEngine.Events.UnityEvent.AddListener(UnityEngine.Events.UnityAction)'*_ _*> has some invalid arguments*_ _*aswell as this:*_ _*> error CS1503: Argument
#1’ cannot
> convertvoid' expression to type*_ _*>
UnityEngine.Events.UnityAction’