Unity Helpers¶
๐ค AI Assistance Disclosure:
Recent versions of this project have utilized AI assistance for feature development, bug detection, performance optimization, and documentation.
The original codebase was developed entirely by humans over several years.
Reduces boilerplate code for common Unity patterns.
Unity Helpers reduces repetitive work with tested utilities. Benchmarks show 10-15x faster random generation than Unity.Random and significant speedups for common reflection operations (see performance docs). From auto-wiring components to efficient spatial queries, this toolkit provides tools for Unity development.
๐ฆ Quick Install¶
| Source | Install Method |
|---|---|
| OpenUPM (Recommended) | openupm add com.wallstop-studios.unity-helpers |
| Git URL | Package Manager โ Add from git URL โ https://github.com/wallstop/unity-helpers.git |
| NPM | Add scoped registry https://registry.npmjs.org โ search com.wallstop-studios.unity-helpers |
| Source | Import .unitypackage or clone repo |
๐ Full installation instructions with step-by-step guides for each method.
Key Features:
- ๐จ Inspector tooling - Grouping, buttons, conditional display, toggle grids (free and open-source) โ Migration Guide
- โก 10-15x faster random generation than Unity.Random in benchmarks
- ๐ Reduced boilerplate component wiring with attributes
- ๐ฎ Designer-friendly effects system (buffs/debuffs as ScriptableObjects)
- ๐ณ O(log n) spatial queries instead of O(n) loops
- ๐ ๏ธ 20+ editor tools that automate sprite/animation workflows
- โ 8,000+ tests
๐บ๏ธ Roadmap Snapshot โ See the Roadmap for prioritized details.
- Inspector tooling: inline nested editors, tabbed navigation, live instrumentation, disable-if/layer attributes
- Editor automation: Animation Creator and Sprite Sheet Animation Creator enhancements, timeline-ready Event Editor upgrades, and new automation dashboards
- Random/statistics: CI statistical harness, automated quality reports, scenario samplers, job-safe stream schedulers
- Spatial trees: graduate the 3D variants, add incremental updates, physics-shape parity, and streaming builders
- UI Toolkit: control pack (dockable panes, data grids), theming samples, and performance patterns
- Utilities: cross-system bridges plus new math/combinatorics and service-pattern helpers
- Performance: automated benchmarks, Burst/Jobs rewrites of hot paths, and allocation analyzers
- Attributes & tags: effect visualization tools, attribute graphs, and migration/versioning helpers
- Relational components: cached reflection, source generators, editor-time validation, and interface-based resolution
๐ New to Unity Helpers? Start here: Getting Started Guide
๐ Looking for something specific? Check the Feature Index
โ Need a definition? See the Glossary
๐ First Time Here?¶
Choose your starting point:
| Your Problem | Your Solution | Time to Value |
|---|---|---|
| ๐จ Writing custom editors | Inspector Tooling - Odin-level features, free | ~2 minutes |
๐ Writing GetComponent everywhere | Relational Components - Auto-wire with attributes | ~2 minutes |
| ๐ฎ Need buffs/debuffs system | Effects System - Designer-friendly ScriptableObjects | ~5 minutes |
| ๐ Slow spatial searches | Spatial Trees - O(log n) queries | ~5 minutes |
| ๐ฒ Random is too slow/limited | PRNG.Instance - 10-15x faster in benchmarks | ~1 minute |
| ๐พ Need save/load system | Serialization - Unity types just work | ~10 minutes |
| ๐ ๏ธ Manual sprite workflows | Editor Tools - 20+ automation tools | ~3 minutes |
Not sure where to start? โ Getting Started Guide walks through the top 3 features in 5 minutes.
โก Top Time-Savers¶
These features reduce entire categories of repetitive work. Pick one that solves your immediate pain:
1. ๐จ Inspector Tooling¶
โฑ๏ธ 5-10 min/script ร 200 scripts = ~20 hours saved on custom editors
Declarative inspector attributes reduce the need for custom PropertyDrawers and EditorGUI code:
Features:
- WGroup - Boxed sections with auto-inclusion, collapsible headers, and animations when enabled
- WButton - Method buttons with history, async support, cancellation
- WShowIf - Conditional visibility (9 comparison operators)
- WEnumToggleButtons - Flag enums as visual toggle grids
- SerializableDictionary, SerializableSet, WGuid, SerializableType - Collections Unity can't serialize
๐ Complete Inspector Guide | ๐ Odin Migration Guide
2. ๐ Auto-Wire Components¶
โฑ๏ธ 10-20 min/script ร 100 scripts = ~20 hours saved
Reduces GetComponent boilerplate with attribute-based auto-wiring. Replace 20+ lines with 3 attributes:
Bonus: Works with VContainer/Zenject/Reflex for automatic DI + relational wiring!
๐ Learn More | See Samples~/DI - VContainer, Samples~/DI - Zenject, and Samples~/DI - Reflex folders in the repository for DI examples
3. ๐ฎ Data-Driven Effects¶
โฑ๏ธ 2-4 hours/effect ร 50 effects = ~150 hours saved
Designers create buffs/debuffs as ScriptableObjects. Zero programmer time after 20-minute setup:
What you get:
- Automatic stacking & duration management
- Reference-counted tags for gameplay queries
- Cosmetic VFX/SFX that spawn/despawn automatically
- Designer-friendly iteration without code changes
Beyond buffs: Tags become a flexible capability system for AI decisions, permission gates, state management, and complex gameplay interactions (invulnerability, stealth, elemental systems).
๐ Full Guide | ๐ 5-Minute Tutorial
4. ๐พ Unity-Aware Serialization¶
โฑ๏ธ 40+ hours on initial implementation + prevents player data loss
JSON/Protobuf that understands Vector3, GameObject, Color - no custom converters needed:
Real-world impact: Ship updates without worrying about corrupting player saves.
5. ๐ฑ Object Pooling¶
โฑ๏ธ Reduces GC spikes = 5-10 FPS improvement in complex scenes
Zero-allocation queries with automatic cleanup. Thread-safe pooling in one line:
Why this matters:
- Stable 60 FPS under load (no GC spikes)
- AI systems querying hundreds of neighbors per frame
- Particle systems with thousands of particles
- Works for List, HashSet, Stack, Queue, and Arrays
6. ๐ ๏ธ Editor Tools Suite¶
โฑ๏ธ 1-2 hours/operation ร weekly use = ~100 hours/year
20+ tools that automate sprite cropping, animation creation, atlas generation, prefab validation:
Common workflows:
- Sprite Cropper: Add or remove transparent pixels from 500 sprites โ 1 click (was: 30 minutes in Photoshop)
- Animation Creator: Bulk-create clips from naming patterns (
walk_0001.png) โ 1 minute (was: 20 minutes) - Prefab Checker: Validate 200 prefabs for missing references โ 1 click (was: manual QA)
- Atlas Generator: Create sprite atlases from regex/labels โ automated (was: manual setup)
๐ Batteries-Included Extensions¶
Unity Helpers includes 200+ extension methods for common Unity operations:
Unity Type Extensions¶
Math That Should Be Built-In¶
Collection Utilities¶
Full list: Math & Extensions Guide | Reflection Helpers
๐ Additional Utilities¶
These utilities solve specific problems that waste hours if you implement them yourself:
| Feature | What It Does | Time Saved |
|---|---|---|
| Predictive Targeting | Accurate ballistics for turrets/missiles in one call | 2-3 hours per shooting system |
| Coroutine Jitter | Prevents 100 enemies polling on same frame | Reduces frame spikes |
| IL-Emitted Reflection | Up to 12x faster than System.Reflection for method invocations, IL2CPP safe | Critical for serialization/modding |
| SmartDestroy() | Editor/runtime safe destruction (no scene corruption) | Prevents countless debugging hours |
| Convex/Concave Hulls | Generate territory borders from point clouds | 4-6 hours per hull algorithm |
| Logging Extensions | Rich tags, thread-aware logs, per-object toggles | Keeps consoles readable + actionable |
Design Philosophy¶
Unity Helpers reduces repetitive work by providing tested utilities for common Unity patterns, including GetComponent boilerplate, spatial query loops, and save/load systems.
Built for Real Projects:
- โ Tested in shipped commercial games
- โ 8,000+ automated tests catch edge cases before you hit them
- โ Minimal external dependencies - depends on protobuf-net for binary serialization
- โ IL2CPP/WebGL ready with optimized SINGLE_THREADED paths
- โ MIT Licensed - use freely in commercial projects
Who This Is For:
- Indie devs who need tools without enterprise overhead
- Teams who value performance and want their junior devs to use tested code
- Senior engineers who want to avoid re-implementing the same utilities every project
Installation¶
Unity Helpers is available from multiple sources. Choose the one that best fits your workflow:
| Source | Best For | Auto-Updates |
|---|---|---|
| OpenUPM | Most users, easy version management | โ Yes |
| Git URL | Latest commits, CI/CD pipelines | โ Yes |
| NPM Registry | Teams already using NPM | โ Yes |
| Source | Offline, modifications needed | โ Manual |
From OpenUPM (Recommended)¶
OpenUPM is the recommended installation method for easy version management and updates.
Option A: Via Package Manager UI¶
- Open Edit โ Project Settings โ Package Manager
- Under Scoped Registries, click + to add a new registry:
- Name:
OpenUPM - URL:
https://package.openupm.com - Scope(s):
com.wallstop-studios - Click Save
- Open Window โ Package Manager
- Change the dropdown to My Registries
- Find and install
Unity Helpers
Option B: Via OpenUPM CLI¶
If you have the OpenUPM CLI installed:
| Bash | |
|---|---|
Option C: Manual manifest.json¶
Add to your Packages/manifest.json:
| JSON | |
|---|---|
From Git URL¶
Install directly from GitHub for the latest version:
- Open Window โ Package Manager
- Click + โ Add package from git URL...
- Enter:
https://github.com/wallstop/unity-helpers.git
OR add to your Packages/manifest.json:
| JSON | |
|---|---|
Tip: To lock to a specific version, append
#3.1.0to the URL.
From NPM Registry¶
- Open Edit โ Project Settings โ Package Manager
- Under Scoped Registries, click + to add a new registry:
- Name:
NPM - URL:
https://registry.npmjs.org - Scope(s):
com.wallstop-studios - Click Save
- Open Window โ Package Manager
- Change the dropdown to My Registries
- Find and install
com.wallstop-studios.unity-helpers
From Source¶
Option A: Import Unity Package¶
- Download the latest
.unitypackagefrom GitHub Releases - In Unity, go to Assets โ Import Package โ Custom Package...
- Select the downloaded
.unitypackagefile and import
Option B: Clone or Download Repository¶
- Clone or download the repository
- Copy the contents to your project's
Assets/orPackages/folder - Unity will automatically import the package
Compatibility¶
| Unity Version | Built-In | URP | HDRP |
|---|---|---|---|
| 2021 | Likely, but untested | Likely, but untested | Likely, but untested |
| 2022 | โ Compatible | โ Compatible | โ Compatible |
| 2023 | โ Compatible | โ Compatible | โ Compatible |
| Unity 6 | โ Compatible | โ Compatible | โ Compatible |
Platform Support¶
Unity Helpers is multiplatform compatible including:
- โ WebGL - Full support with optimized SINGLE_THREADED hot paths
- โ IL2CPP - Tested and compatible with ahead-of-time compilation
- โ Mobile (iOS, Android) - Compatible with IL2CPP
- โ Desktop (Windows, macOS, Linux) - Full threading support
- โ Consoles - IL2CPP compatible
Requirements:
- .NET Standard 2.1 - Required for core library features
WebGL and Single-Threaded Optimization¶
Unity Helpers includes a SINGLE_THREADED scripting define symbol for WebGL and other single-threaded environments. When enabled, the library automatically uses optimized code paths that eliminate threading overhead:
Optimized systems with SINGLE_THREADED:
- Buffers & Pooling - Uses
Stack<T>andDictionary<T>instead ofConcurrentBag<T>andConcurrentDictionary<T> - Random Number Generation - Static instances instead of
ThreadLocal<T> - Reflection Caches - Non-concurrent dictionaries for faster lookups
- Thread Pools - SingleThreadedThreadPool disabled (not needed on WebGL)
How to enable:
Unity automatically defines UNITY_WEBGL for WebGL builds. To enable SINGLE_THREADED optimization:
- Go to Project Settings > Player > Other Settings > Scripting Define Symbols
- Add
SINGLE_THREADEDfor WebGL platform - Or use in your
csc.rspfile:-define:SINGLE_THREADED
Performance impact: 10-20% faster hot path operations on single-threaded platforms by avoiding unnecessary synchronization overhead.
IL2CPP and Code Stripping Considerations¶
โ ๏ธ Important for IL2CPP builds (WebGL, Mobile, Consoles):
Some features in Unity Helpers use reflection internally (particularly Protobuf serialization and ReflectionHelpers). IL2CPP's managed code stripping may remove types/members that are only accessed via reflection, causing runtime errors.
Symptoms of stripping issues:
NullReferenceExceptionorTypeLoadExceptionduring deserialization- Missing fields after Protobuf deserialization
- Reflection helpers failing to find types at runtime
Solution: Use link.xml to preserve required types¶
Create a link.xml file in your Assets folder to prevent stripping:
Best practices:
- โ Always test IL2CPP builds - Development builds don't use stripping, so bugs only appear in release builds
- โ Test on target platform - WebGL stripping behaves differently than iOS/Android
- โ
Use link.xml for all Protobuf types - Any type with
[ProtoContract]should be preserved - โ Verify after every schema change - Adding new serialized types requires updating link.xml
- โ Check logs for stripping warnings - Unity logs which types are stripped during build
When you don't need link.xml:
- JSON serialization (uses source-generated converters, not reflection)
- Spatial trees and data structures (no reflection used)
- Most helper methods (compiled ahead-of-time)
Related documentation:
- Unity Manual: Managed Code Stripping
- Protobuf-net and IL2CPP
- Serialization Guide: IL2CPP Warning
- Reflection Helpers: IL2CPP Warning
Quick Start Guide¶
๐ก First time? Skip to section #2 (Relational Components) - it has the biggest immediate impact.
Already read the Top 5 Time-Savers? Jump directly to the Core Features reference below, or check out the Getting Started Guide.
Core Features¶
Random Number Generators¶
Unity Helpers includes 15 high-quality random number generators, all implementing a rich IRandom interface:
Available Generators¶
The tables below are auto-generated by the performance benchmark. Run
RandomPerformanceTests.Benchmarkin the Unity Test Runner to refresh them.
No benchmark data available yet. Run RandomPerformanceTests.Benchmark to populate these tables.
Rich API¶
All generators implement IRandom with the following functionality:
Deterministic Gameplay¶
All generators are seedable for replay systems:
| C# | |
|---|---|
Threading:
- Do not share a single RNG instance across threads.
- Use
PRNG.Instancefor a thread-local default, or use each generator'sTypeName.Instance(e.g.,IllusionFlow.Instance,PcgRandom.Instance). - Alternatively, create one separate instance per thread.
Spatial Trees¶
Efficient spatial data structures for 2D and 3D games.
2D Spatial Trees¶
- QuadTree2D - Best general-purpose choice
- KDTree2D - Fast nearest-neighbor queries
- RTree2D - Optimized for bounding boxes
3D Spatial Trees¶
Note: KdTree3D, OctTree3D, and RTree3D are under active development. SpatialHash3D is stable and productionโready.
- OctTree3D - Best general-purpose choice for 3D
- KDTree3D - Fast 3D nearest-neighbor queries
- RTree3D - Optimized for 3D bounding volumes
- SpatialHash3D - Efficient for uniformly distributed moving objects (stable)
| C# | |
|---|---|
When to Use Spatial Trees¶
โ Good for:
- Many objects (100+)
- Frequent spatial queries
- Static or slowly changing data
- AI awareness systems
- Visibility culling
- Collision detection optimization
โ Not ideal for:
- Few objects (<50)
- Constantly moving objects
- Single queries
- Already using Unity's physics system
๐ 2D Benchmarks | ๐ 3D Benchmarks
For behavior details and edge cases, see: Spatial Tree Semantics
Relational Components¶
Auto-wire components using attributes to reduce GetComponent boilerplate.
Key attributes:
[SiblingComponent]- Find components on same GameObject[ParentComponent]- Find components in parent hierarchy[ChildComponent]- Find components in children[ValidateAssignment]- Validate at edit time, show errors in inspector[WNotNull]- Must be assigned in inspector[WReadOnly]- Read-only display in inspector[WInLineEditor]- Inline inspector editing for object references[WShowIf]- Conditional display based on field values
Quick example:
See the in-depth guide: Relational Components. Performance snapshots: Relational Component Performance Benchmarks.
Effects, Attributes, and Tags¶
Create data-driven gameplay effects that modify stats, apply tags, and drive cosmetics.
Key pieces:
AttributeEffectโ ScriptableObject that bundles stat changes, tags, cosmetics, and duration.EffectHandleโ Unique ID for one application instance; remove/refresh specific stacks.AttributesComponentโ Base class for components that expose modifiableAttributefields.TagHandlerโ Counts and queries string tags for gating gameplay (e.g., "Stunned").CosmeticEffectDataโ Prefab-like container of behaviors shown while an effect is active.
Quick example:
Details at a glance:
ModifierDurationType.Instantโ applies permanently; returns null handle.ModifierDurationType.Durationโ temporary; expires automatically; reapply can reset if enabled.ModifierDurationType.Infiniteโ persists untilRemoveEffect(handle)is called.AttributeModificationorder: Addition โ Multiplication โ Override.CosmeticEffectData.RequiresInstancingโ instance per application or reuse shared presenters.
Power Pattern: Tags aren't just for buffsโuse them to build capability systems for invulnerability, AI decision-making, permission gates, state management, and elemental interactions. See Advanced Scenarios for patterns.
Further reading: see the full guide Effects System.
Serialization¶
Fast, compact serialization for save systems, config, and networking.
This package provides three serialization technologies:
Jsonโ Uses System.Text.Json with builtโin converters for Unity types.Protobufโ Uses protobuf-net for compact, fast, schemaโevolvable binary.SystemBinaryโ Uses .NET BinaryFormatter for legacy/ephemeral data only.
All are exposed via WallstopStudios.UnityHelpers.Core.Serialization.Serializer.
JSON Profiles¶
- Normal โ default settings (case-insensitive, includes fields, comments/trailing commas allowed)
- Pretty โ human-friendly, indented
- Fast โ strict, minimal with Unity converters (case-sensitive, strict numbers, no comments/trailing commas, IncludeFields=false)
- FastPOCO โ strict, minimal, no Unity converters; best for pure POCO graphs
When To Use What¶
- Use Json for:
- Player or tool settings, humanโreadable saves, serverless workflows.
- Interop with tooling, debugging, or versioning in Git.
- Use Protobuf for:
- Network payloads, large save files, bandwidth/storageโsensitive data.
- Situations where you expect schema evolution across versions.
- Use SystemBinary only for:
- Transient caches in trusted environments where data and code version match.
- Never for untrusted data or longโterm persistence.
JSON Example¶
Protobuf Example¶
Notes:
- Protobufโnet requires stable field numbers. Annotate with
[ProtoMember(n)]and never reuse or renumber. - Unity types supported via surrogates: Vector⅔, Vector2Int/3Int, Quaternion, Color/Color32, Rect/RectInt, Bounds/BoundsInt, Resolution.
Features:
- Custom converters for Unity types (Vector⅔/4, Color, GameObject, Matrix4x4, Type)
- Protobuf (protobufโnet) support for compact binary
- LZMA compression utilities (see
Runtime/Utils/LZMA.cs) - Typeโsafe serialization and pooled buffers/writers to reduce GC
Data Structures¶
Additional high-performance data structures:
| Structure | Use Case |
|---|---|
| CyclicBuffer | Ring buffer, sliding windows |
| BitSet | Compact boolean storage |
| ImmutableBitSet | Read-only bit flags |
| Heap | Priority queue operations |
| PriorityQueue | Event scheduling |
| Deque | Double-ended queue |
| DisjointSet | Union-find operations |
| Trie | String prefix trees |
| SparseSet | Fast add/remove with iteration |
| TimedCache | Auto-expiring cache |
Core Math & Extensions¶
Numeric helpers, geometry primitives, Unity extensions, colors, collections, strings, directions.
See the guide: Core Math & Extensions.
At a Glance¶
PositiveMod,WrappedAddโ Safe cyclic arithmetic for indices/angles.LineHelper.Simplifyโ Reduce polyline vertices with DouglasโPeucker.Line2D.Intersectsโ 2D segment intersection and closest-point helpers.RectTransform.GetWorldRectโ Axis-aligned world bounds for rotated UI.Camera.OrthographicBoundsโ Compute visible world bounds for ortho cameras.Color.GetAverageColorโ LAB/HSV/Weighted/Dominant color averaging.IEnumerable.Infiniteโ Cycle sequences without extra allocations.StringExtensions.LevenshteinDistanceโ Edit distance for fuzzy matching.
Singleton Utilities (ODINโcompatible)¶
RuntimeSingleton<T>โ Global component singleton with optional crossโscene persistence.ScriptableObjectSingleton<T>โ Global settings/data singleton loaded fromResources/, autoโcreated by the editor tool.
See the guide: Singleton Utilities and the tool: ScriptableObject Singleton Creator.
Editor Tools¶
Unity Helpers includes 20+ editor tools to streamline your workflow:
- Sprite Tools: Cropper, Atlas Generator, Animation Editor, Pivot Adjuster
- Texture Tools: Blur, Resize, Settings Applier, Fit Texture Size
- Animation Tools: Event Editor, Creator, Copier, Sheet Animation Creator
- Validation: Prefab Checker with validation rules
- Automation: ScriptableObject Singleton Creator, Attribute Cache Generator
- Compilation: Request a manual script compilation via
Tools > Wallstop Studios > Unity Helpers > Request Script Compilationor use the default shortcut (Ctrl/Cmd + Alt + R) registered with Unityโs Shortcut Manager (listed under Wallstop / Request Script Compilation). The shortcut now forces anAssetDatabase.Refreshbefore requesting compilation and logs whenever Unity is already compiling, so scripts added outside the editor are imported even while Unity is unfocused.
๐ Complete Editor Tools Documentation
Quick Access:
- Menu:
Tools > Wallstop Studios > Unity Helpers - Create Assets:
Assets > Create > Wallstop Studios > Unity Helpers
Buffering Pattern¶
Object Pooling¶
Zero-allocation queries with automatic cleanup and thread-safe pooling.
Do / Don'ts:
- Do reuse buffers per system or component.
- Do treat buffers as temporary scratch space (APIs clear them first).
- Don't keep references to pooled lists beyond their lease lifetime.
- Don't share the same buffer across overlapping async/coroutine work.
Pooling utilities¶
Buffers<T>โ pooled collections (List/Stack/Queue/HashSet) withPooledResourceleases.- Lists:
using var lease = Buffers<Foo>.List.Get(out List<Foo> list); - Stacks:
using var lease = Buffers<Foo>.Stack.Get(out Stack<Foo> stack); - HashSets:
using var lease = Buffers<Foo>.HashSet.Get(out HashSet<Foo> set); -
Pattern: acquire โ use โ Dispose (returns to pool, clears collection).
-
WallstopArrayPool<T>โ rent arrays by length with automatic return on dispose. - Example:
using var lease = WallstopArrayPool<int>.Get(1024, out int[] buffer); -
Use for temporary processing buffers, sorting, or interop with APIs that require arrays.
-
WallstopFastArrayPool<T>โ fast array pool specialized for frequent shortโlived arrays (requiresT : unmanaged), does not clear arrays. Returned arrays may have previous content in them. - Example:
using var lease = WallstopFastArrayPool<int>.Get(count, out int[] buffer); - Used throughout Helpers for highโfrequency editor/runtime operations (e.g., asset searches).
How pooling + buffering help APIs:
- Spatial queries: pass a reusable
List<T>toGetElementsInRange/GetElementsInBoundsand iterate results without allocations. - Component queries:
GetComponents(buffer)clears and fills your buffer instead of allocating arrays. - Editor utilities: temporary arrays/lists from pools keep import/scan tools snappy, especially inside loops.
Dependency Injection Integrations¶
Auto-detected packages:
- Zenject/Extenject:
com.extenject.zenject,com.modesttree.zenject,com.svermeulen.extenject - VContainer:
jp.cysharp.vcontainer,jp.hadashikick.vcontainer - Reflex:
com.gustavopsantos.reflex
Manual or source imports (no UPM):
- Add scripting defines in
Project Settings > Player > Other Settings > Scripting Define Symbols: ZENJECT_PRESENTwhen Zenject/Extenject is presentVCONTAINER_PRESENTwhen VContainer is presentREFLEX_PRESENTwhen Reflex is present- Add the define per target platform (e.g., Standalone, Android, iOS).
Notes:
- When the define is present, optional assemblies under
Runtime/Integrations/*compile automatically and expose helpers likeRelationalComponentsInstaller(Zenject/Reflex) andRegisterRelationalComponents()(VContainer). - If you use UPM, no manual defines are required โ the package IDs above trigger symbols via
versionDefinesin the asmdefs. - For test scenarios without LifetimeScope (VContainer), SceneContext (Zenject), or SceneScope (Reflex), see DI Integrations: Testing and Edge Cases for stepโbyโstep patterns.
Quick start:
- VContainer: in your
LifetimeScope.Configure, callbuilder.RegisterRelationalComponents(). - Zenject/Extenject: add
RelationalComponentsInstallerto yourSceneContext(toggle scene scan if desired). - Reflex: place
RelationalComponentsInstalleron the same GameObject as yourSceneScopeto bind the assigner, run the scene scan, and (optionally) listen for additive scenes. Usecontainer.InjectWithRelations(...)/InstantiateGameObjectWithRelations(...)for DI-friendly hydration.
See the full guide with scenarios, troubleshooting, and testing patterns: Relational Components Guide
Additional Helpers¶
- VContainer:
resolver.InjectWithRelations(component)โ inject + assign a single instanceresolver.InstantiateComponentWithRelations(prefab, parent)โ instantiate + inject + assignresolver.InjectGameObjectWithRelations(root, includeInactiveChildren)โ inject hierarchy + assign-
resolver.InstantiateGameObjectWithRelations(prefab, parent)โ instantiate GO + inject + assign -
Zenject:
container.InjectWithRelations(component)โ inject + assign a single instancecontainer.InstantiateComponentWithRelations(prefab, parent)โ instantiate + assigncontainer.InjectGameObjectWithRelations(root, includeInactiveChildren)โ inject hierarchy + assign-
container.InstantiateGameObjectWithRelations(prefab, parent)โ instantiate GO + inject + assign -
Reflex:
container.InjectWithRelations(component)โ inject + assign a single instancecontainer.InstantiateComponentWithRelations(prefab, parent)โ instantiate + inject + assigncontainer.InjectGameObjectWithRelations(root, includeInactiveChildren)โ inject hierarchy + assigncontainer.InstantiateGameObjectWithRelations(prefab, parent)โ instantiate GO + inject + assign
Additive Scene Loads¶
- VContainer:
RegisterRelationalComponents(..., enableAdditiveSceneListener: true)registers a listener that hydrates components in newly loaded scenes. - Zenject:
RelationalComponentsInstallerexposes a toggle "Listen For Additive Scenes" to register the same behavior. - Reflex:
RelationalComponentsInstallerexposes a toggle "Listen For Additive Scenes" to register the same behavior. - Only the newly loaded scene is processed; other loaded scenes are not reโscanned.
Performance Options¶
- One-time scene scan runs after container build; additive scenes are handled incrementally.
- Single-pass scan (default) reduces
FindObjectsOfTypecalls by scanning once and checking type ancestry. - VContainer:
new RelationalSceneAssignmentOptions(includeInactive: true, useSinglePassScan: true) - Zenject:
new RelationalSceneAssignmentOptions(includeInactive: true, useSinglePassScan: true) - Reflex:
new RelationalSceneAssignmentOptions(includeInactive: true, useSinglePassScan: true) - Per-object paths (instantiate/inject helpers, pools) avoid global scans entirely for objects created via DI.
Performance¶
Unity Helpers is built with performance as a top priority:
Random Number Generation:
- 10-15x faster than Unity.Random in benchmarks (655-885M ops/sec vs 65-85M ops/sec)
- Zero GC pressure with thread-local instances
- ๐ Full Random Performance Benchmarks
Spatial Queries:
- O(log n) tree queries vs O(n) linear search
- Significant speedup for large datasets (QuadTree2D example: 10,000 objects = ~13 checks vs 10,000 checks)
- See benchmarks for detailed performance comparisons
- ๐ 2D Performance Benchmarks
- ๐ 3D Performance Benchmarks
Memory Management:
- Zero-allocation buffering pattern reduces GC spikes
- Object pooling for List, HashSet, Stack, Queue, Arrays
- 5-10 FPS improvement in complex scenes from stable GC
Reflection:
- Cached delegates are 10โ100x faster than raw
System.Reflection(method invocations ~12x; boxed scenarios up to 100x) - Safe for IL2CPP and AOT platforms; capability overrides (
ReflectionHelpers.OverrideReflectionCapabilities) let tests force expression/IL fallbacks - Run the benchmarks via ReflectionPerformanceTests.Benchmark (EditMode Test Runner) and commit the updated markdown section
- ๐ Reflection Helpers Guide and ๐ Benchmarks
List Sorting:
- Multiple adaptive algorithms (
Ghost,Meteor,Power,Grail,Pattern-Defeating QuickSort,Insertion,Tim,Jesse,Green,Ska,Ipn,Smooth,Block,IPS4o,Power+,Glide,Flux) tuned forIList<T> - Deterministic datasets (sorted, nearly sorted, shuffled) across sizes from 100 to 1,000,000
- ๐ IList Sorting Performance Benchmarks
Documentation Index¶
Start Here:
- ๐ Getting Started โ Getting Started Guide
- ๐ Feature Index โ Complete A-Z Index
- ๐ Glossary โ Term Definitions
Core Guides:
- Odin Migration Guide โ Migrate from Odin Inspector
- Serialization Guide โ Serialization
- Editor Tools Guide โ Editor Tools
- Math & Extensions โ Core Math & Extensions
- Singletons โ Singleton Utilities
- Relational Components โ Relational Components
- Effects System โ Effects System
- Data Structures โ Data Structures
Spatial Trees:
- 2D Spatial Trees Guide โ 2D Spatial Trees Guide
- 3D Spatial Trees Guide โ 3D Spatial Trees Guide
- Spatial Tree Semantics โ Spatial Tree Semantics
- Spatial Tree 2D Performance โ Spatial Tree 2D Performance
- Spatial Tree 3D Performance โ Spatial Tree 3D Performance
- Hulls (Convex vs Concave) โ Hulls
Performance & Reference:
- Reflection Performance Guide โ Reflection Benchmarks
- Reflection AOT/Burst Validation โ IL2CPP & Burst Validation
- Reflection Benchmark Workflow โ Benchmarking & Verification
- Random Performance โ Random Performance
- Reflection Helpers โ Reflection Helpers
- IList Sorting Performance โ IList Sorting Performance
Project Info:
- Changelog โ Changelog
- License โ License
- ThirdโParty Notices โ ThirdโParty Notices
- Contributing โ Contributing
- llms.txt โ LLM-Friendly Documentation | llms.txt
Contributing¶
Contributions are welcome! Please feel free to submit a Pull Request.
Formatting Assistance¶
- Dependabot PRs: Formatting fixes (CSharpier + Prettier + markdownlint) are applied automatically by CI.
- Contributor PRs: Opt-in formatting is available.
- Comment on the PR with
/format(aliases:/autofix,/lint-fix).- If the PR branch is in this repo, the bot pushes a commit with fixes.
- If the PR is from a fork, the bot opens a formatting PR targeting the base branch.
- The commenter must be the PR author or a maintainer/collaborator.
- Or run the Actions workflow manually: Actions โ "Opt-in Formatting" โ Run workflow โ enter the PR number.
- Not everything is auto-fixable: link checks and YAML linting may still require manual changes.
See more details in CONTRIBUTING.
License¶
This project is licensed under the MIT License - see the LICENSE file for details.
2.0 Release Notes (Highlights)¶
- BinaryFormatter deprecated, still functional for trusted/legacy data:
-
SerializationType.SystemBinaryis[Obsolete]. UseSerializationType.Json(System.Text.Json + Unity converters) orSerializationType.Protobuf(protobuf-net) for new work. Keep BinaryFormatter for trusted, nonโportable data only. -
GameObject JSON converter outputs structured JSON:
-
GameObjectConverternow writes a JSON object withname,type(assembly-qualified), andinstanceIdrather than a stringified placeholder. -
Minor robustness improvements:
- Guarded stray
UnityEditorimports in runtime files to ensure clean player builds.
See Serialization guide for AOT/IL2CPP guidance and Unity JSON options, and Editor tools guide for Editor tool usage details.