小编Dav*_*ili的帖子

如何使用不安全的代码Unity

我想在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)

c# c++ clr unsafe unity-game-engine

6
推荐指数
2
解决办法
1万
查看次数

标签 统计

c# ×1

c++ ×1

clr ×1

unity-game-engine ×1

unsafe ×1