问题描述
在使用OpenCV For Unity插件时报错 “Assets\OpenCVForUnity\Examples\Advanced\AlphaBlendingExample\AlphaBlendingExample.cs(530,17): error CS0227: Unsafe code may only appear if compiling with /unsafe. Enable “Allow ‘unsafe’ code” in the inspector for ‘Assets/OpenCVForUnity/EnoxSoftware.OpenCVForUnity.asmdef’ to fix this error.” 
解决方法
这里提供两种方式修改:
1.Tools入口修改
在窗口上侧的 Tools > OpenCV For Unity > 勾选Use Unsafe Code。 如下图: 
不过可能会没有该入口的情况,则使用方法2.
2.修改asmdef文件
.asmdef文件是程序集定义文件(Assembly Definition File),这个方法在报错提示中也有。 在Assets/OpenCVForUnity/EnoxSoftware.OpenCVForUnity.asmdef 路径下的文件进行修改,选中文件后,在Inspector窗口中勾选Allow ‘unsafe’ Code选项,Apply。

|