Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - thibaud

Pages: [1]
1
NGUI 3 Support / Re: UIEventListener - Dynamic function
« on: August 12, 2014, 07:56:46 AM »
Ok for 1.

For 2., I try that without success :

  1. UIEventListener.Get(go).onClick = function(i : int){ Debug.Log('click '+i); };

2
NGUI 3 Support / UIEventListener - Dynamic function
« on: August 12, 2014, 01:20:36 AM »
Hi

I know how to add an event to a button and it's work :

  1. go = Instantiate (prefabBtn, Vector3(0, 0, 0), Quaternion.identity);
  2. UIEventListener.Get(go).onClick = function(){ Debug.Log('click'); };
  3.  

But I need to create buttons in a loop and add parameter to my function

  1. for(var i = 0; i < 10; i++){
  2. go = Instantiate (prefabBtn, Vector3(i*100, 0, 0), Quaternion.identity);
  3. UIEventListener.Get(go).onClick = function(){ Debug.Log('click '+i); };
  4. }
  5.  

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.

Pages: [1]