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 - Arun

Pages: [1]
1
NGUI 3 Support / Add EventDelegate on UIButton script Runtime .
« on: November 05, 2014, 12:00:46 AM »
Hi guys ,

 I am trying to add EventDelegate (OnClick) on UIButton script Runtime .This Script is attached to a Button prefab .I am trying to add CloseButton() Method of same mono behaviour from where i am creating this prefab. Cross Button is a child of portPrefab .
  1. portPrefab = Instantiate (portDashboard, new Vector3 (0, 0, 0), Quaternion.identity) as GameObject;
  2. GameObject.Find ("Cross Button").GetComponent<UIButton> ().onClick.Add (new  EventDelegate (this, "CloseButton"));

I can't see it added in inspector .

Update :
I can also see delegate is added in the list(onClick) , but it's not executing .Is it even feasible to add EventDelegate at runtime and expect them to run properly . When i try to add them via Inspector in prefab . It removes itself when prefab is instantiated at runtime .

Pages: [1]