You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 10, 2021. It is now read-only.
Copy file name to clipboardExpand all lines: Documentation/README.md
+6-8Lines changed: 6 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,12 +3,10 @@
3
3
## Game Events
4
4
The library provides two types of game events:
5
5
-`GameEvent` without arguments.
6
-
-`ArgumentGameEvent` which accept arguments.
6
+
-`ArgumentGameEvent` which accepts arguments.
7
7
8
8
### Game event assets
9
-
The core of events is game event `ScriptableObject` assets. They store game event listeners and notify them when an event is raised.
10
-
11
-
To use game events, create an appropriate game event type asset (where _"Argument Name"_ is type of the argument that you are going to be passing to your events):
9
+
The core of events is game event `ScriptableObject` assets. They store game event listeners and notify them when an event is raised. To use game events, create an appropriate game event type asset (where _"Argument Name"_ is type of the argument that you are going to be passing to your events):
12
10
-`GameEvent` - _Right Click -> Create -> Game Events -> Game Event_
13
11
-`ArgumentGameEvent` - _Right Click -> Create -> Game Events -> "Argument Name" Game Event_
14
12
@@ -45,7 +43,7 @@ public class CustomGameEvent : ArgumentGameEvent<Custom>
45
43
}
46
44
```
47
45
48
-
In order to enable raising of custom game events from the inspector, create a `CustomEditor` script where the argument fields are going to be drawn. To do so, define an editor script, extend `GameEvents.Generic.ArgumentGameEventEditor` and override `DrawArgumentField(Custom)`. Make sure to place this script under the `Editor` folder:
46
+
In order to enable raising of custom game events from the inspector, create a `CustomEditor` script where the argument fields are going to be drawn. Extend `GameEvents.Generic.ArgumentGameEventEditor` and override `DrawArgumentField(Custom)`. Make sure to place this script under the `Editor` folder:
@@ -58,22 +56,22 @@ public class CustomGameEventEditor : ArgumentGameEventEditor<CustomGameEvent, Cu
58
56
```
59
57
60
58
### Game event listeners
61
-
Game events can be listened to by listener components. To use listeners, you need to create an appropriate listener component:
59
+
Game events can be listened to by listener components. To use pre-made listeners, add an appropriate listener component:
62
60
-`GameEvent` - _Add Component -> Game Events -> Game Event Listener_
63
61
-`ArgumentGameEvent` - _Add Component -> Game Events -> "Argument Name" Game Event Listener_
64
62
65
63
Once the component is added, slot in the appropriate `GameEvent` you want the listener to listen to and add your response methods to `onGameEvent` callback via the inspector.
66
64
67
65
### Custom game event listeners
68
-
Custom game event listeners which accept different arguments can also be created. First of all, create a `UnityEvent` which would accept your `Custom` type:
66
+
Custom game event listeners which accept different arguments can also be created. Create a `UnityEvent` which would accept your `Custom` type:
69
67
```cs
70
68
[Serializable]
71
69
publicclassCustomEvent : UnityEvent<Custom>
72
70
{
73
71
}
74
72
```
75
73
76
-
Then, create a custom game event listener which. This can be done by extending `GameEvents.Generic.ArgumentGameEventListener` class.
74
+
Then, create a custom game event listener by extending `GameEvents.Generic.ArgumentGameEventListener`.
77
75
```cs
78
76
[AddComponentMenu("Game Events/Custom Game Event Listener")]
0 commit comments