Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dasannikov/vault
Native data arrays for Unity3D with zero C# allocations
https://github.com/dasannikov/vault
c collections csharp datastructures game game-development unity unity3d
Last synced: 3 months ago
JSON representation
Native data arrays for Unity3D with zero C# allocations
- Host: GitHub
- URL: https://github.com/dasannikov/vault
- Owner: dasannikov
- License: mit
- Created: 2020-02-10T18:14:07.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-22T08:52:14.000Z (about 2 years ago)
- Last Synced: 2024-11-02T14:33:30.662Z (3 months ago)
- Topics: c, collections, csharp, datastructures, game, game-development, unity, unity3d
- Language: C#
- Homepage:
- Size: 193 KB
- Stars: 19
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Vault Libray for Unity3D
**DOWNLOAD:** [Latest build (Unity package)](https://github.com/dasannikov/Vault/releases)
`Vault.List` - Continuous data array with dynamic size similar to C++ `std::vector` or C# `List`. It uses an optimized native array implemented on `C` that is even faster than STL C++ containers (apporix. 10% faster) and has zero C# memory allocations.
## Supported platforms:
- Standalone Mono. Windows/MacOS/Linux
- Standalone IL2CPP. Windows/MacOS/Linux
- Mobile. iOS/Android
- Other through IL2CPP or specific shared libraries## Advantages:
- Doesn't use any Unity3D features. Can work with any C# code
- Continuous data array with dynamic size
- Fast and small prebuild native libraries
- No C# memory allocations and C# GC
- You manage your memory (`Free` means deleting container and releasing memory)## Usage
`Vault.List` is a continuous container with dynamic size. Similar to C++ `std::vector` or C# `List` or Unity's `NativeList````csharp
// New list with default initializer
// Vault.List is a struct. Zero allocations in C# memory
var vecArr = new Vault.List(10, new Vector2(1.0f, 1.0f));// Set element value
vecArr[9] = new Vector2(101f, 102f);
vecArr[0] = new Vector2(101f, 102f);// Resize list
vecArr.Resize(14);// Add element to list.
vecArr.Add(new Vector2(21f, 22f));// Fast remove element by swap with last element
vecArr.RemoveBySwap(1);// Relatively slow remove element by memmove
vecArr.Remove(1);// Swap elements
vecArr.Swap(0, 1);// Clear list
vecArr.Clear();// Free list after use
// Completely release unmanaged memory
vecArr.Free();```
## Performance
Performance (IL2CPP Builds) is similar (±10%) to Unit's `NativeList`