would you Re-implement this in a C DLL and have bindings for C# for improved performance? would you rewrite some classes to structs to avoid the class overhead in unity's il2cpp and to possible allow you to marshal.copy https://www.jacksondunstan.com/articles/3916