Skip to content
A collection of extensions, systems and jobs for Unity ECS.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Entities Updated to p29 Mar 19, 2019
.gitattributes Repo setup Dec 28, 2018
.gitignore
.npmignore Repo setup Dec 28, 2018
Entities.meta Renamed to entities Dec 29, 2018
README.md Update README.md Jan 4, 2019
README.md.meta Meta Jan 4, 2019
package.json Updated to p29 Mar 19, 2019
package.json.meta Added first extension for testing the setup. Dec 29, 2018

README.md

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.

NativeQueue<T> EntityEventSystem.CreateEventQueue<T>(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

void CreateBufferEvent<T, TB>(T component, NativeArray<TB> 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)
You can’t perform that action at this time.