Publisher | santutu |
---|---|
File size | 25.39kB |
Number of files | 16 |
Latest version | 2 |
Latest release date | 2025-01-20 08:17:58 |
First release date | 2025-01-14 05:09:12 |
Supported Unity versions | 2018.4.2 or higher |
Background
1. Why should we pay attention to trivial matters? When using Physics.NonAlloc, determining the size of the array is usually unnecessary.
If the number of detected colliders exceeds the size of the array, the DynamicArray will automatically resize the array.
2. When executing Physics.NonAlloc method, the number of detected colliders and the actual colliders are handled separately as an int and an array[], making it inconvenient to use.
A DynamicArray instance holding this information would be more convenient to use.
3. For concise code.
using var result = DPhysics.OverlapSphereNonAllocFromPool(transform.position, 3);
foreach (var collider in result)
{
Debug.Log(collider.name);
}
Use Case
1. automatic resizing
2. foreach loop
3. for loop
4. passing the detected collider array as a parameter
The detected colliders and their count can be accessed from anywhere using dynamicarray
5. from pool of dynamic array
6. shorthand
Readme.md
https://github.com/santutu/unity-dynamic-array/blob/main/README.md
Sample