- Home /
C++ dll plugin problem.
I just made C++ dll. when i read the dll in Unity, Unity crash down. Folloing is the steps.
tool: vs2008
step 1) vs2008 => new => Project ==> Visual C++ ==> CLR ==> Class Library projectname is clrtest.
step 2) clrtest.h
#pragma once #using <mscorlib.dll>
using namespace System;
namespace clrtest {
public ref class Class1
{
public:
int Add(int a, int b) { return a + b; };
};
}
step 3) compile ==> copy clrtest.dll into unity plugin folder.
step 4) in unity c# script
using UnityEngine; using System; using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices;
using clrtest;
public class mycowcontrol : MonoBehaviour {
void Start()
{
clrtest.Class1 temp = new clrtest.Class1();
int x = temp.Add(1, 2);
Debug.Log("1+2 = " + x);
}
}
step 5) execute and just down.
I don't know why the unity is down. is any problem my c++ dll making procedure?
please let me know if you have any idea. Any help would be much appreciated.
Please surround all your code using the "Code" button, or using the tags, to make it easier for other people to read.
Answer by SteveFSP · Jul 18, 2010 at 09:56 PM
See the answer to Considerations/Gotchas when Creating a C++ CLR Plugin in VS2008.