Repository navigation
Releases
Releases · KenseiTheOne/KenseiECS
KenseiECS v2.0.0
Breaking
IComponentPoolreplaced by the abstract classComponentPoolBase.Clear,AddDefaultandCopyToare now internal; user code can no longer desynchronize masks and filters by calling them.World.GetEntity(int)on a dead slot returns the dead entity's own handle (IsAliveis false) instead of throwing underKENSEI_DEBUG. A slot's generation now changes when the slot is reused, not when it is freed.IWorldEventListener.OnEntityCreatedfires after the first component is added (CreateEntity) or after all components are copied (CopyEntity). Listeners never observe an entity without components.World.Unsubscribe<T>keeps the emptyListeners<T>component; unsubscribing the last listener no longer auto-destroys the entity.HasListeners<T>is false for an empty list.World.Remove<T>no longer creates the pool for a type that was never added.SystemsRunner.DestroyrunsIDestroySystem.Destroyin reverse registration order, is a no-op beforeInit, and resets the runner soInitcan run again.Listeners<T>andWorldListenerExtensionsmoved fromUnity/toCore/and no longer depend on Unity.- The .NET project file moved from
KenseiECS/KenseiECS.csprojtoKenseiECS.NET/KenseiECS.csproj; theKenseiECS/folder is now a UPM package.
Added
FilterBuilder.Any<T>(): match entities with at least one of the listed types.AnyandExcof the same type is rejected;Anyof anInctype is dropped as redundant.world.Filter<Inc<A, B>, Exc<C>, Any<D, E>>()static filter specs (Inc1-6 types,Exc1-4,Any2-4,None).Filter.IsEmpty,First(),TryGetFirst,Single(),Entitiesspan,AddListener(IFilterListener)for enter/leave notifications.ComponentPool<T>.AddListener(IComponentListener<T>):OnAddedafter filters update,OnRemovedbefore AutoReset.CommandBuffer: deferredCreateEntity/Add/Set/Remove/DestroyEntitywithPendingEntityhandles, typed payload storage, zero allocations after warmup; commands on dead entities are skipped.World.GetSingleton<T>(),GetSingletonEntity<T>(),HasSingleton<T>().EventBuffer<T>component andworld.AddEvent(entity, value)for several events per entity per frame; lists are pooled.KENSEI_DEBUG: removing an entity from a filter that is being iterated throws when the swap-remove would make the loop visit an entity twice (nested loops tracked per enumerator).KenseiECS.NETmulti-targetsnetstandard2.1andnet8.0; the .NET build usesBitOperations.SystemsRunner.GetSystemInfo(int),SystemCount,SetActive(int, bool),IsEnabled,World: introspection for tooling. Every run system gets aProfilerMarkeron Unity;LastRunMs/PeakRunMsandResetTimings()underKENSEI_DEBUG.World.FilterCount/GetFilter(int);Filter.IncludedTypes/ExcludedTypes/AnyTypes,ToString(),DenseCapacity,AllocatedBytes;ComponentPoolBase.SparseCapacity,DenseCapacity,ComponentSize,AllocatedBytes.World.SetName(Entity, string)/GetName(Entity)debug entity names (SetNamecompiles out withoutKENSEI_DEBUG).- Filter sparse arrays are paged (1024 slots per page, allocated on first touch); a filter no longer costs an
intper entity slot of the world. - Owning groups:
world.Group<T1, T2>()(up to four types) keeps the owned pools' dense arrays aligned so members can be iterated throughData1..DataNspans with no sparse lookups. A pool belongs to at most one group.World.GroupCount/GetGroup. - Change tracking:
pool.TrackChanges(),Modify(e),MarkChanged(e),ChangedVersion(e),ChangedSince(e, version)withWorld.ChangeVersionas the consumer's bookmark. WorldSerializer:Save(world, stream)/Load(world, stream)snapshots that keep entity indices and generations (soEntityfields inside components stay valid), identify types by name, write unmanaged components bit-for-bit and useIComponentFormatter<T>for components with references.- Source generator (
KenseiECS.Generators, shipped asPlugins/KenseiECS.Generators.dll):[Inc],[Exc],[Any],[Pool],[Group],[Shared]on fields of a partial system class generateInitand callpartial void OnInit(World, SharedData). Diagnostics KECS001-KECS005 for misuse. World.TryGetEntity(int, out Entity).ParallelRunnerandIRangeJob: struct jobs over an index range (filterEntitiesor groupDataspans) on fixed worker threads plus the caller, dynamic chunking, no allocations perRun, worker exceptions rethrown on the caller.- Unity:
EcsBootstrapbase MonoBehaviour (World, SharedData, update/fixed/late runners, warmup),IEcsSystemsProvider,EcsComponentProvider<T>inspector-authored components,EcsEntityView.Spawn(world)andEntityName,KenseiECS -> Systemswindow with enable toggles and timings, Filters and Pools tabs in the World Inspector, debug names in inspector and profiler,Samples~/BasicGame. - UPM package:
package.json,KenseiECSandKenseiECS.Editorassembly definitions, committed.metafiles. Install via git URL with?path=/KenseiECS. ComponentType.TypeOf(int)andComponentType.NameOf(int)resolve thetypeIndexpassed to world event listeners.World.GetComponentTypes(Entity, List<int>),World.GetComponentCount(Entity),World.GetPool(int).ComponentPoolBase.ComponentType.SystemsRunner.DelHere<T>()removes allTat that point of the pipeline;SystemsRunner.IsInitialized,SystemsRunner.Shared.SystemsRunner.SetActive/IsActivework on named child runners.Listeners<T>.Count.IAutoReset<T>andIAutoCopy<T>may be implemented explicitly.KENSEI_DEBUGvalidation: poolAddon a dead or never-allocated slot,RunbeforeInit,AddafterInit, unknown names inSetActive/IsActive/GetRunner,GetComponentTypeson a dead entity.- GitHub Actions workflow running the test suite in both configurations.
Fixed
- An exception thrown by a world event listener or
AutoResetduringDestroyEntityleft a permanent zombie (dead flag set, components and filter membership intact, slot never freed). The slot is now always released and components are drained infinally. - An exception in
SystemsRunner.Initmarked the runner initialized and skipped the remaining systems forever;Initnow resumes at the failed system. - An exception in a system skipped OneFrame cleanup, so events were processed twice; cleanup now runs in
finally. Warmupfired world events and profiler records for its temporary entity.- Removing a world event listener with a lower index from inside a dispatch invoked the current listener twice; the listener list is now copy-on-write.
- A child
SystemsRunnerconstructed withoutSharedDatagot an empty container instead of the parent's. - The World Inspector and EcsEntityView inspector lost edits made to nested structs and array elements.
KenseiECS -> Debug ModeappliedKENSEI_DEBUGonly to the current build target group.EcsProfilerkept a static reference to a destroyed world and survived Enter Play Mode without domain reload.Il2CppSetOptiondid not apply toFilter.Enumerator(nested types do not inherit it), so the hottest loop kept bounds checks under IL2CPP.ComponentPool.ClearandWorld.Clearwere O(entity capacity) per pool; sparse entries are now reset through the dense list.
Changed
- Per-type filter lists are split into include/exclude/any, so adding or removing a component tests the mask only for filters it can move the entity into.
KenseiECS v1.0.0
KenseiECS v1.0.0
Lightweight, Sparse Set-based Entity Component System for Unity.
Highlights
- Sparse Set storage — O(1) component access, dense arrays for cache-friendly iteration
- Dynamic component bitmask — unlimited component types with O(1) filter membership check
- Reactive filters — always up-to-date, no manual synchronization
- Zero-allocation iteration — struct enumerator, no GC pressure
- Generational entities — 8-byte Entity (int Index + int Generation)
- Auto-destroy — entities without components are destroyed automatically
- IAutoReset / IAutoCopy — custom cleanup and deep-copy logic
- OneFrame components — auto-removed event components
- Nested system runners — separate groups for Update/FixedUpdate/LateUpdate
- Named systems — enable/disable at runtime
- Editor tools — World Inspector, Profiler, EcsEntityView with navigation (under KENSEI_DEBUG)
Performance (10,000 entities, .NET 8, zero allocations)
| Operation | KenseiECS | vs LeoEcsLite | vs Arch |
|---|---|---|---|
| Iteration (2 components) | 13.9 us | 1-8% faster | 2.5x slower |
| Entity creation (2 components) | 232 us | 1.5-2.6x faster | 1.6-4.8x faster |
| Structural changes (add+remove) | 90.8 us | 1.2x slower | 6.5x faster |
| Game loop (mixed frame) | 31.3 us | 27-32% faster | 2.4x faster |
Installation
- Download
KenseiECS-v1.0.0.zipfrom Assets below - Extract into your Unity project's
Assets/Scripts/(or any folder) - Done — no assembly definitions required
Define Symbols
KENSEI_DEBUG— enables Editor tools (World Inspector, Profiler, EcsEntityView)