Running unsafe code on hololens

I got my dev environment set up and tested my Unity app on the hololens. Now I’m trying to use some of the assets from the holotoolkit and I can’t compile because there are a dozen scripts using functions like:

Which causes the compiler to throw errors

So I created a file called smcs.rsp and added the line -unsafe to it for the compiler, but the errors are still preventing me from building due to the unsafe flag.

Any ideas? Thanks

It may depend on the .Net API Compatibility Level setting you’re using. When using the full .Net 2.0 compatibility level, the file has to be named gmcs.rsp instead, according to this - How to enable unsafe and use pointers - Questions & Answers - Unity Discussions

You also have to allow unsafe code in the Visual Studio project. However, Unity tools for Visual Studio doesn’t allow you to access the project properties anymore since they get overwritten by Unity very often. You will need to edit the .csproj file of your project and set the AllowUnsafeBlocks occurrences to true whenever you want to run in the editor or create a build.