我有以下lib.jslib
文件
mergeInto(LibraryManager.library, {
IsGuestUser: function (objectName, objectMethodName) {
gamesmart.user.isGuest(function (result) {
console.log(Pointer_stringify(objectName), Pointer_stringify(objectMethodName), result);
gameSmartGameInstance.SendMessage(Pointer_stringify(objectName), Pointer_stringify(objectMethodName), result);
});
}
});
从这里开始调用:
namespace GameSmart {
public class User : API {
[DllImport("__Internal")]
public static extern void IsGuestUser(string objectName, string objectMethodName);
public static void IsGuest(string objectName, string objectMethodName) {
IsGuestUser(objectName, objectMethodName);
}
}
}
并且是这样开始的:
public class Test : MonoBehaviour {
void Start() {
GameSmart.User.IsGuest("GameSmart", "OnIsGuest");
}
}
如上所示,我将GameSmart
和OnIsGuest
传递给JavaScript,当它转到JavaScript时,我会在两个值上调用Pointer_stringify()
。
转换并记录后,我得到以下输出:0Zހ
和ﳀ�
我应该得到GameSmart
和OnIsGuest
但是我没有导致这个发生了吗?
答案 0 :(得分:0)
所以解决这个问题的方法是将Pointer_stringify
移到匿名函数之外,所以它看起来像这样:
mergeInto(LibraryManager.library, {
IsGuestUser: function (objectName, objectMethodName) {
var jsObjectName = Pointer_stringify(objectName);
var jsObjectMethodName = Pointer_stringify(objectMethodName);
gamesmart.user.isGuest(function (result) {
gameSmartGameInstance.SendMessage(jsObjectName, jsObjectMethodName, result);
});
}
});