Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tertle/com.bovinelabs.entities
A collection of extensions, systems and jobs for Unity ECS.
https://github.com/tertle/com.bovinelabs.entities
Last synced: 2 months ago
JSON representation
A collection of extensions, systems and jobs for Unity ECS.
- Host: GitHub
- URL: https://github.com/tertle/com.bovinelabs.entities
- Owner: tertle
- Created: 2018-12-28T10:55:27.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-09-04T03:00:17.000Z (over 5 years ago)
- Last Synced: 2024-08-03T05:17:35.870Z (5 months ago)
- Language: C#
- Homepage:
- Size: 91.8 KB
- Stars: 125
- Watchers: 18
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-unity-open-source-on-github - com.bovinelabs.entities - A collection of extensions, systems and jobs (ECS)
README
# com.bovinelabs.entities
## Systems
### EntityEventSystem
https://forum.unity.com/threads/batch-entitycommandbuffer.593569/Easily create lots of events extremely efficiently.
#### How to use
Instead of using a EntityCommandBuffer, we get a NativeQueue from CreateEventQueue where T is IComponentData, the event data.
```c#
NativeQueue EntityEventSystem.CreateEventQueue(JobComponentSystem componentSystem)
```
It is safe to pass this queue to Jobs, using ToConcurrent() for parallal jobs. Once you have this queue, to create an event simply create, set and add a new type of T to the queue and the EntityEventSystem will handle the rest for you.The EntityEventSystem will batch create create entities for all these components and then set the component data.
#### Things to know
* Events live exactly 1 frame. They will be created in EntityEventSystem and 1 frame later destroyed in EntityEventSystem.
* Use of event will be delayed till the next frame. EntityEventSystem executes just before EndFrameBarrier.
* You can use CreateEventQueue for the same type from different systems or even multiple times from the same system.
* In the case of the same system, it's slightly faster to reuse the same queue if systems have correct dependencies.
* The system calling CreateEventQueue passes a reference to itself to the EntityEventSystem and this is used to ensure dependencies are completed before EntityEventSystem is updated.#### CreateBufferEvent
```c#
void CreateBufferEvent(T component, NativeArray buffer)
```
Works similar to CreateEventQueue except it will add a component T and BufferArray to the entity.
**Note:** you do not need to worry about disposing the NativeArray as this will be done for you.## Containers
* NativeUnit - Let's you effectively pass a 'reference' of a struct between jobs.## Extensions
* EntityManager - SetComponentObject(Entity, ComponentType, object)
* World - AddManager for creating your own managers dynamically (dependency injection etc)
* List - AddRange(NativeArray), AddRange(NativeList), AddRange(DynamicBuffer), AddRange(NativeSlice), AddRange(void*, int), Resize(int), EnsureLength(int, T)
* DynamicBuffer - Contains(T), IndexOf(T), Remove(T), Reverse(), ResizeInitialized(int), CopyTo(NativeArray)
* NativeList - Reverse(), Insert(T, int), Remove(T), RemoveAt(int), RemoveRange(int, int)