Hi
I know how to add an event to a button and it's work :
go = Instantiate (prefabBtn, Vector3(0, 0, 0), Quaternion.identity);
UIEventListener.Get(go).onClick = function(){ Debug.Log('click'); };
But I need to create buttons in a loop and add parameter to my function
for(var i = 0; i < 10; i++){
go = Instantiate (prefabBtn, Vector3(i*100, 0, 0), Quaternion.identity);
UIEventListener.Get(go).onClick = function(){ Debug.Log('click '+i); };
}
But with this code, all buttons display "Click 10" and not "Click 1" for the first, "Click 2" for the second.
I think I have scope issue but I don't find a workaround.
Thanks for your help.