- 微信小游戏无法使用 script.onload = function () {} 吗??????
Setup: function (strJsonDataPtr) { try { if (typeof UTF8ToString !== 'function') { throw new Error("UTF8ToString is not defined."); } const strJsonData = UTF8ToString(strJsonDataPtr); console.log("[WebGL] Setup data received from Unity:", strJsonData); const setupOptions = JSON.parse(strJsonData); // 动态加载 SDK var script = document.createElement('script'); script.src = 'Build/main.js'; // 修改为正确路径 script.type = 'text/javascript'; document.body.appendChild(script); console.log("[WebGL] Loading SDK script..."); script.onload = function () { console.log("11111111111111"); try { console.log("[WebGL] SDK script successfully loaded."); if (typeof SDK === 'undefined') { throw new Error("SDK is not loaded."); } if (typeof SDK .Manager !== 'function') { throw new Error("SDK .Manager is not defined or is not a function."); } const instance = new SDK .Manager(); console.log("[WebGL] Setup options:", setupOptions); // 调用 SDK 的 setup 方法,采用回调方式处理结果 instance.setup(setupOptions, function (result) { if (result.success) { console.log("[WebGL] Setup completed successfully:", result); const successMessage = JSON.stringify({ result: true }); SendMessage("WebGL", "_SetupSucceed", successMessage); } else { console.error("[WebGL] Setup failed:", result.error); const failureMessage = JSON.stringify({ result: false, error: result.error || "SDK initialization failed", }); SendMessage("WebGL", "_SetupFailed", failureMessage); } }); } catch (error) { console.error("[WebGL] Error during SDK Setup:", error); const errorMessage = JSON.stringify({ result: false, error: error.message, }); SendMessage("WebGL", "_SetupFailed", errorMessage); } }; console.log("2222222222222222"); script.onerror = function (errorEvent) { console.error("[WebGL] Failed to load SDK script:", errorEvent); const errorMessage = JSON.stringify({ result: false, error: "Failed to load SDK script", }); SendMessage("WebGL", "_SetupFailed", errorMessage); }; console.log("33333333333333333"); } catch (error) { console.log("444444444444444444"); console.error("[WebGL] Error during setup:", error); const errorMessage = JSON.stringify({ result: false, error: error.message, }); SendMessage("WebGL", "_SetupFailed", errorMessage); } }, 为什么 script.onload = function (){} 里面的代码不会执行??我打包为 webgl 在浏览器中都能正常运行,但是 Unity 中使用微信小游戏的一键打包导入微信小游戏之后就无法执行 script.onload = function (){} 里面的代码。。
04-01 - 小游戏现在不可以内置 webview 吗
现在微信小游戏中,可以内嵌浏览器吗? webview 的效果可以吗?
03-26 - 电脑端拉起微信小程序时显示未登录,但是已经是登录状态了,这是为什么?
背景: 电脑端拉起小程序后,显示图片内容,但是现在微信已经是登录状态。 [图片] 重新退出微信再登录之后才能正常拉起小程序。 问题: 是否是因为登录时间过长导致登录信息失效?如果是的话,登录信息的过期时间是多久? 如果不是的话,具体是什么原因呢?
03-03 - 在Unity中PC端怎么判断是否安装了微信?
因为没有集成 微信,无法使用微信的相关API。但是我想在 unity 中能够判断出该电脑是否安装了微信。我现在想到了查询注册表,但是无法确定注册表路径是否在各个电脑上都能够统一。还有其他的办法吗,比如说是否有什么系统的 API 可以直接判断。
02-19 - PC端怎么判断是否安装了微信?
想判断电脑上是否安装了微信,应该使用什么系统 API?使用注册表查询似乎无法做到准确查询。
02-17