Plugins 带有Unity插件的char*as函数返回值
我想使用char*作为返回值(就像Unity的示例插件中那样),但是我得到了一些无效的标记(效汬o) 而不是简单的“你好”。有什么想法吗 动态链接库: 团结:Plugins 带有Unity插件的char*as函数返回值,plugins,char,unity3d,Plugins,Char,Unity3d,我想使用char*作为返回值(就像Unity的示例插件中那样),但是我得到了一些无效的标记(效汬o) 而不是简单的“你好”。有什么想法吗 动态链接库: 团结: public class audiotest : MonoBehaviour { [DllImport("ASimplePlugin")] private static extern IntPtr PrintHello(); void Start () { Debug.Log(Marsh
public class audiotest : MonoBehaviour
{
[DllImport("ASimplePlugin")]
private static extern IntPtr PrintHello();
void Start ()
{
Debug.Log(Marshal.PtrToStringAuto(PrintHello()));
}
}
Unity的示例插件可以找到
我正在使用Unity 4.2.1f4和Visual Studio 2010使用PtrToStringAnsi而不是PtrToStringAuto 您的DLL正在返回ANSI字符串,但PtrToStringAuto在除Windows 98之外的任何对象上都需要Unicode
public class audiotest : MonoBehaviour
{
[DllImport("ASimplePlugin")]
private static extern IntPtr PrintHello();
void Start ()
{
Debug.Log(Marshal.PtrToStringAuto(PrintHello()));
}
}