Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: pretender on January 29, 2015, 04:37:58 AM
Title:
UIEventListener subscribe/unsubscribe
Post by:
pretender
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!
Title:
Re: UIEventListener subscribe/unsubscribe
Post by:
ArenMook
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 -=.