I am excited to announce that Simpleton v1.8.0 is now officially available on the Unity Asset Store!
Simpleton is a lightweight, minimalistic Dependency Injection (DI) framework designed specifically for Unity game development. This update focuses on performance and stability: `IDeferredReference<T>.ExecuteIfPresent` no longer allocates GC memory, so you can broadcast to your dynamically spawned views every frame. It also fixes lifetime handling for inactive GameObjects and removes warnings that could appear after running EditMode tests.
π What's New in v1.8.0
1. Zero-Allocation ExecuteIfPresent
In v1.7.0, `ExecuteIfPresent` gained the ability to broadcast an action to every registered instance. Until now, each call allocated a temporary snapshot array, which created garbage when the method was called every frame.
In v1.8.0, `ExecuteIfPresent` itself no longer allocates. Registering or unregistering instances inside the action is still safe: each call runs on the instances that were registered when it started.
To keep your whole `Update` loop allocation-free, avoid lambdas that capture local variables, since they create a new closure on every call. Cache the delegate in a field instead:
```csharp
private Action<ITimeDisplay> setTimeAction = default!;
private DateTime currentTime;
[Inject]
private void Construct(IDeferredReference<ITimeDisplay> timeDisplays)
{
this.timeDisplays = timeDisplays;
this.setTimeAction = display => display.SetTime(this.currentTime);
}
private void Update()
{
this.currentTime = DateTime.Now;
this.timeDisplays.ExecuteIfPresent(this.setTimeAction);
}
```
• Benefit: Broadcast per-frame updates (HUDs, timers, indicators) to any number of spawned views with zero GC allocations in the profiler.
2. Bug Fixes
• [RegisterToDeferredReference] on inactive GameObjects: Targets registered while inactive are now released when the target or its installer is destroyed. `ExecuteIfPresent` also skips instances that have already been destroyed.
• EditMode test warnings: Fixed "Disposer was not disposed properly" warnings that could appear after running EditMode tests. `Disposable.Empty()` now returns a shared no-op instance.
3. Updated Sample, AI Skills & User Guide
• Sample 15 (15_DeferredReferenceMultipleRegistration): Now caches its delegate so the presenter's Update loop is allocation-free.
• Updated AI Skills: The built-in AI Skills (under `AI/Skills/`) have been updated to asset-version 1.8.0. Before release, every scenario was re-verified, and several skills were corrected based on the results (for example, basing Presenter attributes on `EagerInjectableAttribute`, and disposing `ServiceRegistry` in tests).
• User Guide: The User Guide PDF and the online guide have been updated with per-frame usage guidance and the 1.8.0 release notes.
π Full Changelog
[1.8.0] - 2026-10
• IDeferredReference<T>.ExecuteIfPresent no longer allocates GC memory on each call.
• Registering or unregistering instances inside the ExecuteIfPresent action remains safe.
• Fixed lifetime handling of [RegisterToDeferredReference] targets registered while inactive.
• ExecuteIfPresent now skips instances that have already been destroyed.
• Fixed "Disposer was not disposed properly" warnings after EditMode tests; Disposable.Empty() now returns a shared no-op instance.
• Updated sample 15_DeferredReferenceMultipleRegistration to avoid per-frame closure allocations.
• Updated AI Skills to asset-version 1.8.0, with corrections from the pre-release verification run.
• Updated the User Guide with per-frame usage guidance.
• No breaking changes.
π Get Simpleton Today!
Update your project or get started with Simpleton today on the Unity Asset Store:
• Unity Asset Store: https://assetstore.unity.com/packages/tools/utilities/simpleton-326289
• Official Website: https://fig-code-factory.blogspot.com/
Thank you for using Simpleton! If you have any questions, suggestions, or feedback, please feel free to leave a review or reach out.
No comments:
Post a Comment