Unity のサンプル プラグインのように char* を戻り値として使用したいのですが、単純な「Hello」の代わりに無効なマーキング (效汬o) が表示されます。何が間違っている可能性がありますか?
DLL:
extern "C"
{
const __declspec(dllexport) char* PrintHello()
{
return "Hello";
}
}
団結:
public class audiotest : MonoBehaviour
{
[DllImport("ASimplePlugin")]
private static extern IntPtr PrintHello();
void Start ()
{
Debug.Log(Marshal.PtrToStringAuto(PrintHello()));
}
}
Unity のサンプル プラグインはhttp://docs.unity3d.com/Documentation/Images/manual/SimplestPluginExample-4.0.zipにあります。
Unity 4.2.1f4 と Visual Studio 2010 を使用しています