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: docs/src/content/docs/components/event-listener.mdx
+63-1Lines changed: 63 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,4 +3,66 @@ title: Event Listener
3
3
description: Event listener component for hooking up events in the inspector.
4
4
sidebar:
5
5
order: 10
6
-
---
6
+
---
7
+
8
+
Event Listener is a component that allows you to hook up events from a [scriptable event](../../types/scriptable-event/) in the inspector.
9
+
10
+
## Usage
11
+
12
+
Assign a scriptable event to the `Target Event` field of the component.
13
+
14
+
Then pick when you want to start listening. You can pick between `Awake`, `Start`, and `OnEnable`.
15
+
16
+
-`Awake`: The event will be triggered when the value changes in the `Awake` method.
17
+
-`Start`: The event will be triggered when the value changes in the `Start` method.
18
+
-`OnEnable`: The event will be triggered when the value changes in the `OnEnable` method.
19
+
20
+
Then pick when you want to stop listening. You can pick between `OnDestroy` and `OnDisable`.
21
+
22
+
-`OnDestroy`: The event will be triggered when the value changes in the `OnDestroy` method.
23
+
-`OnDisable`: The event will be triggered when the value changes in the `OnDisable` method.
24
+
25
+
After that you can pick when you want the events to be triggered. You can pick between `Any`, `From Value`, and `To Value`.
26
+
27
+
-`Any`: The event will be triggered any time the event is invoked.
28
+
-`From Value`: The event will be triggered when the event is invoked from the value you set in the inspector.
29
+
-`To Value`: The event will be triggered when the event is invoked to the value you set in the inspector.
30
+
31
+
:::note
32
+
`Invoke On` does not exist on event listeners without arguments.
33
+
:::
34
+
35
+
## Extending
36
+
37
+
Event Listeners are extended by inheriting from the [`ScriptableEventListener<T>`](../../reference/hertzole.scriptablevalues.scriptableeventlistener-1/) class. This will allow you to create your own event listeners for your own types.
0 commit comments