Unity3D Insecure Code Requires Specifying an “Insecure” Command Line Option

I use Unity3D 4.3 and call the DLL that I created. when trying to call a single function, which is:

 void GetModelReferences(int &nVertices, float * vertices, int &nTriangles, int * triangles, float * normals, float * uvCoordinates); 

gives me an error:

 Unsafe code requires the `unsafe' command line option to be specified 

so in my MonoDevelop I opened: Project->Assembly-Csharp options and turned on unsafe mode.

it reduces some errors, but this last one does not go away

 Unsafe code requires the `unsafe' command line option to be specified 

What am I doing?

+6
source share
4 answers

Go to the project properties page and select the Build check box in the Allow unsafe code field. This should solve your problem.

+11
source

Here is what worked for me with Unity3D 5.3:
- If in the Unity Build-> Player Setting-> Other Settings "API Compatibility Level" is ".Net 2.0", create a file in the Unity Asset folder with the name gmcs.rsp, add the following line to the file: <w>
this option Close Unity and open it again.
- If the "API Compatibility Level" is ".Net 2.0 Subset", the above file name should be: smcs.rsp.

See the figure below to find the location of the API Compatibility parameter in Unity.
enter image description here

+8
source

The answer is given here: http://answers.unity3d.com/questions/804103/how-to-enable-unsafe-and-use-pointers.html

You need to add the file "smcs.rsp" (or "gmcs.rsp") to the Assets directory, which contains the line:

 -unsafe 
+2
source

Have you tried this ?

look at the fifth comment

First, show the contents of Unity.App and go to Contents / Frameworks / MonoCompiler.framework.

Open a file called compile_any.pl and in the section "# Launch csharp compiler" change @Base_Args parameters as shown below:

my @base_args = ($ mono_path, $ mcs_path, '-debug', '-unsafe', '-target: library', '-nowarn: 0169', '-out:'. $ output,);

0
source

Source: https://habr.com/ru/post/971596/


All Articles