Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: Balours on November 28, 2013, 10:14:44 AM
Title:
Prebaf button losing target.
Post by:
Balours
on
November 28, 2013, 10:14:44 AM
Hi,
Thanks for this plugin !
I'm stuck on creating button prefab at runtime, the notified gameObjet is outside the prefab so the link is removed by unity.
How can I add the notify and the function to call at runtime, just after creating the button ?
Thanks !
Balours :)
Title:
Re: Prebaf button losing target.
Post by:
npritchard
on
November 28, 2013, 10:22:58 AM
Hook into the onClick event...
void
CreateButton
(
)
{
UIButton createdBtn
=
;
// code to create and get the UIButton component
EventDelegate
.
Add
(
createdBtn
.
onClick
, OnCreatedButtonClick
)
;
}
void
OnCreatedButtonClick
(
)
{
Debug
.
Log
(
"Button Pressed"
)
;
}
Don't forget to EventDelegate.Remove(...) when appropriate.
HTH
Title:
Re: Prebaf button losing target.
Post by:
Balours
on
November 28, 2013, 10:28:30 AM
Thank you, worked perfectly.
I had no idea of how EventDelegate worked. Now I got it.