Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: Arun 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 .
portPrefab
= Instantiate
(portDashboard,
new Vector3
(0,
0,
0), Quaternion
.identity) as GameObject
;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 .
-
Read this sticky post: http://www.tasharen.com/forum/index.php?topic=11208.0