私はCLRを使用して単一性のためにc#でC++コードを使用したいと思います。安全でないコードを使用する方法Unity
The program works properly outside of unity, but inside of engine it gives me an error:
"cs0227: unsafe code requires the 'unsafe' command line option to be specified"
私は本当に混乱しています。なぜなら、プロジェクトはビジュアルスタジオ(エラーや警告なし)で正常に構築されるからです。私は "安全でない"ボタンを有効にしました。
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();
}
不明な点がある場合は教えてください。 –
Unityはブラックボックスなので、コード変換時にどのC#機能がサポートされているのか分かりません。大まかな推測は危険なものではありません。 'Marshal'クラスメソッドの使用を検討しましたか? – Aybe
dllインポートを意味しますか? '[DllImport( "C++ unitshi.dll")]' static extern int add(int a、int b); ' –