Skip to content

Commit fb8204e

Browse files
authored
WIP on readme
1 parent 22700c0 commit fb8204e

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

README.md

+31-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Unity Events
1+
# Unity Events 2.0
22
=======================
3-
An efficient code focused typed event system with global and per GameObject event systems. Loosely couple components by using this event system to invoke functions who listen for events.
3+
An efficient code focused typed publisher/subscriber event system. Supports global event system and per object event systems that send deferred events to be processed at a later time. Allows regular callback events and multithreaded jobs that trigger on events.
44

55
####Obtain!####
66
[Releases](https://github.com/GalvanicGames/unity-events/releases)
@@ -11,6 +11,35 @@ If you'd like the most up to date version (which is the most cool), then pull th
1111

1212
Once the Unity Events asset has been imported into the project then the event system is ready to be used.
1313

14+
## Simple Usage
15+
16+
### Events ###
17+
Events in Unity Events are unmanaged structs that that are created by publishers and processed by subscribers.
18+
19+
```csharp
20+
// This is the example struct that will be used throughout all the examples
21+
public struct MyExampleEvent
22+
{
23+
// Can pass ANY unmanaged information in these events!
24+
public int intValue;
25+
public float floatValue;
26+
27+
public MyExampleEvent(int intValue, float floatValue)
28+
{
29+
this.intValue = intValue;
30+
this.floatValue = floatValue;
31+
}
32+
}
33+
```
34+
35+
As previously mentioned, Events HAVE to be unmanaged types. This means primitives and structs that only contain primitives. This is done to force "good" habits by only sending copyable data. Since events aren't processed immediately references can be stale or even point to "null" Unity objects. If a reference still needs to be sent (say to a GameObject or a ScriptableObject), create a look up database and send an ID in the event.
36+
37+
If an array/list needs to be sent then consider using something like [ValueTypeLists](https://gist.github.com/cjddmut/cb43af3ee191af78363f41a3188c0f7b).
38+
39+
### Global Event Systems ###
40+
41+
### Local Event Systems ###
42+
1443
## Event Systems
1544

1645
A Unity Events event system works fairly simply. It will maintain a list of subscribed functions to each strongly typed event. When an event is sent through a system, it will invoke each function that is listening for that event. There are two different kinds of event systems, global and local.

0 commit comments

Comments
 (0)