-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathllms.txt
More file actions
296 lines (220 loc) · 15.8 KB
/
llms.txt
File metadata and controls
296 lines (220 loc) · 15.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# Unity Helpers
> Unity Helpers is a comprehensive Unity package (2021.3+) providing production-ready utilities that reduce boilerplate and improve runtime performance:
>
> - Professional inspector tooling, spatial data structures, PRNGs, serialization utilities
> - Effects systems, relational components, and 20+ editor tools
> - 11,000+ tests, IL2CPP/WebGL compatible, shipped in commercial games
## Key Information
- **Package Name**: `com.wallstop-studios.unity-helpers`
- **Version**: 3.0.4
- **Unity Version**: 2021.3+ (LTS)
- **License**: MIT
- **Repository**: https://github.com/wallstop/unity-helpers
- **Root Namespace**: `WallstopStudios.UnityHelpers`
### Important Implementation Notes
- Use **explicit types** instead of `var` in all code
- Use **PascalCase** for all method names (no underscores, even in tests)
- Never use `#region` directives
- Never use nullable reference types (`?` annotations like `string?`)
- Never use `?.`, `??`, `??=` on `UnityEngine.Object` types (use explicit null checks instead)
- Place `using` directives inside namespace blocks
- Unity Object null checks: use `thing != null` / `thing == null` directly (Unity's Object equality)
- For tests: use `[Test]` for synchronous tests, `[UnityTest]` with `IEnumerator` for async (NOT `async Task`)
- One file per MonoBehaviour/ScriptableObject (production AND tests)
### Assembly Structure
| Assembly | Purpose |
|----------|---------|
| `WallstopStudios.UnityHelpers` | Runtime code |
| `WallstopStudios.UnityHelpers.Editor` | Editor code |
| `WallstopStudios.UnityHelpers.Tests.Runtime` | Runtime tests |
| `WallstopStudios.UnityHelpers.Tests.Editor` | Editor tests |
| `WallstopStudios.UnityHelpers.Tests.Core` | Shared test utilities |
## Core Features
### Inspector Tooling (Odin-like, FREE)
Professional inspector attributes eliminating custom PropertyDrawer code:
- `[WGroup]` / `[WGroupEnd]` - Boxed sections with collapsible headers, color themes, animations
- `[WButton]` - Method buttons with async support, cancellation, history, groupPriority, groupPlacement
- `[WShowIf]` - Conditional visibility (9 comparison operators)
- `[WEnumToggleButtons]` - Flag enums as visual toggle grids
- `[WReadOnly]` - Read-only inspector display
- `[WInLineEditor]` - Inline nested editor for object references
- `[WNotNull]` - Validation for required fields (shows error/warning HelpBox in inspector with customizable MessageType and CustomMessage)
- `[ValidateAssignment]` - Runtime assignment validation (shows error/warning HelpBox for null, empty string, or empty collections)
- `[StringInList]` - Dropdown selection from string lists, methods (`nameof(Method)`), or static methods
- `[WValueDropDown]` - Value dropdown selection
- `[WSerializableCollectionFoldout]` - Custom foldout behavior for serializable collections
- `[IntDropDown]` - Integer dropdown selection
- `[EnumDisplayName]` - Custom display names for enum values
- `[DetectAssetChanged]` - Monitor asset changes and execute methods when assets are created/deleted
### Relational Components (Auto-Wiring)
Reduce GetComponent boilerplate with hierarchy-aware attributes:
```csharp
[SiblingComponent] private Animator animator; // Same GameObject
[ParentComponent] private Rigidbody2D rb; // Parent hierarchy
[ChildComponent] private Collider2D[] colliders; // Children
[ChildComponent(MaxDepth = 1)] private Weapon[] weapons; // Direct children only
```
Call `this.AssignRelationalComponents()` in Awake to wire all references.
### Serializable Collections
Unity-serializable data structures with custom inspector drawers:
- `SerializableDictionary<TKey, TValue>` - Dictionary with full inspector support
- `SerializableSortedDictionary<TKey, TValue>` - Ordered dictionary
- `SerializableHashSet<T>` - HashSet with duplicate detection
- `SerializableSortedSet<T>` - Sorted set for `IComparable<T>` elements
- `SerializableNullable<T>` - Nullable value types in inspector
- `SerializableType` - Type references in inspector
- `WGuid` - Serializable GUID
All collections support pagination, inline nested editors, undo/redo, and confirmation dialogs when clearing.
### Spatial Data Structures
O(log n) spatial queries for 2D and 3D:
**2D Trees**: `QuadTree2D<T>`, `KdTree2D<T>`, `RTree2D<T>`, `SpatialHash2D<T>`
**3D Trees**: `OctTree3D<T>`, `KdTree3D<T>`, `RTree3D<T>`, `SpatialHash3D<T>`
```csharp
QuadTree2D<Enemy> tree = new(enemies, e => e.transform.position);
tree.GetElementsInRange(playerPos, radius: 10f, resultsBuffer);
tree.GetElementsInBounds(bounds, resultsBuffer);
tree.GetApproximateNearestNeighbors(position, count: 5, resultsBuffer);
```
### Random Number Generators
15+ high-quality PRNGs (10-15x faster than Unity.Random in benchmarks):
- `PRNG.Instance` - Thread-local default (IllusionFlow)
- `IllusionFlow`, `PcgRandom`, `XorShiftRandom`, `XoroShiroRandom`, `SplitMix64`, `RomuDuo`, `WyRandom`
- `BlastCircuitRandom`, `WaveSplatRandom`, `FlurryBurstRandom`, `PhotonSpinRandom`, `StormDropRandom`, `SquirrelRandom`
- `LinearCongruentialGenerator`, `DotNetRandom`, `SystemRandom`, `UnityRandom` (wrappers)
- `NativePcgRandom` - Burst/Jobs compatible
- All implement `IRandom` with extensive API: `NextFloat()`, `NextVector2()`, `NextGaussian()`, `NextWeightedIndex()`, `Shuffle()`, `NextGuid()`
- `PerlinNoise` - Coherent noise generation
All generators are seedable for deterministic replay systems. Use `RandomGeneratorMetadata` to inspect generator properties.
### Effects System
Data-driven buffs/debuffs using ScriptableObjects:
- `AttributeEffect` - ScriptableObject defining stat modifications, tags, cosmetics, duration
- `AttributesComponent` - Base class exposing `Attribute` fields
- `TagHandler` - Reference-counted tag queries ("Stunned", "Invulnerable")
- `EffectHandle` - Unique ID for tracking/removing specific effect instances
```csharp
EffectHandle? handle = player.ApplyEffect(hasteEffect);
if (player.HasTag("Stunned")) return;
player.RemoveEffect(handle.Value);
```
### Serialization
JSON and Protobuf serialization with Unity type support:
```csharp
// JSON (System.Text.Json with Unity converters)
byte[] json = Serializer.JsonSerialize(data);
SaveData loaded = Serializer.JsonDeserialize<SaveData>(jsonText);
// Protobuf (protobuf-net, compact binary)
byte[] proto = Serializer.ProtoSerialize(message);
Message decoded = Serializer.ProtoDeserialize<Message>(proto);
```
Supported Unity types: Vector2/3/4, Color, Quaternion, Rect, Bounds, GameObject references.
### Pooling & Buffering
Zero-allocation patterns for hot paths:
```csharp
// Collection pooling (List, HashSet, etc.)
using var lease = Buffers<Enemy>.List.Get(out List<Enemy> buffer);
tree.GetElementsInRange(position, radius, buffer);
// buffer automatically returned to pool on dispose
// Variable-size array pooling (preferred for dynamic sizes)
using PooledArray<float> pooled = SystemArrayPool<float>.Get(size, out float[] arr);
// IMPORTANT: Use pooled.Length, not arr.Length (arr may be larger than requested)
// Exact-size array pooling (for fixed, known sizes only)
using var arrayLease = WallstopArrayPool<float>.Get(size, out float[] arr);
```
### Threading & Main Thread Dispatch
Thread-safe utilities for Unity's main thread requirement:
- `UnityMainThreadDispatcher` - Execute code on Unity's main thread from any thread
- `UnityMainThreadGuard` (internal) - Ensure operations run on the main thread
- Thread pool utilities for background work
### Editor Tools
20+ automation tools accessible via `Tools > Wallstop Studios > Unity Helpers`:
- **Sprite Tools**: Cropper, Atlas Generator, Pivot Adjuster
- **Animation Tools**: Event Editor, Creator, Copier, Sheet Animation Creator
- **Texture Tools**: Blur, Resize, Settings Applier, Fit Texture Size
- **Validation**: Prefab Checker with comprehensive validation rules
- **Analysis**: Unity Method Analyzer for detecting inheritance issues and lifecycle method errors
- **Utilities**: ScriptableObject Singleton Creator, Request Script Compilation (Ctrl/Cmd+Alt+R)
- **Project Settings**: Configure coroutine wait buffer defaults under `Project Settings > Wallstop Studios > Unity Helpers`
### Data Structures
Additional high-performance structures:
- `CyclicBuffer<T>` - Ring buffer
- `Heap<T>` / `PriorityQueue<T>` - Min/max heap
- `Deque<T>` - Double-ended queue
- `DisjointSet` - Union-find
- `Trie` - String prefix tree
- `SparseSet` - Fast add/remove with iteration
- `BitSet` / `ImmutableBitSet` - Compact boolean storage
- `TimedCache<T>` - Auto-expiring cache
### Geometry & Math
Geometric primitives and math utilities:
- `Circle`, `Sphere`, `BoundingBox3D` - Geometric primitives
- `WallMath` - Math utilities, ballistics, geometry calculations
- `Geometry` - Hull generation (convex/concave), point operations
- `LineHelper` - Line intersection, distance calculations
### Extension Methods
200+ extensions for Unity types, collections, strings, math:
- `transform.GetAncestors(buffer)` - Non-allocating hierarchy traversal
- `Camera.OrthographicBounds()` - Visible world bounds
- `color.GetAverageColor(ColorAveragingMethod.LAB)` - Perceptual color averaging
- `(-1).PositiveMod(length)` - Non-negative modulo
- `gameObject.SmartDestroy()` - Editor/runtime safe destruction
- `string.LevenshteinDistance()` - Edit distance for fuzzy matching
### Visual Components
UGUI and UI Toolkit visual components:
- `EnhancedImage` (UGUI) - Extended Image with HDR color support, improved material management
- `LayeredImage` (UI Toolkit) - Multi-layer visual element
- `AnimatedSpriteLayer` - Sprite animation layers
### Singletons
- `RuntimeSingleton<T>` - Component singleton with cross-scene persistence
- `ScriptableObjectSingleton<T>` - Settings singleton from Resources
- `[AutoLoadSingleton]` - Automatic singleton instantiation during Unity start-up phases
### DI Framework Integration
Automatic integration with VContainer, Zenject, and Reflex:
```csharp
// VContainer
builder.RegisterRelationalComponents();
// Zenject - add RelationalComponentsInstaller to SceneContext
// Reflex - add RelationalComponentsInstaller to SceneScope
```
## Docs
- [README - Main Documentation](https://github.com/wallstop/unity-helpers/blob/main/README.md): Complete feature overview with examples and installation instructions
- [Getting Started Guide](https://github.com/wallstop/unity-helpers/blob/main/docs/overview/getting-started.md): 5-minute quickstart covering top features
- [Feature Index](https://github.com/wallstop/unity-helpers/blob/main/docs/overview/index.md): Alphabetical A-Z index of all features with links
- [Glossary](https://github.com/wallstop/unity-helpers/blob/main/docs/overview/glossary.md): Term definitions for Unity Helpers concepts
## Feature Guides
- [Inspector Overview](https://github.com/wallstop/unity-helpers/blob/main/docs/features/inspector/inspector-overview.md): Complete guide to inspector attributes
- [Inspector Grouping (WGroup)](https://github.com/wallstop/unity-helpers/blob/main/docs/features/inspector/inspector-grouping-attributes.md): Visual property grouping with collapsible sections
- [Inspector Buttons (WButton)](https://github.com/wallstop/unity-helpers/blob/main/docs/features/inspector/inspector-button.md): Method execution buttons with async support
- [Inspector Conditional Display (WShowIf)](https://github.com/wallstop/unity-helpers/blob/main/docs/features/inspector/inspector-conditional-display.md): Conditional field visibility
- [Inspector Selection Attributes](https://github.com/wallstop/unity-helpers/blob/main/docs/features/inspector/inspector-selection-attributes.md): Enum toggle buttons, dropdowns, string lists
- [Relational Components](https://github.com/wallstop/unity-helpers/blob/main/docs/features/relational-components/relational-components.md): Auto-wiring component references
- [Effects System](https://github.com/wallstop/unity-helpers/blob/main/docs/features/effects/effects-system.md): Data-driven buffs/debuffs
- [Effects Tutorial](https://github.com/wallstop/unity-helpers/blob/main/docs/features/effects/effects-system-tutorial.md): 5-minute effects setup walkthrough
- [Serialization Guide](https://github.com/wallstop/unity-helpers/blob/main/docs/features/serialization/serialization.md): JSON and Protobuf serialization
- [Serialization Types](https://github.com/wallstop/unity-helpers/blob/main/docs/features/serialization/serialization-types.md): Serializable collections documentation
- [Editor Tools Guide](https://github.com/wallstop/unity-helpers/blob/main/docs/features/editor-tools/editor-tools-guide.md): 20+ editor automation tools
- [2D Spatial Trees](https://github.com/wallstop/unity-helpers/blob/main/docs/features/spatial/spatial-trees-2d-guide.md): QuadTree, KDTree, RTree usage
- [3D Spatial Trees](https://github.com/wallstop/unity-helpers/blob/main/docs/features/spatial/spatial-trees-3d-guide.md): OctTree, KDTree3D, RTree3D, SpatialHash3D
- [Spatial Tree Semantics](https://github.com/wallstop/unity-helpers/blob/main/docs/features/spatial/spatial-tree-semantics.md): Behavior details and edge cases
- [Hulls (Convex/Concave)](https://github.com/wallstop/unity-helpers/blob/main/docs/features/spatial/hulls.md): Hull generation algorithms
- [Data Structures](https://github.com/wallstop/unity-helpers/blob/main/docs/features/utilities/data-structures.md): Heaps, tries, deques, sparse sets
- [Math & Extensions](https://github.com/wallstop/unity-helpers/blob/main/docs/features/utilities/math-and-extensions.md): Numeric helpers, geometry, Unity extensions
- [Reflection Helpers](https://github.com/wallstop/unity-helpers/blob/main/docs/features/utilities/reflection-helpers.md): High-performance cached reflection
- [Singletons](https://github.com/wallstop/unity-helpers/blob/main/docs/features/utilities/singletons.md): Runtime and ScriptableObject singletons
- [Logging Extensions](https://github.com/wallstop/unity-helpers/blob/main/docs/features/logging/logging-extensions.md): Rich logging with tags and thread awareness
- [Unity Main Thread Dispatcher](https://github.com/wallstop/unity-helpers/blob/main/docs/features/logging/unity-main-thread-dispatcher.md): Thread-safe main thread execution
## Performance
- [Random Performance](https://github.com/wallstop/unity-helpers/blob/main/docs/performance/random-performance.md): PRNG benchmarks (10-15x faster than Unity.Random)
- [Spatial Tree 2D Performance](https://github.com/wallstop/unity-helpers/blob/main/docs/performance/spatial-tree-2d-performance.md): 2D tree benchmarks
- [Spatial Tree 3D Performance](https://github.com/wallstop/unity-helpers/blob/main/docs/performance/spatial-tree-3d-performance.md): 3D tree benchmarks
- [Reflection Performance](https://github.com/wallstop/unity-helpers/blob/main/docs/performance/reflection-performance.md): Cached reflection benchmarks (up to 100x faster in tested scenarios)
- [Relational Components Performance](https://github.com/wallstop/unity-helpers/blob/main/docs/performance/relational-components-performance.md): Component wiring benchmarks
- [IList Sorting Performance](https://github.com/wallstop/unity-helpers/blob/main/docs/performance/ilist-sorting-performance.md): Sorting algorithm benchmarks
## Project
- [Changelog](https://github.com/wallstop/unity-helpers/blob/main/CHANGELOG.md): Version history and release notes
- [Contributing](https://github.com/wallstop/unity-helpers/blob/main/docs/project/contributing.md): Contribution guidelines
- [License](https://github.com/wallstop/unity-helpers/blob/main/LICENSE): MIT License
- [Roadmap](https://github.com/wallstop/unity-helpers/blob/main/docs/overview/roadmap.md): Planned features and improvements
## Optional
- [LLM Instructions](https://github.com/wallstop/unity-helpers/blob/main/.llm/context.md): Comprehensive AI agent guidelines for working with this repository
- [Third-Party Notices](https://github.com/wallstop/unity-helpers/blob/main/docs/project/third-party-notices.md): Attribution for included libraries
- [Animation Event Editor](https://github.com/wallstop/unity-helpers/blob/main/docs/project/animation-event-editor.md): Detailed animation event editor documentation