CLR을 사용하여 단일성을 위해 C++에서 C++ 코드를 사용하고 싶습니다. 프로젝트가 Visual Studio에서 (오류 또는 경고없이) 성공적으로 빌드하기 때문에안전하지 않은 코드 사용 방법 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); ' –