8000 GitHub - dasannikov/Vault: Native data arrays for Unity3D with zero C# allocations · GitHub
[go: up one dir, main page]

Skip to content
{"props":{"color_mode":"dark","logged_in":false,"marketing_page":false,"home_path":"/","login_path":"/login?return_to=https%3A%2F%2FGitHub.com%2Fdasannikov%2FVault","signup_path":"/signup?ref_cta=Sign+up\u0026ref_loc=header+logged+out\u0026ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E\u0026source=header-repo\u0026source_repo=dasannikov%2FVault","signup_enabled":true,"is_signup_controller":false,"show_search_and_nav":true,"hide_search":false,"private_mode_enabled":false,"should_use_dotcom_links":true,"auth_hydro_click":"{\"event_type\":\"authentication.click\",\"payload\":{\"location_in_page\":\"site header menu\",\"repository_id\":null,\"auth_type\":\"SIGN_UP\",\"originating_url\":\"https://GitHub.com/dasannikov/Vault\",\"user_id\":null}}","auth_hydro_click_hmac":"ffb94ef212c7cc0e66ea15a303377a91f84b5450f836e1df28f01b46f743a8c6"}}
dasannikovPublic

About

Native data arrays for Unity3D with zero C# allocations

Topics

Resources

Stars

19 stars

Watchers

2 watching

Forks

Latest commit

 

History

49 Commits

Folders and files

Repository files navigation

Vault Libray for Unity3D

DOWNLOAD: Latest build (Unity package)

Vault.List - Continuous data array with dynamic size similar to C++ std::vector<T> or C# List<T>. 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<T> or C# List<T> or Unity's NativeList<T>

// New list with default initializer
// Vault.List is a struct. Zero allocations in C# memory
var vecArr = new Vault.List<Vector2>(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<T>

About

Native data arrays for Unity3D with zero C# allocations

Topics

Resources

Stars

19 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages

0