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
Copy file name to clipboardExpand all lines: Documentation~/README.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,9 +14,9 @@ The documented features can be imported as samples via [Unity Package Manager] f
14
14
</p>
15
15
16
16
## Getting Started (Simple Events)
17
-
The simplest use case of _Scriptable Events_ is when you want to notify a system that something happened without providing any context. To do so, you need two elements: a _Simple Scriptable Event_ and a _Simple Scriptable Event Listener_.
17
+
The simplest use case of _Scriptable Events_ is when you need to notify a system that something happened without providing any context. To do so, you need two elements: a _Simple Scriptable Event_ and a _Simple Scriptable Event Listener_.
18
18
19
-
First, create a _Simple Scriptable Event_ asset by right-clicking in the project window and selecting _Scriptable Events/Simple Scriptable Event_. You can name the event as you prefer and place it anywhere in your project:
19
+
First, create a _Simple Scriptable Event_ asset by right-clicking in the project window and selecting _Create/Scriptable Events/Simple Scriptable Event_. You can name the event as you prefer and place it anywhere in your project:
20
20
<palign="center">
21
21
<imgsrc="simple-scriptable-event.png"/>
22
22
</p>
@@ -26,15 +26,15 @@ Next, select a _GameObject_ in the scene and add a _Simple Scriptable Event List
26
26
<imgsrc="simple-scriptable-event-listener.png"/>
27
27
</p>
28
28
29
-
Once you've added a listener, insert your event asset into the _Scriptable Event_ field (1). In the _On Raised_[Unity Event] field (2), insert the methods you'd like to be triggered by the event. For example, if you wanted to change a color of an object, your setup might look like the following as seen in the _Simple Events_ sample:
29
+
Once you've added a listener, insert your event asset into the _Scriptable Event_ field (1). In the _On Raised_[Unity Event] field (2) add the methods you'd like to be triggered by the event. For example, if you need to change a color of an object, your setup might look like the following as seen in the _Simple Events_ sample:
30
30
<palign="center">
31
31
<imgsrc="simple-scriptable-event-sample.png"/>
32
32
</p>
33
33
34
-
Now that you have your listener ready, you need to trigger the event. This can be done from a [Unity Event] by calling `SimpleScriptableEvent.Raise` method or by selecting the event asset and clicking the _Raise_ button when the game is running:
34
+
Now that you have your listener ready, you need to trigger the event. This can be done from a [Unity Event] by calling `SimpleScriptableEvent.Raise` method or by selecting the event asset and clicking the _Raise_ button during runtime:
@@ -55,17 +55,17 @@ public class TriggerEvent : MonoBehaviour
55
55
```
56
56
57
57
## Passing Arguments (Events With Arguments)
58
-
In most situations you'll want to pass an argument when triggering an event. For example, if the player takes damage, you might want to notify your systems with the amount of damage taken.
58
+
In some situations might need to pass an argument when triggering an event. For example, if the player takes damage, you might need to notify your systems with the amount of damage taken.
59
59
60
-
For such uses cases, this package provides a set of events with commonly used argument types. To create an event asset which accepts an argument, right-click in the project window and select an event from _Scriptable Events/_ menu which has the required type:
60
+
For such uses cases, this package provides a set of events with commonly used argument types. To create an event asset which accepts an argument, right-click in the project window and select an event from _Create/Scriptable Events/*_ menu which has the required type:
61
61
<palign="center">
62
62
<imgsrc="scriptable-event-arg.png"/>
63
63
</p>
64
64
65
-
Next, you'll want to add a listener. Each corresponding _Scriptable Event_ type provides a listener component. Each typed listener works in the same fashion as _Simple Scriptable Event Listener_. The only caveat is when inserting your methods into the _On Raised_[Unity Event] field. In this case make sure to select a **dynamic** method:
65
+
Next, you'll need to add a listener. Each corresponding _Scriptable Event_ type provides a listener component. Each typed listener works in the same fashion as _Simple Scriptable Event Listener_. The only caveat is when inserting your methods into the _On Raised_[Unity Event] field. In this case make sure to select a **dynamic** method:
To trigger the event follow the same steps as with _Simple Scriptable Event_. However, make sure to select a **dynamic**`Raise` method:
@@ -94,9 +94,9 @@ public class TriggerEvent : MonoBehaviour
94
94
```
95
95
96
96
## Creating Custom Events (Custom Events)
97
-
In some cases using the built-in argument types is not sufficient. For example, if the player takes damage, you might also want to pass a reference to the object that dealt damage to the player. In this case passing only the damage taken is not enough, you need to pass a `class` argument which contains both of those values. For this you'll need to create a custom event.
97
+
In some cases using the built-in argument types is not sufficient. For example, if the player takes damage, you might also need to pass a reference to the object that dealt damage to the player. In this case passing only the damage taken is not enough, you need to pass a `class` argument which contains both of those values. For this you'll need to create a custom event.
98
98
99
-
To start, create a container `class` for your event data. In this case we'll pass the values needed to change the `Metallic` and `Color` properties of a material:
99
+
To start, create a container `class` for your event data. In this example we'll pass the values needed to change the `Metallic` and `Color` properties of a material:
100
100
```cs
101
101
publicclassMaterialData
102
102
{
@@ -164,7 +164,7 @@ public class MaterialOptionsHandler : MonoBehaviour
164
164
}
165
165
```
166
166
167
-
Optionally you can add a custom editor for your event. This will allow you to click the _Raise_ button on your custom event during runtime. To do so, create an editor class which inherits `BaseScriptableEventEditor`in the **Editor** directory:
167
+
**Optionally** you can add a custom editor. This will allow you to click the _Raise_ button on your custom event asset during runtime. To do so, create an editor class which inherits `BaseScriptableEventEditor`. Make sure to place this class in the **Editor** directory, or your project will not build:
0 commit comments