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