Welcome,
Guest
. Please
login
or
register
.
September 24, 2023, 11:32:32 PM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
UIEventListener subscribe/unsubscribe
« previous
next »
Print
Pages: [
1
]
Author
Topic: UIEventListener subscribe/unsubscribe (Read 1311 times)
pretender
Full Member
Thank You
-Given: 1
-Receive: 0
Posts: 155
UIEventListener subscribe/unsubscribe
«
on:
January 29, 2015, 04:37:58 AM »
I was wondering if it is needed to unsubscribe onClick event for example that is subscribe to with UIEventListener?
here is what i am doing
UIEventListener
.
Get
(
Button
)
.
onClick
+=
go
=>
{
Debug
.
Log
(
go
.
name
)
;
}
;
...
UIEventListener
.
Get
(
Button
)
.
onClick
-=
go
=>
{
Debug
.
Log
(
go
.
name
)
;
}
;
Unsubscribe part gives me warning in Visual Studio...what is the proper way of doing this? Thanks!
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: UIEventListener subscribe/unsubscribe
«
Reply #1 on:
January 29, 2015, 01:12:41 PM »
You can't do that with => I'm pretty sure, as this creates a new inlined function in that part of the code. They're effectively different functions.
The only way to -= is to have a proper non-anonymous function reference for both += and -=.
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
UIEventListener subscribe/unsubscribe