How to enable unsafe and use pointers

I am trying to use some pointers in my code. And i get this error in monodevelop:

Parse error: unsafe code requires the ‘unsafe’ command line option to be specified

I strongly recommend to not use pointers and unsafe code at all. Keep in mind that some platforms don’t support unsafe code for safety such as the webplayer for example.

If you really need an unsafe context, you have to create a “smcs.rsp” file in your asset folder and add the line

-unsafe

to that file. This should add this parameter to the c# compiler options when compiling your project.

Again, using unsafe doesn’t give you much advantages, it just opens up for a huge variety of errors, mistakes and unexpected behaviour. Unless you know exactly what you do and you use pointers sparsely you shouldn’t go for an unsafe context.

New answer

(tested in 2020.2)

You can go to Project Settings → Player and at the bottom under “Script Compliation” there is a checkbox for “Allow ‘unsafe’ Code”

In BuildSetting ,you should changes to the “Api Compatibility Level” to" .NET 2.0 Subset" yet.