FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
UnityEventBus/Scripts/GenericListener.cs at master · codingwatching/UnityEventBus · GitHub
codingwatching
/
UnityEventBus
Public
forked from
NullTale/UnityEventBus
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
UnityEventBus
/
Scripts
/
GenericListener.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
52 lines (44 loc) · 1.3 KB
Breadcrumbs
UnityEventBus
/
Scripts
/
GenericListener.cs
Copy path
File metadata and controls
52 lines (44 loc) · 1.3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using
System
;
using
System
.
Collections
.
Generic
;
namespace
UnityEventBus
{
public
sealed
class
GenericListener
<
T
>
:
IListener
<
T
>
,
ISubscriberOptions
,
IDisposable
{
private
string
m_Name
;
private
int
m_Order
;
public
string
Name
=>
m_Name
;
public
int
Priority
=>
m_Order
;
private
List
<
IEventBus
>
m_Subscriptions
=
new
List
<
IEventBus
>
(
1
)
;
private
Action
<
T
>
m_Reaction
;
// =======================================================================
public
GenericListener
(
Action
<
T
>
reaction
,
int
order
,
string
name
)
{
m_Reaction
=
reaction
;
m_Order
=
order
;
m_Name
=
name
;
}
public
void
Subscribe
(
IEventBus
bus
)
{
if
(
m_Subscriptions
.
Contains
(
bus
)
)
return
;
m_Subscriptions
.
Add
(
bus
)
;
bus
.
Subscribe
(
this
)
;
}
public
void
UnSubscribe
(
IEventBus
bus
)
{
if
(
m_Subscriptions
.
Remove
(
bus
)
)
bus
.
UnSubscribe
(
this
)
;
}
public
void
Dispose
(
)
{
foreach
(
var
bus
in
m_Subscriptions
)
{
bus
.
UnSubscribe
(
this
)
;
}
}
public
void
React
(
in
T
e
)
{
m_Reaction
(
e
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL