Welcome,
Guest
. Please
login
or
register
.
June 12, 2026, 09:50:09 AM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
How do you correctly remove an event receiver?
« previous
next »
Print
Pages: [
1
]
Author
Topic: How do you correctly remove an event receiver? (Read 3184 times)
Disastercake
Jr. Member
Thank You
-Given: 0
-Receive: 1
Posts: 87
www.disastercake.com
How do you correctly remove an event receiver?
«
on:
September 12, 2012, 12:12:38 AM »
I am using the code:
MyTweenColor
.
eventReceiver
=
null
;
MyTweenColor
.
callWhenFinished
=
""
;
To make it so that if this tween happens again, it does not send out a message again. However, this is not working properly and it still calls the same object and function even though it shows in the inspector that they are not set. What is the proper way to remove these receivers? Also, what is the proper way to replace them with a new one via script?
Logged
Creator of Soul Saga.
http://www.disastercake.com
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: How do you correctly remove an event receiver?
«
Reply #1 on:
September 12, 2012, 12:25:58 AM »
Code straight from UITweener:
// Notify the event listener target
if
(
eventReceiver
!=
null
&&
!
string
.
IsNullOrEmpty
(
callWhenFinished
)
)
{
eventReceiver
.
SendMessage
(
callWhenFinished,
this
, SendMessageOptions
.
DontRequireReceiver
)
;
}
So if either is null, nothing will happen. Are you sure it's coming from this place and not the event delegate you set elsewhere?
Logged
Disastercake
Jr. Member
Thank You
-Given: 0
-Receive: 1
Posts: 87
www.disastercake.com
Re: How do you correctly remove an event receiver?
«
Reply #2 on:
September 12, 2012, 12:49:56 AM »
I double checked and it looks like I had both objects that were fading in call the same function when they were done. So I was only disabling one. I've fixed it by only having one of the objects make the call. Thanks for helping me ArenMook!
Logged
Creator of Soul Saga.
http://www.disastercake.com
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
How do you correctly remove an event receiver?