我想在c#中使用c ++代码来使用CLR进行统一.
该程序在统一之外正常工作,但在引擎内部它给我一个错误:
"cs0227:不安全的代码需要指定'unsafe'命令行选项"
我真的很困惑,因为该项目在visual studio中成功构建(没有任何错误或警告).我已激活" 允许 不安全 "按钮.
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class newspawn_real : MonoBehaviour {
void Start () {
unsafe
{
fixed (int * p = &bam[0, 0, 0])
{
CppWrapper.CppWrapperClass controlCpp = new CppWrapper.CppWrapperClass();
controlCpp.allocate_both();
controlCpp.fill_both();
controlCpp.fill_wrapper();
}
Run Code Online (Sandbox Code Playgroud)