diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f9307a82..3d8d371c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,37 @@ Removed - 删除功能/接口 Fixed - 修复问题 Others - 其他 --> +## 2024-1-7 【重要更新】 +### Feature +* 重要:支持Unity6,预览版本不建议上线使用 +* 普通:OffShareMessageToFriend支持 +* 普通:性能深度分析工具版本更新 +### Fixed +* 普通: reserveChannelsLive补充回调参数 +* 普通: 低基础库版本报错修复 +* 普通: BannerAd.OnResize回调报错修复 +* 普通: requestMidasPaymentGameItem修复 +* 普通: WriteSync接口无法正常返回已写入的字节数 +* 普通: ReadSync接口无法正常调用 + +## 2024-12-18 【重要更新】 +### Feature +* 普通: 开放数据域支持screenCanvas +* 普通: 完善screenCanvas.toTempFilePath +* 普通: 低版本WindowInfo适配 +* 普通: 调整autoAdaptScreen默认false +* 普通: 首资源包放小游戏分包时,总大小调整为30MB +### Fixed +* 重要: 更改WebGLInput.mobileKeyboardSupport默认属性为 false,该属性导致Unity2022 以上版本 Touch 会多调用一次 MainLoop产生较大性能损耗。请使用微信键盘API或 WXTouchInputOverride支持文本输入框 + +## 2024-11-14 【普通更新】 +### Feature +* 普通: WXSDK代码简化 +* 普通: 增强JsonMapper报错信息 +* 普通: 适配插件版本升级到1.2.62 +### Fixed +* 普通: WX.Cloud.Init 自定义环境报错 + ## 2024-10-8 【重要更新】 ### Feature * 普通: UDPSocket.write适配 diff --git a/Editor/WXConvertCore.cs b/Editor/WXConvertCore.cs index a69aaa882..cdc1f6fa3 100644 --- a/Editor/WXConvertCore.cs +++ b/Editor/WXConvertCore.cs @@ -25,7 +25,6 @@ namespace WeChatWASM public static void Init() { - SDKFilePath = Path.Combine(UnityUtil.GetWxSDKRootPath(), "Runtime", "wechat-default", "unity-sdk", "index.js"); string templateHeader = "PROJECT:"; #if TUANJIE_2022_3_OR_NEWER PlayerSettings.WeixinMiniGame.threadsSupport = false; @@ -79,7 +78,6 @@ namespace WeChatWASM public static string dataFileSize = string.Empty; public static string codeMd5 = string.Empty; public static string dataMd5 = string.Empty; - private static string SDKFilePath = string.Empty; public static string defaultImgSrc = "Assets/WX-WASM-SDK-V2/Runtime/wechat-default/images/background.jpg"; private static bool lastBrotliType = false; @@ -243,7 +241,7 @@ namespace WeChatWASM try { string metaPath = AssetDatabase.GetTextMetaFilePathFromAssetPath(inAssetPath); // 获取.meta文件的路径 - string enableFlagStr = inEnabled? "1" : "0"; + string enableFlagStr = inEnabled ? "1" : "0"; // 读取.meta文件 // 处理WebGL @@ -314,12 +312,12 @@ namespace WeChatWASM #else wxPerf2022Importer.SetCompatibleWithPlatform(BuildTarget.WebGL, bShouldEnablePerf2022Plugin); #endif - SetPluginCompatibilityByModifyingMetadataFile(wxPerfPlugins[1], bShouldEnablePerf2022Plugin); + SetPluginCompatibilityByModifyingMetadataFile(wxPerfPlugins[1], bShouldEnablePerf2022Plugin); } { // wx_perf_2021.a - bool bShouldEnablePerf2021Plugin = config.CompileOptions.enablePerfAnalysis && IsCompatibleWithUnity202103To202203(); + bool bShouldEnablePerf2021Plugin = config.CompileOptions.enablePerfAnalysis && IsCompatibleWithUnity202102To202203(); var wxPerf2021Importer = AssetImporter.GetAtPath(wxPerfPlugins[2]) as PluginImporter; #if PLATFORM_WEIXINMINIGAME @@ -335,7 +333,7 @@ namespace WeChatWASM /** * Lua Adaptor Settings. */ - + private static bool GetRequiredLuaHeaderFiles(out Dictionary luaPaths) { luaPaths = new Dictionary() @@ -349,8 +347,8 @@ namespace WeChatWASM {"ltable.h", null}, {"lauxlib.h", null}, }; - - string rootPath = Directory.GetParent(Application.dataPath).ToString(); + + string rootPath = Directory.GetParent(Application.dataPath).ToString(); string[] paths = Directory.GetFiles(rootPath, "*.h", SearchOption.AllDirectories); foreach (var path in paths) { @@ -379,7 +377,7 @@ namespace WeChatWASM { return $"Packages{DS}com.qq.weixin.minigame{DS}Runtime{DS}Plugins{DS}LuaAdaptor{DS}{filename}"; } - + return $"Assets{DS}WX-WASM-SDK-V2{DS}Runtime{DS}Plugins{DS}LuaAdaptor{DS}{filename}"; } @@ -408,8 +406,9 @@ namespace WeChatWASM File.WriteAllText(luaAdaptorImportHeaderPath, importHeaderContent); } - - private static void ManageLuaAdaptorBuildOptions(bool shouldBuild) { + + private static void ManageLuaAdaptorBuildOptions(bool shouldBuild) + { string[] maybeBuildFiles = new string[] { "lua_adaptor_501.c", @@ -441,7 +440,7 @@ namespace WeChatWASM SetPluginCompatibilityByModifyingMetadataFile(path, shouldBuild); } } - + private static void MakeEnvForLuaAdaptor() { bool hasLuaEnv = GetRequiredLuaHeaderFiles(out var luaPaths); @@ -449,10 +448,10 @@ namespace WeChatWASM { MakeLuaImport(luaPaths); } - + ManageLuaAdaptorBuildOptions(hasLuaEnv && config.CompileOptions.enablePerfAnalysis); } - + private static bool IsCompatibleWithUnity202203OrNewer() { #if UNITY_2022_3_OR_NEWER @@ -462,11 +461,11 @@ namespace WeChatWASM #endif } - static bool IsCompatibleWithUnity202103To202203() + static bool IsCompatibleWithUnity202102To202203() { #if UNITY_2022_3_OR_NEWER return false; -#elif !UNITY_2021_3_OR_NEWER +#elif !UNITY_2021_2_OR_NEWER return false; #else return true; @@ -809,10 +808,11 @@ namespace WeChatWASM PlayerSettings.WebGL.emscriptenArgs = string.Empty; if (WXExtEnvDef.GETDEF("UNITY_2021_2_OR_NEWER")) { - PlayerSettings.WebGL.emscriptenArgs += " -s EXPORTED_FUNCTIONS=_sbrk,_emscripten_stack_get_base,_emscripten_stack_get_end -s ERROR_ON_UNDEFINED_SYMBOLS=0"; + PlayerSettings.WebGL.emscriptenArgs += " -s EXPORTED_FUNCTIONS=_sbrk,_emscripten_stack_get_base,_emscripten_stack_get_end"; #if UNITY_2021_2_5 - PlayerSettings.WebGL.emscriptenArgs += ",_main"; + PlayerSettings.WebGL.emscriptenArgs += ",_main"; #endif + PlayerSettings.WebGL.emscriptenArgs += " -s ERROR_ON_UNDEFINED_SYMBOLS=0"; } #endif PlayerSettings.runInBackground = false; @@ -874,6 +874,11 @@ namespace WeChatWASM PlayerSettings.WebGL.emscriptenArgs += " --profiling-funcs "; } +#if UNITY_6000_0_OR_NEWER + // 从小游戏转换工具里无法直接开启wasm2023特性 会导致转出的webgl异常,所以强制关闭 + PlayerSettings.WebGL.wasm2023 = false; +#endif + #if UNITY_2021_2_OR_NEWER #if UNITY_2022_1_OR_NEWER // 默认更改为OptimizeSize,减少代码包体积 @@ -1090,11 +1095,16 @@ namespace WeChatWASM File.Copy(tempDataPath, config.ProjectConf.compressDataPackage ? brMinigameDataPath : originMinigameDataPath, true); } } - checkNeedRmovePackageParallelPreload(); - // 设置InstantGame的首资源包路径,上传用 FirstBundlePath = tempDataPath; + convertDataPackageJS(); + } + + public static void convertDataPackageJS() + { + checkNeedRmovePackageParallelPreload(); + var loadDataFromCdn = config.ProjectConf.assetLoadType == 0; Rule[] rules = { @@ -1115,15 +1125,31 @@ namespace WeChatWASM } }; string[] files = { "game.js", "game.json", "project.config.json", "check-version.js" }; - ReplaceFileContent(files, rules); + if (WXRuntimeExtEnvDef.IsPreviewing) + { + ReplaceFileContent(files, rules, WXRuntimeExtEnvDef.PreviewDst); + } + else + { + ReplaceFileContent(files, rules); + } } private static void checkNeedRmovePackageParallelPreload() { + string dst; + if (WXRuntimeExtEnvDef.IsPreviewing) + { + dst = WXRuntimeExtEnvDef.PreviewDst; + } + else + { + dst = Path.Combine(config.ProjectConf.DST, miniGameDir); + } // cdn下载时不需要填写并行下载配置 if (config.ProjectConf.assetLoadType == 0) { - var filePath = Path.Combine(config.ProjectConf.DST, miniGameDir, "game.json"); + var filePath = Path.Combine(dst, "game.json"); string content = File.ReadAllText(filePath, Encoding.UTF8); JsonData gameJson = JsonMapper.ToObject(content); @@ -1143,13 +1169,14 @@ namespace WeChatWASM /// /// /// - public static void ReplaceFileContent(string[] files, Rule[] replaceList) + public static void ReplaceFileContent(string[] files, Rule[] replaceList, string fileDir = null) { if (files.Length != 0 && replaceList.Length != 0) { + var dstPath = fileDir != null ? fileDir : Path.Combine(config.ProjectConf.DST, miniGameDir); for (int i = 0; i < files.Length; i++) { - var filePath = Path.Combine(config.ProjectConf.DST, miniGameDir, files[i]); + var filePath = Path.Combine(dstPath, files[i]); string text = File.ReadAllText(filePath, Encoding.UTF8); for (int j = 0; j < replaceList.Length; j++) { @@ -1210,6 +1237,10 @@ namespace WeChatWASM var info = new FileInfo(dataPath); dataFileSize = info.Length.ToString(); UnityEngine.Debug.LogFormat("[Converter] that to genarate md5 and copy files ended"); + if (config.ProjectConf.Appid == "wx7c792ca878775717") // 快适配小游戏示例 + { + InsertPreviewCode(); + } ModifyWeChatConfigs(isFromConvert); ModifySDKFile(); ClearFriendRelationCode(); @@ -1223,6 +1254,110 @@ namespace WeChatWASM return Brotlib(codeMd5 + ".webgl.wasm.code.unityweb.wasm.br", codePath, Path.Combine(config.ProjectConf.DST, miniGameDir, "wasmcode", codeMd5 + ".webgl.wasm.code.unityweb.wasm.br")); } + private static void InsertPreviewCode() + { + Debug.LogWarning("[WeChat Preview] InsertPreviewCode Start"); + Rule[] rules = + { + // game.json 引入预览插件 + new Rule() + { + old = "\"plugins\": {", + newStr = "\"plugins\": {\n" + + " \"MiniGamePreviewPlugin\": {\n" + + " \"version\": \"latest\",\n" + // 这里更改版本号 + " \"provider\": \"wx7c792ca878775717\",\n" + + " \"contexts\": [\n" + + " {\n" + + " \"type\": \"isolatedContext\"\n" + + " }\n" + + " ]\n" + + " }," + }, + // game.js 嵌入:有url启动参数进入预览盒子 + new Rule() + { + old = "const managerConfig = {", + newStr = + "export let minigamePreview;\n" + + "let isStarted = false;\n" + + "wx.onShow((res) => {\n" + + " console.warn('onShow: ' + JSON.stringify(res));\n" + + " // res.query.url = 'localhost:8044';\n" + + " if (!isStarted) {\n" + + " isStarted = true;\n" + + " if (res.query.url) {\n" + + " startPreview(res.query.url);\n" + + " } else {\n" + + " startGame();\n" + + " }\n" + + " } else if (res.query.url) { // 扫预览码进入\n" + + " wx.restartMiniProgram({\n" + + " path: `/?url=${res.query.url}`\n" + + " });\n" + + " }\n" + + "})\n" + + "function startPreview(url) {\n" + + " wx.setEnableDebug({ enableDebug: true });\n" + + " const [ip, port] = url.split(':');\n" + + " let MiniGamePreview;\n" + + " if (requirePlugin) {\n" + + " try {\n" + + " MiniGamePreview = requirePlugin('MiniGamePreviewPlugin', {\n" + + " enableRequireHostModule: true,\n" + + " customEnv: {\n" + + " wx,\n" + + " canvas,\n" + + " gameGlobal: {...GameGlobal},\n" + + " },\n" + + " }).default;\n" + + " } catch (e) {\n" + + " console.error(e);\n" + + " }\n" + + " minigamePreview = new MiniGamePreview({\n" + + " ip: ip,\n" + + " port: port\n" + + " })\n" + + " minigamePreview.initStartPage();\n" + + " }\n" + + "}\n" + + "function startGame() {\n" + + "const managerConfig = {", + }, + // game.js 括号补齐 + new Rule() + { + old = " }\n});", + newStr = " }\n});}", + }, + // unity-sdk/module-helper.js 引入预览插件 + new Rule() + { + old = "import { MODULE_NAME } from './conf';", + newStr = "import { MODULE_NAME } from './conf';\n" + + "import { minigamePreview } from '../game';", + }, + // unity-sdk/module-helper.js 预览环境下hookAPI + new Rule() + { + old = "this._send = GameGlobal.Module.SendMessage;", + newStr = "if (minigamePreview) {\n" + + " this._send = minigamePreview.getPreviewSend();\n" + + " } else {\n" + + " this._send = GameGlobal.Module.SendMessage;\n" + + " }", + }, + new Rule() + { + old = "3.5.1", // project.config.json 转换插件 hardcode + newStr = "latest", + } + }; + string[] files = { "game.js", "game.json", "unity-sdk/module-helper.js", "project.config.json" }; + ReplaceFileContent(files, rules); + Debug.LogWarning("[WeChat Preview] InsertPreviewCode End"); + } + private static int Brotlib(string filename, string sourcePath, string targetPath) { UnityEngine.Debug.LogFormat("[Converter] Starting to generate Brotlib file"); @@ -1297,9 +1432,18 @@ namespace WeChatWASM /// /// 更新game.json /// - private static void ClearFriendRelationCode() + public static void ClearFriendRelationCode() { - var filePath = Path.Combine(config.ProjectConf.DST, miniGameDir, "game.json"); + string dst; + if (WXRuntimeExtEnvDef.IsPreviewing) + { + dst = WXRuntimeExtEnvDef.PreviewDst; + } + else + { + dst = Path.Combine(config.ProjectConf.DST, miniGameDir); + } + var filePath = Path.Combine(dst, "game.json"); string content = File.ReadAllText(filePath, Encoding.UTF8); JsonData gameJson = JsonMapper.ToObject(content); @@ -1317,7 +1461,7 @@ namespace WeChatWASM gameJson["plugins"].Remove("Layout"); // 删除 open-data 相应的文件夹 - string openDataDir = Path.Combine(config.ProjectConf.DST, miniGameDir, "open-data"); + string openDataDir = Path.Combine(dst, "open-data"); UnityUtil.DelectDir(openDataDir); Directory.Delete(openDataDir, true); } @@ -1342,9 +1486,18 @@ namespace WeChatWASM /// /// 更新game.js /// - private static void GameJsPlugins() + public static void GameJsPlugins() { - var filePath = Path.Combine(config.ProjectConf.DST, miniGameDir, "game.js"); + string dst; + if (WXRuntimeExtEnvDef.IsPreviewing) + { + dst = WXRuntimeExtEnvDef.PreviewDst; + } + else + { + dst = Path.Combine(config.ProjectConf.DST, miniGameDir); + } + var filePath = Path.Combine(dst, "game.js"); string content = File.ReadAllText(filePath, Encoding.UTF8); @@ -1366,7 +1519,7 @@ namespace WeChatWASM } else { - File.Delete(Path.Combine(config.ProjectConf.DST, miniGameDir, "plugins", "check-update.js")); + File.Delete(Path.Combine(dst, "plugins", "check-update.js")); } if (config.CompileOptions.autoAdaptScreen) { @@ -1375,7 +1528,7 @@ namespace WeChatWASM } else { - File.Delete(Path.Combine(config.ProjectConf.DST, miniGameDir, "plugins", "screen-adapter.js")); + File.Delete(Path.Combine(dst, "plugins", "screen-adapter.js")); } if (changed) @@ -1384,26 +1537,34 @@ namespace WeChatWASM } else { - Directory.Delete(Path.Combine(config.ProjectConf.DST, miniGameDir, "plugins"), true); + Directory.Delete(Path.Combine(dst, "plugins"), true); } } - private static void ModifySDKFile() + public static void ModifySDKFile() { - var config = UnityUtil.GetEditorConf(); - string content = File.ReadAllText(SDKFilePath, Encoding.UTF8); + string dst; + if (WXRuntimeExtEnvDef.IsPreviewing) + { + dst = WXRuntimeExtEnvDef.PreviewDst; + } + else + { + dst = Path.Combine(config.ProjectConf.DST, miniGameDir); + } + string content = File.ReadAllText(Path.Combine(UnityUtil.GetWxSDKRootPath(), "Runtime", "wechat-default", "unity-sdk", "index.js"), Encoding.UTF8); content = content.Replace("$unityVersion$", Application.unityVersion); - File.WriteAllText(Path.Combine(config.ProjectConf.DST, miniGameDir, "unity-sdk", "index.js"), content, Encoding.UTF8); + File.WriteAllText(Path.Combine(dst, "unity-sdk", "index.js"), content, Encoding.UTF8); // content = File.ReadAllText(Path.Combine(Application.dataPath, "WX-WASM-SDK-V2", "Runtime", "wechat-default", "unity-sdk", "storage.js"), Encoding.UTF8); content = File.ReadAllText(Path.Combine(UnityUtil.GetWxSDKRootPath(), "Runtime", "wechat-default", "unity-sdk", "storage.js"), Encoding.UTF8); var PreLoadKeys = config.PlayerPrefsKeys.Count > 0 ? JsonMapper.ToJson(config.PlayerPrefsKeys) : "[]"; content = content.Replace("'$PreLoadKeys'", PreLoadKeys); - File.WriteAllText(Path.Combine(config.ProjectConf.DST, miniGameDir, "unity-sdk", "storage.js"), content, Encoding.UTF8); + File.WriteAllText(Path.Combine(dst, "unity-sdk", "storage.js"), content, Encoding.UTF8); // 修改纹理dxt // content = File.ReadAllText(Path.Combine(Application.dataPath, "WX-WASM-SDK-V2", "Runtime", "wechat-default", "unity-sdk", "texture.js"), Encoding.UTF8); content = File.ReadAllText(Path.Combine(UnityUtil.GetWxSDKRootPath(), "Runtime", "wechat-default", "unity-sdk", "texture.js"), Encoding.UTF8); - File.WriteAllText(Path.Combine(config.ProjectConf.DST, miniGameDir, "unity-sdk", "texture.js"), content, Encoding.UTF8); + File.WriteAllText(Path.Combine(dst, "unity-sdk", "texture.js"), content, Encoding.UTF8); } public static string HandleLoadingImage() @@ -1610,8 +1771,6 @@ namespace WeChatWASM { UnityEngine.Debug.LogFormat("[Converter] Starting to modify configs"); - var config = UnityUtil.GetEditorConf(); - var PRELOAD_LIST = GetPreloadList(config.ProjectConf.preloadFiles); var imgSrc = HandleLoadingImage(); @@ -1621,7 +1780,7 @@ namespace WeChatWASM var screenOrientation = new List() { "portrait", "landscape", "landscapeLeft", "landscapeRight" }[(int)config.ProjectConf.Orientation]; var customUnicodeRange = GetCustomUnicodeRange(config.FontOptions.CustomUnicode); - Debug.Log("customUnicodeRange: " + customUnicodeRange); + Debug.Log("[Converter] customUnicodeRange: " + customUnicodeRange); var boolConfigInfo = GenerateBootInfo(); @@ -1693,12 +1852,24 @@ namespace WeChatWASM List replaceList = new List(replaceArrayList); List files = new List { "game.js", "game.json", "project.config.json", "unity-namespace.js", "check-version.js", "unity-sdk/font/index.js" }; - ReplaceFileContent(files.ToArray(), replaceList.ToArray()); - BuildTemplate.mergeJSON( - Path.Combine(Application.dataPath, "WX-WASM-SDK-V2", "Editor", "template", "minigame"), - Path.Combine(config.ProjectConf.DST, miniGameDir) - ); + if (WXRuntimeExtEnvDef.IsPreviewing) + { + ReplaceFileContent(files.ToArray(), replaceList.ToArray(), WXRuntimeExtEnvDef.PreviewDst); + BuildTemplate.mergeJSON( + Path.Combine(Application.dataPath, "WX-WASM-SDK-V2", "Editor", "template", "minigame"), + WXRuntimeExtEnvDef.PreviewDst + ); + } + else + { + ReplaceFileContent(files.ToArray(), replaceList.ToArray()); + BuildTemplate.mergeJSON( + Path.Combine(Application.dataPath, "WX-WASM-SDK-V2", "Editor", "template", "minigame"), + Path.Combine(config.ProjectConf.DST, miniGameDir) + ); + } Emit(LifeCycle.afterBuildTemplate); + UnityEngine.Debug.LogFormat("[Converter] that to modify configs ended"); } diff --git a/Editor/WXEditorSettingHelper.cs b/Editor/WXEditorSettingHelper.cs index 8b7a9bfb4..df27e2567 100644 --- a/Editor/WXEditorSettingHelper.cs +++ b/Editor/WXEditorSettingHelper.cs @@ -721,15 +721,15 @@ namespace WeChatWASM const string MACRO_ENABLE_WX_PERF_FEATURE = "ENABLE_WX_PERF_FEATURE"; string defineSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup); - bool shouldAddSymbol = this.getDataCheckbox("enablePerfAnalysis") && this.getDataCheckbox("developBuild"); + bool shouldAddSymbol = this.getDataCheckbox("enablePerfAnalysis") && this.getDataCheckbox("developBuild"); #if !UNITY_2021_2_OR_NEWER || UNITY_2023_2_OR_NEWER - if(shouldAddSymbol) + if (shouldAddSymbol) { shouldAddSymbol = false; EditorUtility.DisplayDialog("警告", $"当前Unity版本({Application.unityVersion})不在性能分析工具适配范围内(2021.2-2023.1), 性能分析工具将被禁用。", "确定"); - config.CompileOptions.enablePerfAnalysis = false; - this.setData("enablePerfAnalysis", false); + config.CompileOptions.enablePerfAnalysis = false; + this.setData("enablePerfAnalysis", false); } #endif diff --git a/Editor/WXExtDef.cs b/Editor/WXExtDef.cs index 9c6516520..3763d7e74 100644 --- a/Editor/WXExtDef.cs +++ b/Editor/WXExtDef.cs @@ -72,6 +72,11 @@ namespace WeChatWASM #else WXExtEnvDef.SETDEF("UNITY_2022", false); #endif +#if UNITY_6000 + WXExtEnvDef.SETDEF("UNITY_6000", true); +#else + WXExtEnvDef.SETDEF("UNITY_6000", false); +#endif #if UNITY_2022_2_OR_NEWER WXExtEnvDef.SETDEF("UNITY_2022_2_OR_NEWER", true); #else @@ -92,6 +97,11 @@ namespace WeChatWASM #else WXExtEnvDef.SETDEF("TUANJIE_2022_3_OR_NEWER", false); #endif +#if UNITY_6000_0_OR_NEWER + WXExtEnvDef.SETDEF("UNITY_6000_0_OR_NEWER", true); +#else + WXExtEnvDef.SETDEF("UNITY_6000_0_OR_NEWER", false); +#endif #if PLATFORM_WEIXINMINIGAME WXExtEnvDef.SETDEF("PLATFORM_WEIXINMINIGAME", true); #else diff --git a/Editor/WXPluginVersion.cs b/Editor/WXPluginVersion.cs index 23320c981..d5dee9809 100644 --- a/Editor/WXPluginVersion.cs +++ b/Editor/WXPluginVersion.cs @@ -2,7 +2,7 @@ namespace WeChatWASM { public class WXPluginVersion { - public static string pluginVersion = "202411211302"; // 这一行不要改他,导出的时候会自动替换 + public static string pluginVersion = "202502110725"; // 这一行不要改他,导出的时候会自动替换 } public class WXPluginConf diff --git a/Editor/wx-editor.dll b/Editor/wx-editor.dll index fd8d3f3eb..b4225363a 100644 Binary files a/Editor/wx-editor.dll and b/Editor/wx-editor.dll differ diff --git a/Editor/wx-editor.xml.meta b/Editor/wx-editor.xml.meta index 212186c53..9076a7dd3 100644 --- a/Editor/wx-editor.xml.meta +++ b/Editor/wx-editor.xml.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e3a203a0f026fa02c0462024b16c2e30 +guid: d05761f316f7eab715c19190699cc137 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/DisableKeyboardInput.cs b/Runtime/DisableKeyboardInput.cs new file mode 100644 index 000000000..fa300352b --- /dev/null +++ b/Runtime/DisableKeyboardInput.cs @@ -0,0 +1,23 @@ +#if UNITY_WEBGL || WEIXINMINIGAME || UNITY_EDITOR +using System; +using UnityEngine; +using WeChatWASM; + + +internal class DisableKeyboardInput : MonoBehaviour +{ + [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] + private static void OnGameLaunch() + { +#if !UNITY_EDITOR +#if PLATFORM_WEIXINMINIGAME + WeixinMiniGameInput.mobileKeyboardSupport = false; +#elif PLATFORM_WEBGL +#if UNITY_2022_1_OR_NEWER + WebGLInput.mobileKeyboardSupport = false; +#endif +#endif +#endif + } +} +#endif \ No newline at end of file diff --git a/Runtime/DisableKeyboardInput.cs.meta b/Runtime/DisableKeyboardInput.cs.meta new file mode 100644 index 000000000..4ac7a9f6a --- /dev/null +++ b/Runtime/DisableKeyboardInput.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: b4b797696785c4e6c93ba24eb8129b15 +DefaultImporter: +externalObjects: {} +userData: +assetBundleName: +assetBundleVariant: \ No newline at end of file diff --git a/Runtime/Plugins/LuaAdaptor.meta b/Runtime/Plugins/LuaAdaptor.meta index 1de8e7fe9..42ebab194 100644 --- a/Runtime/Plugins/LuaAdaptor.meta +++ b/Runtime/Plugins/LuaAdaptor.meta @@ -1,8 +1,8 @@ fileFormatVersion: 2 -guid: d3b689e5d408dbed9ed74e621b4a87bd +guid: 78d089244d74c3042a4f280b5652f74d folderAsset: yes DefaultImporter: externalObjects: {} userData: assetBundleName: - assetBundleVariant: \ No newline at end of file + assetBundleVariant: diff --git a/Runtime/Plugins/LuaAdaptor/lua_adaptor_501.c.meta b/Runtime/Plugins/LuaAdaptor/lua_adaptor_501.c.meta index c2db2989a..7507a643f 100644 --- a/Runtime/Plugins/LuaAdaptor/lua_adaptor_501.c.meta +++ b/Runtime/Plugins/LuaAdaptor/lua_adaptor_501.c.meta @@ -62,12 +62,12 @@ PluginImporter: - first: WebGL: WebGL second: - enabled: 1 + enabled: 0 settings: {} - first: WeixinMiniGame: WeixinMiniGame second: - enabled: 1 + enabled: 0 settings: {} userData: assetBundleName: diff --git a/Runtime/Plugins/LuaAdaptor/lua_adaptor_503.c.meta b/Runtime/Plugins/LuaAdaptor/lua_adaptor_503.c.meta index b6c4095f5..63d671147 100644 --- a/Runtime/Plugins/LuaAdaptor/lua_adaptor_503.c.meta +++ b/Runtime/Plugins/LuaAdaptor/lua_adaptor_503.c.meta @@ -62,12 +62,12 @@ PluginImporter: - first: WebGL: WebGL second: - enabled: 1 + enabled: 0 settings: {} - first: WeixinMiniGame: WeixinMiniGame second: - enabled: 1 + enabled: 0 settings: {} userData: assetBundleName: diff --git a/Runtime/Plugins/LuaAdaptor/lua_adaptor_comm.c.meta b/Runtime/Plugins/LuaAdaptor/lua_adaptor_comm.c.meta index d1744cfc8..20c55edeb 100644 --- a/Runtime/Plugins/LuaAdaptor/lua_adaptor_comm.c.meta +++ b/Runtime/Plugins/LuaAdaptor/lua_adaptor_comm.c.meta @@ -62,12 +62,12 @@ PluginImporter: - first: WebGL: WebGL second: - enabled: 1 + enabled: 0 settings: {} - first: WeixinMiniGame: WeixinMiniGame second: - enabled: 1 + enabled: 0 settings: {} userData: assetBundleName: diff --git a/Runtime/Plugins/LuaAdaptor/lua_adaptor_import.h.meta b/Runtime/Plugins/LuaAdaptor/lua_adaptor_import.h.meta index e76e1d4f6..19c38cbd6 100644 --- a/Runtime/Plugins/LuaAdaptor/lua_adaptor_import.h.meta +++ b/Runtime/Plugins/LuaAdaptor/lua_adaptor_import.h.meta @@ -62,12 +62,12 @@ PluginImporter: - first: WebGL: WebGL second: - enabled: 1 + enabled: 0 settings: {} - first: WeixinMiniGame: WeixinMiniGame second: - enabled: 1 + enabled: 0 settings: {} userData: assetBundleName: diff --git a/Runtime/Plugins/SDK-Call-JS-Old.jslib b/Runtime/Plugins/SDK-Call-JS-Old.jslib index 4d3e66b78..6d658038c 100755 --- a/Runtime/Plugins/SDK-Call-JS-Old.jslib +++ b/Runtime/Plugins/SDK-Call-JS-Old.jslib @@ -232,6 +232,16 @@ mergeInto(LibraryManager.library, { stringToUTF8(returnStr, buffer, bufferSize); return buffer; }, + WXOpenDataToTempFilePath: function (conf, s, f, c) { + window.WXWASMSDK.WXOpenDataToTempFilePath(_WXPointer_stringify_adaptor(conf), _WXPointer_stringify_adaptor(s), _WXPointer_stringify_adaptor(f), _WXPointer_stringify_adaptor(c)) + }, + WXOpenDataToTempFilePathSync: function (conf) { + var returnStr = window.WXWASMSDK.WXOpenDataToTempFilePathSync(_WXPointer_stringify_adaptor(conf)); + var bufferSize = lengthBytesUTF8(returnStr || '') + 1; + var buffer = _malloc(bufferSize); + stringToUTF8(returnStr, buffer, bufferSize); + return buffer; + }, WXGetUserDataPath: function () { var returnStr = window.WXWASMSDK.WXGetUserDataPath(); var bufferSize = lengthBytesUTF8(returnStr || '') + 1; @@ -253,6 +263,9 @@ mergeInto(LibraryManager.library, { stringToUTF8(returnStr, buffer, bufferSize); return buffer; }, + WXGetOpenDataContext: function (mode) { + window.WXWASMSDK.WXGetOpenDataContext(_WXPointer_stringify_adaptor(mode)); + }, WXDataContextPostMessage: function (msg) { window.WXWASMSDK.WXDataContextPostMessage(_WXPointer_stringify_adaptor(msg)); }, diff --git a/Runtime/Plugins/WXAssetBundle.jslib b/Runtime/Plugins/WXAssetBundle.jslib index 9314aaad2..ab24b88e2 100644 --- a/Runtime/Plugins/WXAssetBundle.jslib +++ b/Runtime/Plugins/WXAssetBundle.jslib @@ -198,7 +198,7 @@ var WXAssetBundleLibrary = { }(); WXFS.cache = new WXFileCache(ttl, capacity); - if(!unityNamespace.isAndroid) { + if(unityNamespace.isIOS && unityNamespace.isH5Renderer) { WXFS.cache.RegularCleaning(1); } diff --git a/Runtime/Plugins/WxPerfJsBridge.jslib b/Runtime/Plugins/WxPerfJsBridge.jslib index 9e0ea2e26..828162dac 100644 --- a/Runtime/Plugins/WxPerfJsBridge.jslib +++ b/Runtime/Plugins/WxPerfJsBridge.jslib @@ -94,5 +94,17 @@ mergeInto(LibraryManager.library, { 'idbfsPathStr': idbfsPathStr, 'targetPathStr': targetPathStr }) + }, + + JSGetDPR: function() { + return window.devicePixelRatio; + }, + + JSGetConvertPluginVersion: function() { + var lengthBytes = lengthBytesUTF8(GameGlobal.unityNamespace.convertPluginVersion) + 1; + var stringOnWasmHeap = _malloc(lengthBytes); + stringToUTF8(GameGlobal.unityNamespace.convertPluginVersion, stringOnWasmHeap, lengthBytes); + + return stringOnWasmHeap; } }); diff --git a/Runtime/Plugins/wx-perf.dll b/Runtime/Plugins/wx-perf.dll index a76e7190e..6eb8202d0 100644 Binary files a/Runtime/Plugins/wx-perf.dll and b/Runtime/Plugins/wx-perf.dll differ diff --git a/Runtime/Plugins/wx-perf.dll.meta b/Runtime/Plugins/wx-perf.dll.meta index 7684517d7..99b128da8 100644 --- a/Runtime/Plugins/wx-perf.dll.meta +++ b/Runtime/Plugins/wx-perf.dll.meta @@ -64,6 +64,11 @@ PluginImporter: second: enabled: 1 settings: {} + - first: + WeixinMiniGame: WeixinMiniGame + second: + enabled: 1 + settings: {} - first: Windows Store Apps: WindowsStoreApps second: diff --git a/Runtime/Plugins/wx-perf.xml b/Runtime/Plugins/wx-perf.xml index 6621b573b..e9125a4cc 100644 --- a/Runtime/Plugins/wx-perf.xml +++ b/Runtime/Plugins/wx-perf.xml @@ -20,7 +20,7 @@ 性能指标名称 性能指标类别 - 性能指标展示方式,1. 线性插值;2. Step插值;0. 只显示单一值 + 性能指标展示方式,0. 不插值. 1. 线性插值;2. Step插值; diff --git a/Runtime/Plugins/wx-runtime-editor.dll b/Runtime/Plugins/wx-runtime-editor.dll index 3fef49a29..0d91ccdef 100644 Binary files a/Runtime/Plugins/wx-runtime-editor.dll and b/Runtime/Plugins/wx-runtime-editor.dll differ diff --git a/Runtime/Plugins/wx-runtime-editor.xml b/Runtime/Plugins/wx-runtime-editor.xml index ab9d6bc2f..37d9fdc87 100644 --- a/Runtime/Plugins/wx-runtime-editor.xml +++ b/Runtime/Plugins/wx-runtime-editor.xml @@ -193,14 +193,31 @@ - 同步的将当前 Canvas 保存为一个临时文件 + 同步的将当前 SharedCanvas(开放数据域) 截屏保存为一个临时文件 华为机型分享有已知bug,推荐使用异步版本 canvas 生成的临时文件路径 (本地路径) - 异步的将当前 Canvas 保存为一个临时文件 + 异步的将当前 SharedCanvas(开放数据域) 截图保存为一个临时文件 + + + + + 开放数据域的sharedCanvas + + + + + 同步的将当前 SharedCanvas(开放数据域) 保存为一个临时文件 + 华为机型分享有已知bug,推荐使用异步版本 + + canvas 生成的临时文件路径 (本地路径) + + + + 异步的将当前 SharedCanvas(开放数据域) 保存为一个临时文件 @@ -3107,6 +3124,26 @@ 接口调用成功的回调函数 + + + 预告 id,通过 getChannelsLiveNoticeInfo 接口获取 + + + + + 接口调用结束的回调函数(调用成功、失败都会执行) + + + + + 接口调用失败的回调函数 + + + + + 接口调用成功的回调函数 + + 小程序账号信息 @@ -8574,11 +8611,6 @@ 接口调用成功的回调函数 - - - 预告 id,通过 getChannelsLiveNoticeInfo 接口获取 - - 接口调用结束的回调函数(调用成功、失败都会执行) diff --git a/Runtime/Plugins/wx-runtime-editor.xml.meta b/Runtime/Plugins/wx-runtime-editor.xml.meta index 28a3f3ff4..c04304d56 100644 --- a/Runtime/Plugins/wx-runtime-editor.xml.meta +++ b/Runtime/Plugins/wx-runtime-editor.xml.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e433b3740527c2a62e32be2cb3642757 +guid: 7a86865669cf8962db73b80475f73340 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/Plugins/wx-runtime.dll b/Runtime/Plugins/wx-runtime.dll index e5bb9fe5a..02ce4f2df 100644 Binary files a/Runtime/Plugins/wx-runtime.dll and b/Runtime/Plugins/wx-runtime.dll differ diff --git a/Runtime/Plugins/wx-runtime.xml b/Runtime/Plugins/wx-runtime.xml index 110617077..63c0b1c5b 100644 --- a/Runtime/Plugins/wx-runtime.xml +++ b/Runtime/Plugins/wx-runtime.xml @@ -199,14 +199,31 @@ - 同步的将当前 Canvas 保存为一个临时文件 + 同步的将当前 SharedCanvas(开放数据域) 截屏保存为一个临时文件 华为机型分享有已知bug,推荐使用异步版本 canvas 生成的临时文件路径 (本地路径) - 异步的将当前 Canvas 保存为一个临时文件 + 异步的将当前 SharedCanvas(开放数据域) 截图保存为一个临时文件 + + + + + 开放数据域的sharedCanvas + + + + + 同步的将当前 SharedCanvas(开放数据域) 保存为一个临时文件 + 华为机型分享有已知bug,推荐使用异步版本 + + canvas 生成的临时文件路径 (本地路径) + + + + 异步的将当前 SharedCanvas(开放数据域) 保存为一个临时文件 @@ -3113,6 +3130,26 @@ 接口调用成功的回调函数 + + + 预告 id,通过 getChannelsLiveNoticeInfo 接口获取 + + + + + 接口调用结束的回调函数(调用成功、失败都会执行) + + + + + 接口调用失败的回调函数 + + + + + 接口调用成功的回调函数 + + 小程序账号信息 @@ -8580,11 +8617,6 @@ 接口调用成功的回调函数 - - - 预告 id,通过 getChannelsLiveNoticeInfo 接口获取 - - 接口调用结束的回调函数(调用成功、失败都会执行) diff --git a/Runtime/Plugins/wx-runtime.xml.meta b/Runtime/Plugins/wx-runtime.xml.meta index c9a37364b..6166ab1d3 100644 --- a/Runtime/Plugins/wx-runtime.xml.meta +++ b/Runtime/Plugins/wx-runtime.xml.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: aafa0abf815bb0845a4166c5f523605c +guid: 73f0f5fde7193ea9d6786ceb70926356 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/Plugins/wx_perf_2021.a b/Runtime/Plugins/wx_perf_2021.a index fae254b0a..da9074be3 100644 Binary files a/Runtime/Plugins/wx_perf_2021.a and b/Runtime/Plugins/wx_perf_2021.a differ diff --git a/Runtime/Plugins/wx_perf_2022.a b/Runtime/Plugins/wx_perf_2022.a index 5db186f90..9b27bc262 100644 Binary files a/Runtime/Plugins/wx_perf_2022.a and b/Runtime/Plugins/wx_perf_2022.a differ diff --git a/Runtime/WX.cs b/Runtime/WX.cs index cb2c765db..2f1513ba7 100644 --- a/Runtime/WX.cs +++ b/Runtime/WX.cs @@ -278,7 +278,7 @@ namespace WeChatWASM /// /// [wx.exitMiniProgram(Object object)](https://developers.weixin.qq.com/minigame/dev/api/navigate/wx.exitMiniProgram.html) /// 需要基础库: `2.17.3` - /// 退出当前小程序。必须有点击行为才能调用成功。 + /// 退出当前小程序 /// public static void ExitMiniProgram(ExitMiniProgramOption callback) { @@ -628,7 +628,7 @@ namespace WeChatWASM /// **encryptedData 解密后得到的 GameClubData 的结构** /// | 属性 | 类型 | 说明 | /// | ------- | ------- | -------------------------------------- | - /// | dataList | Array | 游戏圈相关数据的对象数组 | + /// | dataList | Array\ | 游戏圈相关数据的对象数组 | /// **GameClubDataByType 的结构** /// | 属性 | 类型 | 说明 | /// | ------- |------- | -------------------------------------- | @@ -737,9 +737,6 @@ namespace WeChatWASM /// /// [wx.getPhoneNumber(Object object)](https://developers.weixin.qq.com/minigame/dev/api/open-api/user-info/wx.getPhoneNumber.html) /// 手机号快速验证,向用户申请,并在用户同意后,快速填写和验证手机 [具体说明](https://developers.weixin.qq.com/minigame/dev/guide/open-ability/getPhoneNumber.html) - /// **** - /// ## 注意事项 - /// - 用户点击后才可进行调用 /// public static void GetPhoneNumber(GetPhoneNumberOption callback) { @@ -790,10 +787,11 @@ namespace WeChatWASM /// **示例代码** /// ```js /// wx.getScreenRecordingState({ - /// success: function (res) { - /// console.log(res.state) - /// }, + /// success: function (res) { + /// console.log(res.state) + /// }, /// }) + /// ``` /// public static void GetScreenRecordingState(GetScreenRecordingStateOption callback) { @@ -1364,7 +1362,7 @@ namespace WeChatWASM /// /// [wx.openCustomerServiceChat(Object object)](https://developers.weixin.qq.com/minigame/dev/api/open-api/service-chat/wx.openCustomerServiceChat.html) /// 需要基础库: `2.30.4` - /// 打开微信客服,页面产生点击事件(例如 button 上 bindtap 的回调中)后才可调用。了解更多信息,可以参考[微信客服介绍](https://work.weixin.qq.com/kf/)。 + /// 打开微信客服,页面产生点击事件后才可调用。了解更多信息,可以参考[微信客服介绍](https://work.weixin.qq.com/kf/)。 /// **示例代码** /// ```js /// wx.openCustomerServiceChat({ @@ -1382,7 +1380,7 @@ namespace WeChatWASM /// /// [wx.openCustomerServiceConversation(Object object)](https://developers.weixin.qq.com/minigame/dev/api/open-api/customer-message/wx.openCustomerServiceConversation.html) /// 需要基础库: `2.0.3` - /// 进入客服会话。要求在用户发生过至少一次 touch 事件后才能调用。后台接入方式与小程序一致,详见 [客服消息接入](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/customer-message/customer-message.html) + /// 进入客服会话。要求在用户发生过至少一次 touch 事件后才能调用。后台接入方式与小程序一致,详见 [客服消息接入](#) /// **注意事项** /// - 在客服会话内点击小程序消息卡片进入小程序时,不能通过 wx.onShow 或 wx.getEnterOptionsSync 等接口获取启动路径和参数,而是应该通过 wx.openCustomerServiceConversation 接口的 success 回调获取启动路径和参数 /// @@ -1455,6 +1453,16 @@ namespace WeChatWASM WXSDKManagerHandler.Instance.OpenSystemBluetoothSetting(callback); } + /// + /// [wx.operateGameRecorderVideo(Object object)](https://developers.weixin.qq.com/minigame/dev/api/game-recorder/wx.operateGameRecorderVideo.html) + /// 需要基础库: `2.26.1` + /// 分享游戏对局回放。安卓微信8.0.28开始支持,iOS微信8.0.30开始支持。 + /// + public static void OperateGameRecorderVideo(OperateGameRecorderVideoOption callback) + { + WXSDKManagerHandler.Instance.OperateGameRecorderVideo(callback); + } + /// /// [wx.previewImage(Object object)](https://developers.weixin.qq.com/minigame/dev/api/media/image/wx.previewImage.html) /// 在新页面中全屏预览图片。预览的过程中用户可以进行保存图片、发送给朋友等操作。 @@ -1738,7 +1746,6 @@ namespace WeChatWASM /// 需要基础库: `2.9.4` /// 调起小游戏系统订阅消息界面,返回用户订阅消息的操作结果。当用户勾选了订阅面板中的“总是保持以上选择,不再询问”时,模板消息会被添加到用户的小游戏设置页,通过 [wx.getSetting](https://developers.weixin.qq.com/minigame/dev/api/open-api/setting/wx.getSetting.html) 接口可获取用户对相关模板消息的订阅状态。 /// ## 注意事项 - /// - 需要在 touchend 事件的回调中调用。 /// - 使用前建议阅读 [小游戏系统订阅消息使用指引](https://developers.weixin.qq.com/minigame/dev/guide/open-ability/subscribe-system-message.html)。 /// - 系统订阅消息只需要订阅一次,永久有效。 /// **错误码** @@ -2135,7 +2142,7 @@ namespace WeChatWASM /// /// [wx.showShareMenu(Object object)](https://developers.weixin.qq.com/minigame/dev/api/share/wx.showShareMenu.html) /// 需要基础库: `1.1.0` - /// 显示当前页面的转发按钮 + /// 设置右上角点开的详情界面中的分享按钮是否可用 /// **** /// ## 注意事项 /// - "shareAppMessage"表示“发送给朋友”按钮,"shareTimeline"表示“分享到朋友圈”按钮 @@ -2550,16 +2557,6 @@ namespace WeChatWASM WXSDKManagerHandler.Instance.ExitPointerLock(); } - /// - /// [wx.operateGameRecorderVideo(Object object)](https://developers.weixin.qq.com/minigame/dev/api/game-recorder/wx.operateGameRecorderVideo.html) - /// 需要基础库: `2.26.1` - /// 分享游戏对局回放。安卓微信8.0.28开始支持,iOS微信8.0.30开始支持。 - /// - public static void OperateGameRecorderVideo(OperateGameRecorderVideoOption option) - { - WXSDKManagerHandler.Instance.OperateGameRecorderVideo(option); - } - /// /// [wx.removeStorageSync(string key)](https://developers.weixin.qq.com/minigame/dev/api/storage/wx.removeStorageSync.html) /// [wx.removeStorage](https://developers.weixin.qq.com/minigame/dev/api/storage/wx.removeStorage.html) 的同步版本 @@ -2613,7 +2610,7 @@ namespace WeChatWASM /// /// [wx.reportUserBehaviorBranchAnalytics(Object object)](https://developers.weixin.qq.com/minigame/dev/api/data-analysis/wx.reportUserBehaviorBranchAnalytics.html) /// 需要基础库: `2.12.0` - /// 用于分支相关的UI组件(一般是按钮)相关事件的上报,事件目前有曝光、点击两种 + /// 上报场景分析,用于UI组件(一般是按钮)相关事件的上报,事件目前有曝光、点击两种,查看[相关文档](https://developers.weixin.qq.com/minigame/analysis/selfanalysis.html) /// public static void ReportUserBehaviorBranchAnalytics(ReportUserBehaviorBranchAnalyticsOption option) { @@ -2624,13 +2621,13 @@ namespace WeChatWASM /// [wx.requestPointerLock()](https://developers.weixin.qq.com/minigame/dev/api/render/cursor/wx.requestPointerLock.html) /// 需要基础库: `3.2.0` /// 锁定鼠标指针。锁定指针后,鼠标会被隐藏,可以通过 [wx.touchMove](#) 事件获取鼠标偏移量。 **此接口仅在 Windows、Mac 端支持,且必须在用户进行操作后才可调用。** - /// **示例代码 + /// **示例代码** /// ```js /// wx.onTouchEnd(() => { /// wx.requestPointerLock() // 触发鼠标锁定 /// }) /// ``` - /// 示例 demo** + /// **示例 demo** /// 下方打开后点按窗口会鼠标锁定,同时会在 touchMove 时持续在控制台打印偏移量。 /// [https://developers.weixin.qq.com/s/wGruMHm97tMF](https://developers.weixin.qq.com/s/wGruMHm97tMF) /// </summary> @@ -2639,16 +2636,6 @@ namespace WeChatWASM WXSDKManagerHandler.Instance.RequestPointerLock(); } - /// <summary> - /// [wx.reserveChannelsLive(Object object)](https://developers.weixin.qq.com/minigame/dev/api/open-api/channels/wx.reserveChannelsLive.html) - /// 需要基础库: `2.19.0` - /// 预约视频号直播 - /// </summary> - public static void ReserveChannelsLive(ReserveChannelsLiveOption option) - { - WXSDKManagerHandler.Instance.ReserveChannelsLive(option); - } - /// <summary> /// [wx.revokeBufferURL(string url)](https://developers.weixin.qq.com/minigame/dev/api/storage/wx.revokeBufferURL.html) /// 需要基础库: `2.14.0` @@ -2994,6 +2981,36 @@ namespace WeChatWASM WXSDKManagerHandler.Instance.OffError(error); } + /// <summary> + /// [wx.onGamepadConnected(function listener)](https://developers.weixin.qq.com/minigame/dev/api/device/gamepad/wx.onGamepadConnected.html) + /// 需要基础库: `3.6.4` + /// 监听用户已连接游戏手柄的事件。 + /// </summary> + public static void OnGamepadConnected(Action<OnGamepadConnectedListenerResult> result) + { + WXSDKManagerHandler.Instance.OnGamepadConnected(result); + } + + public static void OffGamepadConnected(Action<OnGamepadConnectedListenerResult> result) + { + WXSDKManagerHandler.Instance.OffGamepadConnected(result); + } + + /// <summary> + /// [wx.onGamepadDisconnected(function listener)](https://developers.weixin.qq.com/minigame/dev/api/device/gamepad/wx.onGamepadDisconnected.html) + /// 需要基础库: `3.6.4` + /// 监听用户断开游戏手柄的事件。 + /// </summary> + public static void OnGamepadDisconnected(Action<OnGamepadDisconnectedListenerResult> result) + { + WXSDKManagerHandler.Instance.OnGamepadDisconnected(result); + } + + public static void OffGamepadDisconnected(Action<OnGamepadDisconnectedListenerResult> result) + { + WXSDKManagerHandler.Instance.OffGamepadDisconnected(result); + } + /// <summary> /// [wx.onHide(function listener)](https://developers.weixin.qq.com/minigame/dev/api/base/app/life-cycle/wx.onHide.html) /// 监听小游戏隐藏到后台事件。锁屏、按 HOME 键退到桌面、显示在聊天顶部等操作会触发此事件。 @@ -3055,7 +3072,7 @@ namespace WeChatWASM /// <summary> /// [wx.onKeyboardComplete(function listener)](https://developers.weixin.qq.com/minigame/dev/api/device/keyboard/wx.onKeyboardComplete.html) - /// 监听监听键盘收起的事件 + /// 监听键盘收起的事件 /// </summary> public static void OnKeyboardComplete(Action<OnKeyboardInputListenerResult> result) { @@ -3124,9 +3141,9 @@ namespace WeChatWASM /// **示例代码** /// ```js /// wx.onMemoryWarning(function () { - /// console.log('onMemoryWarningReceive') + /// console.log('onMemoryWarningReceive') /// }) - /// `` + /// ``` /// </summary> public static void OnMemoryWarning(Action<OnMemoryWarningListenerResult> result) { @@ -3283,6 +3300,10 @@ namespace WeChatWASM WXSDKManagerHandler.Instance.OnShareMessageToFriend(result); } + public static void OffShareMessageToFriend(Action<OnShareMessageToFriendListenerResult> result) + { + WXSDKManagerHandler.Instance.OffShareMessageToFriend(result); + } /// <summary> /// [wx.onShow(function listener)](https://developers.weixin.qq.com/minigame/dev/api/base/app/life-cycle/wx.onShow.html) @@ -3512,6 +3533,24 @@ namespace WeChatWASM WXSDKManagerHandler.Instance.OffGameLiveStateChange(callback); } + /// <summary> + /// [Array.<Object> wx.getGamepads()](https://developers.weixin.qq.com/minigame/dev/api/device/gamepad/wx.getGamepads.html) + /// 需要基础库: `3.6.4` + /// 获取已连接的游戏手柄信息,仅在 PC 平台支持。 + /// **示例代码** + /// ```js + /// const gamepads = wx.getGamepads(); + /// console.log(gamepads); + /// ``` + /// **示例代码片段** + /// [在微信开发者工具中查看示例](https://developers.weixin.qq.com/s/6al1r2m17oV6) + /// </summary> + /// <returns></returns> + public static string[] GetGamepads() + { + return WXSDKManagerHandler.GetGamepads(); + } + /// <summary> /// [Boolean wx.setHandoffQuery(String query)](https://developers.weixin.qq.com/minigame/dev/api/share/wx.setHandoffQuery.html) /// 需要基础库: `2.14.4` @@ -3520,7 +3559,7 @@ namespace WeChatWASM /// <returns></returns> public static bool SetHandoffQuery(string query) { - return WXSDKManagerHandler.Instance.SetHandoffQuery(query); + return WXSDKManagerHandler.SetHandoffQuery(query); } /// <summary> @@ -3538,7 +3577,7 @@ namespace WeChatWASM /// <returns></returns> public static AccountInfo GetAccountInfoSync() { - return WXSDKManagerHandler.Instance.GetAccountInfoSync(); + return WXSDKManagerHandler.GetAccountInfoSync(); } /// <summary> @@ -3568,7 +3607,7 @@ namespace WeChatWASM /// <returns></returns> public static AppAuthorizeSetting GetAppAuthorizeSetting() { - return WXSDKManagerHandler.Instance.GetAppAuthorizeSetting(); + return WXSDKManagerHandler.GetAppAuthorizeSetting(); } /// <summary> @@ -3589,7 +3628,7 @@ namespace WeChatWASM /// <returns></returns> public static AppBaseInfo GetAppBaseInfo() { - return WXSDKManagerHandler.Instance.GetAppBaseInfo(); + return WXSDKManagerHandler.GetAppBaseInfo(); } /// <summary> @@ -3599,7 +3638,7 @@ namespace WeChatWASM /// <returns></returns> public static GetBatteryInfoSyncResult GetBatteryInfoSync() { - return WXSDKManagerHandler.Instance.GetBatteryInfoSync(); + return WXSDKManagerHandler.GetBatteryInfoSync(); } /// <summary> @@ -3620,7 +3659,7 @@ namespace WeChatWASM /// <returns></returns> public static DeviceInfo GetDeviceInfo() { - return WXSDKManagerHandler.Instance.GetDeviceInfo(); + return WXSDKManagerHandler.GetDeviceInfo(); } /// <summary> @@ -3652,7 +3691,7 @@ namespace WeChatWASM /// <returns></returns> public static EnterOptionsGame GetEnterOptionsSync() { - return WXSDKManagerHandler.Instance.GetEnterOptionsSync(); + return WXSDKManagerHandler.GetEnterOptionsSync(); } /// <summary> @@ -3667,7 +3706,7 @@ namespace WeChatWASM /// <returns></returns> public static T GetExptInfoSync<T>(string[] keys) { - return WXSDKManagerHandler.Instance.GetExptInfoSync<T>(keys); + return WXSDKManagerHandler.GetExptInfoSync<T>(keys); } /// <summary> @@ -3685,7 +3724,7 @@ namespace WeChatWASM /// <returns></returns> public static T GetExtConfigSync<T>() { - return WXSDKManagerHandler.Instance.GetExtConfigSync<T>(); + return WXSDKManagerHandler.GetExtConfigSync<T>(); } /// <summary> @@ -3707,7 +3746,7 @@ namespace WeChatWASM /// <returns></returns> public static LaunchOptionsGame GetLaunchOptionsSync() { - return WXSDKManagerHandler.Instance.GetLaunchOptionsSync(); + return WXSDKManagerHandler.GetLaunchOptionsSync(); } /// <summary> @@ -3728,7 +3767,7 @@ namespace WeChatWASM /// <returns></returns> public static ClientRect GetMenuButtonBoundingClientRect() { - return WXSDKManagerHandler.Instance.GetMenuButtonBoundingClientRect(); + return WXSDKManagerHandler.GetMenuButtonBoundingClientRect(); } /// <summary> @@ -3758,7 +3797,7 @@ namespace WeChatWASM /// <returns></returns> public static GetStorageInfoSyncOption GetStorageInfoSync() { - return WXSDKManagerHandler.Instance.GetStorageInfoSync(); + return WXSDKManagerHandler.GetStorageInfoSync(); } /// <summary> @@ -3767,7 +3806,7 @@ namespace WeChatWASM /// <returns></returns> public static SystemInfo GetSystemInfoSync() { - return WXSDKManagerHandler.Instance.GetSystemInfoSync(); + return WXSDKManagerHandler.GetSystemInfoSync(); } /// <summary> @@ -3786,7 +3825,7 @@ namespace WeChatWASM /// <returns></returns> public static SystemSetting GetSystemSetting() { - return WXSDKManagerHandler.Instance.GetSystemSetting(); + return WXSDKManagerHandler.GetSystemSetting(); } /// <summary> @@ -3809,7 +3848,7 @@ namespace WeChatWASM /// <returns></returns> public static WindowInfo GetWindowInfo() { - return WXSDKManagerHandler.Instance.GetWindowInfo(); + return WXSDKManagerHandler.GetWindowInfo(); } /// <summary> @@ -3825,7 +3864,7 @@ namespace WeChatWASM /// <returns></returns> public static ImageData CreateImageData(double width, double height) { - return WXSDKManagerHandler.Instance.CreateImageData(width, height); + return WXSDKManagerHandler.CreateImageData(width, height); } /// <summary> @@ -3836,7 +3875,7 @@ namespace WeChatWASM /// <returns></returns> public static Path2D CreatePath2D() { - return WXSDKManagerHandler.Instance.CreatePath2D(); + return WXSDKManagerHandler.CreatePath2D(); } /// <summary> @@ -3847,7 +3886,7 @@ namespace WeChatWASM /// <returns></returns> public static bool IsPointerLocked() { - return WXSDKManagerHandler.Instance.IsPointerLocked(); + return WXSDKManagerHandler.IsPointerLocked(); } /// <summary> @@ -3862,7 +3901,7 @@ namespace WeChatWASM /// <returns></returns> public static bool IsVKSupport(string version) { - return WXSDKManagerHandler.Instance.IsVKSupport(version); + return WXSDKManagerHandler.IsVKSupport(version); } /// <summary> @@ -3876,16 +3915,16 @@ namespace WeChatWASM /// <returns></returns> public static bool SetCursor(string path, double x, double y) { - return WXSDKManagerHandler.Instance.SetCursor(path, x, y); + return WXSDKManagerHandler.SetCursor(path, x, y); } /// <summary> /// [boolean wx.setMessageToFriendQuery(Object object)](https://developers.weixin.qq.com/minigame/dev/api/share/wx.setMessageToFriendQuery.html) /// 设置 wx.shareMessageToFriend 接口 query 字段的值 - /// **提示 + /// **提示** /// 1. 此处的 query 参数与 wx.onShow 取到的启动查询参数 query 不是同一个概念,仅仅是启动查询参数会增加一个字段为 query。 /// 2. query 参数如涉及 "?"和"&" 等特殊符号,需自行进行 encodeURIComponent 和 decodeURIComponent 等操作。 - /// 示例代码 + /// **示例代码** /// ```js /// // 发送方 /// wx.setMessageToFriendQuery({ @@ -3895,7 +3934,8 @@ namespace WeChatWASM /// // 预期接收方可以通过以下方式拿到设置 /// wx.getEnterOptionsSync().query.shareMessageToFriendScene // 1 /// wx.getEnterOptionsSync().query.query // 'testquery' - /// 示例代码-特殊字符query** + /// ``` + /// **示例代码-特殊字符query** /// ```js /// // 发送方 /// wx.setMessageToFriendQuery({ @@ -3910,7 +3950,7 @@ namespace WeChatWASM /// <returns></returns> public static bool SetMessageToFriendQuery(SetMessageToFriendQueryOption option) { - return WXSDKManagerHandler.Instance.SetMessageToFriendQuery(option); + return WXSDKManagerHandler.SetMessageToFriendQuery(option); } /// <summary> @@ -3920,7 +3960,7 @@ namespace WeChatWASM /// <returns></returns> public static double GetTextLineHeight(GetTextLineHeightOption option) { - return WXSDKManagerHandler.Instance.GetTextLineHeight(option); + return WXSDKManagerHandler.GetTextLineHeight(option); } /// <summary> @@ -3930,7 +3970,7 @@ namespace WeChatWASM /// <returns></returns> public static string LoadFont(string path) { - return WXSDKManagerHandler.Instance.LoadFont(path); + return WXSDKManagerHandler.LoadFont(path); } /// <summary> @@ -3939,7 +3979,7 @@ namespace WeChatWASM /// <returns></returns> public static GameLiveState GetGameLiveState() { - return WXSDKManagerHandler.Instance.GetGameLiveState(); + return WXSDKManagerHandler.GetGameLiveState(); } /// <summary> diff --git a/Runtime/WXBase.cs b/Runtime/WXBase.cs index 52ccdce1b..eaefbe801 100644 --- a/Runtime/WXBase.cs +++ b/Runtime/WXBase.cs @@ -446,9 +446,9 @@ namespace WeChatWASM /// 获取开放数据域,关系链相关可以参看 https://developers.weixin.qq.com/minigame/dev/guide/open-ability/open-data.html /// </summary> /// <returns>开放数据域对象</returns> - public static WXOpenDataContext GetOpenDataContext() + public static WXOpenDataContext GetOpenDataContext(OpenDataContextOption option = null) { - return new WXOpenDataContext(); + return new WXOpenDataContext(option); } /// <summary> @@ -1106,6 +1106,17 @@ namespace WeChatWASM { return WXSDKManagerHandler.CallJSFunctionWithReturn(sdkName, functionName, args); } + + // TODO: 声明错误临时处理 + /// <summary> + /// [wx.reserveChannelsLive(Object object)](https://developers.weixin.qq.com/minigame/dev/api/open-api/channels/wx.reserveChannelsLive.html) + /// 需要基础库: `2.19.0` + /// 预约视频号直播 + /// </summary> + public static void ReserveChannelsLive(ReserveChannelsLiveOption option) + { + WXSDKManagerHandler.Instance.ReserveChannelsLive(option); + } } } #endif diff --git a/Runtime/WXProfileStatsScript.cs b/Runtime/WXProfileStatsScript.cs index bffc919fa..a2fda5f22 100644 --- a/Runtime/WXProfileStatsScript.cs +++ b/Runtime/WXProfileStatsScript.cs @@ -264,9 +264,9 @@ public class WXProfileStatsScript : MonoBehaviour, WeChatWASM.WXSDKManagerHandle m_fpsCount++; m_fpsDeltaTime += Time.deltaTime; - if (m_fpsCount % 60 == 0) + if (m_fpsCount % 60 == 0 && m_fpsDeltaTime != 0.0f) { - m_fpsCount = 1; + m_fpsCount = 0; fps = (int)Mathf.Ceil(60.0f / m_fpsDeltaTime); m_fpsDeltaTime = 0; } diff --git a/Runtime/WXRuntimeExtDef.cs b/Runtime/WXRuntimeExtDef.cs index 6fd6dbec2..72ca88f2a 100644 --- a/Runtime/WXRuntimeExtDef.cs +++ b/Runtime/WXRuntimeExtDef.cs @@ -89,6 +89,11 @@ namespace WeChatWASM #else WXRuntimeExtEnvDef.SETDEF("TUANJIE_2022_3_OR_NEWER", false); #endif +#if UNITY_6000_0_OR_NEWER + WXRuntimeExtEnvDef.SETDEF("UNITY_6000_0_OR_NEWER", true); +#else + WXRuntimeExtEnvDef.SETDEF("UNITY_6000_0_OR_NEWER", false); +#endif #if PLATFORM_WEIXINMINIGAME WXRuntimeExtEnvDef.SETDEF("PLATFORM_WEIXINMINIGAME", true); diff --git a/Runtime/WXSDKPerf/WXPerfEngine.cs b/Runtime/WXSDKPerf/WXPerfEngine.cs index afae70150..00552b351 100644 --- a/Runtime/WXSDKPerf/WXPerfEngine.cs +++ b/Runtime/WXSDKPerf/WXPerfEngine.cs @@ -34,7 +34,14 @@ namespace WXSDKPerf #endif } - + /// <summary> + /// This method is used to add an annotation to the performance data. + /// The annotation string is uploaded to the server along with the current frame ID. + /// </summary> + /// <param name="InAnnotationString">The annotation string to be added. It should not be null or empty.</param> + /// <remarks> + /// If the provided annotation string is null or empty, an error message will be logged. + /// </remarks> public static void Annotation(string InAnnotationString) { #if UNITY_EDITOR @@ -53,7 +60,20 @@ namespace WXSDKPerf m_PerfEngineImplementation.Annotation(InAnnotationString); #endif + } + + /// <summary> + /// 检查是否正在录制性能数据 + /// </summary> + /// <returns>如果正在录制返回true,否则返回false</returns> + public static bool IsRecording() + { +#if UNITY_EDITOR + return false; +#else + return m_PerfEngineImplementation != null && m_PerfEngineImplementation.IsRecording(); +#endif } private static void TakeAndUploadUnityMemorySnapshot() @@ -75,7 +95,11 @@ namespace WXSDKPerf #endif #endif } - + + /// <summary> + /// 指定luaState + /// </summary> + /// <param name="L">luaState</param> public static void SetLuaState(IntPtr L) { #if UNITY_EDITOR @@ -90,8 +114,116 @@ namespace WXSDKPerf m_PerfEngineImplementation.SetLuaState(L); #endif } - } + + /// <summary> + /// 声明自定义性能指标 + /// </summary> + /// <param name="inStatName">性能指标名称</param> + /// <param name="inStatCategory">性能指标类别</param> + /// <param name="inStatInterpType">性能指标展示方式,0. 不插值. 1. 线性插值;2. Step插值;</param> + public static void DeclareCustomStatInfo(string inStatName, string inStatCategory, int inStatInterpType = 1) + { +#if UNITY_EDITOR + return; +#else + if (m_PerfEngineImplementation == null) + { + UnityEngine.Debug.LogError("DeclareCustomStatInfo: Invalid m_PerfEngineImplementation! "); + return; + } + m_PerfEngineImplementation.DeclareCustomStatInfo(inStatName, inStatCategory, inStatInterpType); +#endif + } + + /// <summary> + /// 设置自定义性能指标,目前只支持浮点数 + /// 若该指标未通过DeclareCustomStatInfo进行类别的声明,则将被归为默认自定义类别,以及使用默认线性插值 + /// </summary> + /// <param name="inStatName">性能指标名称</param> + /// <param name="inValue">性能指标数值</param> + public static void SetCustomStatValue(string inStatName, float inValue) + { +#if UNITY_EDITOR + return; +#else + if (m_PerfEngineImplementation == null) + { + UnityEngine.Debug.LogError("SetCustomStatInfo: Invalid m_PerfEngineImplementation! "); + return; + } + + m_PerfEngineImplementation.SetCustomStatInfo(inStatName, inValue); +#endif + } + + /// 在自定义性能指标值的基础上增加一段数值。 + /// 如果未进行指标声明,将自动声明该指标,该指标将出现在报告的“Project Default Stat Category”中 + /// </summary> + /// <param name="inStatName">性能指标名称</param> + /// <param name="inValue">性能指标数值</param> + public static void AddCustomStatInfoBy(string inStatName, float inValue) + { +#if UNITY_EDITOR + return; +#else + if (m_PerfEngineImplementation == null) + { + UnityEngine.Debug.LogError("AddCustomStatInfoBy: Invalid m_PerfEngineImplementation! "); + return; + } + + m_PerfEngineImplementation.AddCustomStatInfoBy(inStatName, inValue); +#endif + + } + + + /// <summary> + /// 手动开始记录 + /// </summary> + /// <param name="inEnableStackTrace">是否启用堆栈跟踪</param> + /// <param name="inEnableStatInfo">是否启用统计信息</param> + /// <param name="inFrequentScreenShot">是否频繁截图</param> + /// <param name="inEnablebRenderInst">是否记录渲染指令</param> + /// <param name="inEnableCaptureResource">是否启用资源捕获</param> + /// <param name="inEnableLuaMemoryMonitor">是否启用Lua内存监控</param> + /// <param name="inEnableLuaFunctionMemoryTracking">是否启用Lua函数内存跟踪</param> + public static void StartRecordManually(bool inEnableStackTrace, bool inEnableStatInfo, bool inFrequentScreenShot, bool inEnablebRenderInst, + bool inEnableCaptureResource, bool inEnableLuaMemoryMonitor, bool inEnableLuaFunctionMemoryTracking) + { +#if UNITY_EDITOR + return; +#else + if (m_PerfEngineImplementation == null) + { + UnityEngine.Debug.LogError("StartRecordManually: Invalid m_PerfEngineImplementation! "); + return; + } + + m_PerfEngineImplementation.StartRecordManually(inEnableStackTrace, inEnableStatInfo, inFrequentScreenShot, inEnablebRenderInst, + inEnableCaptureResource, inEnableLuaMemoryMonitor, inEnableLuaFunctionMemoryTracking); +#endif + } + + /// <summary> + /// 手动停止记录 + /// </summary> + public static void StopRecordManually() + { +#if UNITY_EDITOR + return; +#else + if (m_PerfEngineImplementation == null) + { + UnityEngine.Debug.LogError("StartRecordManually: Invalid m_PerfEngineImplementation! "); + return; + } + + m_PerfEngineImplementation.StopRecordManually(); +#endif + } + } } #endif diff --git a/Runtime/WXTouchInputOverride.cs b/Runtime/WXTouchInputOverride.cs index 78e1f7887..dc7ca2b6d 100644 --- a/Runtime/WXTouchInputOverride.cs +++ b/Runtime/WXTouchInputOverride.cs @@ -38,7 +38,7 @@ public class WXTouchInputOverride : BaseInput { base.OnEnable(); #if UNITY_WEBGL && !UNITY_EDITOR - if (string.IsNullOrEmpty(WeChatWASM.WX.GetDeviceInfo().platform)) return; + if (string.IsNullOrEmpty(WeChatWASM.WX.GetSystemInfoSync().platform)) return; InitWechatTouchEvents(); if (_standaloneInputModule) { @@ -144,7 +144,30 @@ public class WXTouchInputOverride : BaseInput button.onClick.Invoke(); button.onClick.SetPersistentListenerState(0, UnityEventCallState.Off); } + } +#if !UNITY_EDITOR + Text text = selectedObject.GetComponent<Text>(); + if (text != null) + { +#if PLATFORM_WEIXINMINIGAME + WeixinMiniGameInput.mobileKeyboardSupport = true; +#elif PLATFORM_WEBGL +#if UNITY_2022_1_OR_NEWER + WebGLInput.mobileKeyboardSupport = true; +#endif +#endif } + else + { +#if PLATFORM_WEIXINMINIGAME + WeixinMiniGameInput.mobileKeyboardSupport = false; +#elif PLATFORM_WEBGL +#if UNITY_2022_1_OR_NEWER + WebGLInput.mobileKeyboardSupport = false; +#endif +#endif + } +#endif } } diff --git a/Runtime/wechat-default/check-version.js b/Runtime/wechat-default/check-version.js index e9e0a97b3..1f65ece21 100644 --- a/Runtime/wechat-default/check-version.js +++ b/Runtime/wechat-default/check-version.js @@ -1,7 +1,7 @@ /* eslint-disable no-multi-assign */ /* eslint-disable @typescript-eslint/naming-convention */ -const { version, SDKVersion } = wx.getAppBaseInfo(); -const { platform, system } = wx.getDeviceInfo(); +const { version, SDKVersion } = wx.getAppBaseInfo ? wx.getAppBaseInfo() : wx.getSystemInfoSync(); +const { platform, system } = wx.getDeviceInfo ? wx.getDeviceInfo() : wx.getSystemInfoSync(); const accountInfo = wx.getAccountInfoSync(); const envVersion = accountInfo?.miniProgram?.envVersion; function compareVersion(v1, v2) { @@ -17,6 +17,7 @@ function compareVersion(v1, v2) { .map(v => v.padStart(2, '0')) .join('')); } +export const isDebug = false; export const isPc = platform === 'windows' || platform === 'mac'; export const isIOS = platform === 'ios'; export const isAndroid = platform === 'android'; @@ -63,7 +64,9 @@ const isMobileBrotliInvalid = isMobile && !compareVersion(SDKVersion, '2.21.1'); // @ts-ignore const isBrotliInvalid = $COMPRESS_DATA_PACKAGE && (isPcBrotliInvalid || isMobileBrotliInvalid); // iOS系统版本>=17.5时,小游戏退后台会导致异常 -export const isIOS175 = compareVersion(systemVersion, '17.5') || isH5Renderer; +export const isIOS175 = compareVersion(systemVersion, '17.5') && isH5Renderer; +// 是否支持开放数据域渲染模式,使用ScreenCanvas模式可以优化ToTempFilePath的使用 +export const isSupportSharedCanvasMode = compareVersion(SDKVersion, '3.6.6'); // 是否能以iOS高性能模式运行 // 请勿修改GameGlobal.canUseH5Renderer赋值!!! GameGlobal.canUseH5Renderer = isH5Renderer && isH5LibVersionValid; diff --git a/Runtime/wechat-default/check-version.js.meta b/Runtime/wechat-default/check-version.js.meta index de6b1f8de..248c584cf 100644 --- a/Runtime/wechat-default/check-version.js.meta +++ b/Runtime/wechat-default/check-version.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: ae20ea906e2a2be4a56e281bb00457a0 +guid: fe0bcf83e5927674a4a4198b13d502ad DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/data-package/game.js.meta b/Runtime/wechat-default/data-package/game.js.meta index 18b1f8ad2..10f461667 100644 --- a/Runtime/wechat-default/data-package/game.js.meta +++ b/Runtime/wechat-default/data-package/game.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d44e34cd3ca3b2196e3bde9a91d17af5 +guid: 89da7514871218aac104ffcde6677d85 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/events.js.meta b/Runtime/wechat-default/events.js.meta index 3c3d5efeb..0893390bc 100644 --- a/Runtime/wechat-default/events.js.meta +++ b/Runtime/wechat-default/events.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 7ef14169da4b9ee5ea8193cb7b0aa17b +guid: 06ec53b2d71a903129af210e7952c6d8 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/game.js.meta b/Runtime/wechat-default/game.js.meta index fb647b6e8..9aec37732 100644 --- a/Runtime/wechat-default/game.js.meta +++ b/Runtime/wechat-default/game.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: abf2c8555e627babf06e35475f6ac7e1 +guid: a82792729d9f0f9812f8d360d55162bb DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/game.json b/Runtime/wechat-default/game.json index 0b7137050..2fd4a2b59 100644 --- a/Runtime/wechat-default/game.json +++ b/Runtime/wechat-default/game.json @@ -23,7 +23,7 @@ ], "plugins": { "UnityPlugin": { - "version": "1.2.63", + "version": "1.2.65", "provider": "wxe5a48f1ed5f544b7", "contexts": [ { diff --git a/Runtime/wechat-default/game.json.meta b/Runtime/wechat-default/game.json.meta index 1b6b3779b..971d368dd 100644 --- a/Runtime/wechat-default/game.json.meta +++ b/Runtime/wechat-default/game.json.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 7f92a7defc2de54557688c48cfd6187a +guid: bd94565b5f5f0c6f754c6fdf1e2f3f46 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/images/background.jpg.meta b/Runtime/wechat-default/images/background.jpg.meta index fdea54e40..a4c8be066 100644 --- a/Runtime/wechat-default/images/background.jpg.meta +++ b/Runtime/wechat-default/images/background.jpg.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 208a3d3b035439598cebd18db371ed31 +guid: 4fc440f3412e2458bf66719ae1d60924 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/images/unity_logo.png.meta b/Runtime/wechat-default/images/unity_logo.png.meta index 3bda0c316..c620ee265 100644 --- a/Runtime/wechat-default/images/unity_logo.png.meta +++ b/Runtime/wechat-default/images/unity_logo.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 040074cce8dcc4e7c914018c9d32e7e3 +guid: 5e75a0e04ac04517c16a8471b07c81e5 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/open-data/data/index.js.meta b/Runtime/wechat-default/open-data/data/index.js.meta index 4da577b97..d29fde89a 100644 --- a/Runtime/wechat-default/open-data/data/index.js.meta +++ b/Runtime/wechat-default/open-data/data/index.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 1384bc8cbbdeaedcc89a37b546ab6956 +guid: 52354d70a9efb4918dadbaab89605663 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/open-data/data/utils.js.meta b/Runtime/wechat-default/open-data/data/utils.js.meta index b8a984983..e0686432f 100644 --- a/Runtime/wechat-default/open-data/data/utils.js.meta +++ b/Runtime/wechat-default/open-data/data/utils.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 22bceeda40fc20a2574640172bb5ee2c +guid: f29feeb91e62e414a8c436059dc204f3 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/open-data/index.js.meta b/Runtime/wechat-default/open-data/index.js.meta index 46154963d..49b22a5d1 100644 --- a/Runtime/wechat-default/open-data/index.js.meta +++ b/Runtime/wechat-default/open-data/index.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: ea26f1397a46231b336029635611c91d +guid: b4068dcde906e960877018e073ed37ac DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/open-data/loading.js.meta b/Runtime/wechat-default/open-data/loading.js.meta index 7a250de80..74512484a 100644 --- a/Runtime/wechat-default/open-data/loading.js.meta +++ b/Runtime/wechat-default/open-data/loading.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 233b6f50c7b41bd0b43fb110d26d60e7 +guid: 48988177116c69c2b1e5efc5b9316299 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/open-data/render/image/avatar.png.meta b/Runtime/wechat-default/open-data/render/image/avatar.png.meta index 66c1016c8..4e563d521 100644 --- a/Runtime/wechat-default/open-data/render/image/avatar.png.meta +++ b/Runtime/wechat-default/open-data/render/image/avatar.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c89770e6eb650a852c2ede0d95a18ba2 +guid: ead859e2530842e680b7b013918eb849 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/open-data/render/image/button1.png.meta b/Runtime/wechat-default/open-data/render/image/button1.png.meta index e43625e46..e9f6234d2 100644 --- a/Runtime/wechat-default/open-data/render/image/button1.png.meta +++ b/Runtime/wechat-default/open-data/render/image/button1.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a8ccf87ca2e8b5533ff9c5943c0bd78e +guid: 2e98cbff498d4e17791f38d542e0ff34 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/open-data/render/image/button2.png.meta b/Runtime/wechat-default/open-data/render/image/button2.png.meta index 04334b9f2..75b9bbf2a 100644 --- a/Runtime/wechat-default/open-data/render/image/button2.png.meta +++ b/Runtime/wechat-default/open-data/render/image/button2.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a427c161f1a002c7d6205db1d25b4af2 +guid: 5ef3f0b6382e4ef978defdc6b96d1dad DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/open-data/render/image/button3.png.meta b/Runtime/wechat-default/open-data/render/image/button3.png.meta index fac819cca..9339eef04 100644 --- a/Runtime/wechat-default/open-data/render/image/button3.png.meta +++ b/Runtime/wechat-default/open-data/render/image/button3.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: ea0cac811524ccbcfe556550d3359416 +guid: 700f0e41d89e1bd39e81fcd907518b40 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/open-data/render/image/loading.png.meta b/Runtime/wechat-default/open-data/render/image/loading.png.meta index df62d5bba..07750c926 100644 --- a/Runtime/wechat-default/open-data/render/image/loading.png.meta +++ b/Runtime/wechat-default/open-data/render/image/loading.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 43c3f3df3658febd6f31815b5f8865e9 +guid: 1f1eabc1a223a4520e841735c6a6c597 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/open-data/render/image/nameBg.png.meta b/Runtime/wechat-default/open-data/render/image/nameBg.png.meta index a87be236a..061466541 100644 --- a/Runtime/wechat-default/open-data/render/image/nameBg.png.meta +++ b/Runtime/wechat-default/open-data/render/image/nameBg.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e3f33306a0f7712bbd5d9a00fb2803fc +guid: 49ea2ada0b457c0991aeb39559886099 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/open-data/render/image/rankAvatar.png.meta b/Runtime/wechat-default/open-data/render/image/rankAvatar.png.meta index 5729e0e3e..fa114928a 100644 --- a/Runtime/wechat-default/open-data/render/image/rankAvatar.png.meta +++ b/Runtime/wechat-default/open-data/render/image/rankAvatar.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4dd96dbcc57d6fdabba37b6b0eaf7a73 +guid: e1fd3c58caaca70d86d1098a43a5bc10 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/open-data/render/image/rankBg.png.meta b/Runtime/wechat-default/open-data/render/image/rankBg.png.meta index 2d450e1f9..1f078063f 100644 --- a/Runtime/wechat-default/open-data/render/image/rankBg.png.meta +++ b/Runtime/wechat-default/open-data/render/image/rankBg.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 84f4c37b3d3f75af65a87cbae19f478a +guid: 60e76236db56208a00ff86226f7a8910 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/open-data/render/image/shareBg.png.meta b/Runtime/wechat-default/open-data/render/image/shareBg.png.meta index f3f52997c..6b4e7274d 100644 --- a/Runtime/wechat-default/open-data/render/image/shareBg.png.meta +++ b/Runtime/wechat-default/open-data/render/image/shareBg.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 3e006600c6d7a534d0398dc3e064e616 +guid: 9c3732983037ca82075e610f2602e21a DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/open-data/render/image/shareBg2.png.meta b/Runtime/wechat-default/open-data/render/image/shareBg2.png.meta index 75eb483ca..ba293fdc9 100644 --- a/Runtime/wechat-default/open-data/render/image/shareBg2.png.meta +++ b/Runtime/wechat-default/open-data/render/image/shareBg2.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 5d307099e356baa4d07d2767b0f2d52b +guid: 0e94f7325962d5b14c97d84aeee56cc7 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/open-data/render/styles/friendRank.js.meta b/Runtime/wechat-default/open-data/render/styles/friendRank.js.meta index 8874ca541..2edee1e18 100644 --- a/Runtime/wechat-default/open-data/render/styles/friendRank.js.meta +++ b/Runtime/wechat-default/open-data/render/styles/friendRank.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: da16a73e2603b59c75d006937e366898 +guid: 581e44a63a9c7593d95a639a7526f016 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/open-data/render/styles/tips.js.meta b/Runtime/wechat-default/open-data/render/styles/tips.js.meta index 5a45f5ea7..247f0a002 100644 --- a/Runtime/wechat-default/open-data/render/styles/tips.js.meta +++ b/Runtime/wechat-default/open-data/render/styles/tips.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 9e73bfab43c8dadfb966f0c7c5a0d6a8 +guid: 97df967211e82448ccdfe83ee1a403d7 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/open-data/render/tpls/friendRank.js.meta b/Runtime/wechat-default/open-data/render/tpls/friendRank.js.meta index e877d51f5..39bf0eb4b 100644 --- a/Runtime/wechat-default/open-data/render/tpls/friendRank.js.meta +++ b/Runtime/wechat-default/open-data/render/tpls/friendRank.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d0afa943b1d7326b82e09ad11ee12ce1 +guid: 03a8004dfb12cca822f9b6abfc939bb5 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/open-data/render/tpls/tips.js.meta b/Runtime/wechat-default/open-data/render/tpls/tips.js.meta index 0615bc5a7..84a263c9d 100644 --- a/Runtime/wechat-default/open-data/render/tpls/tips.js.meta +++ b/Runtime/wechat-default/open-data/render/tpls/tips.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 5b5d5def2035bb5a6ba0fe31922c110f +guid: 30f5b6fd4b64277ff72faea15cfd65c5 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/plugin-config.js.meta b/Runtime/wechat-default/plugin-config.js.meta index c0fa0ef38..2d0ddf8a4 100644 --- a/Runtime/wechat-default/plugin-config.js.meta +++ b/Runtime/wechat-default/plugin-config.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c8645a28cae8902edf5703237ca8b6af +guid: 70dafc4543ef5e705c265c95284559a1 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/plugins/check-update.js.meta b/Runtime/wechat-default/plugins/check-update.js.meta index 2619be474..5fcbbf1e0 100644 --- a/Runtime/wechat-default/plugins/check-update.js.meta +++ b/Runtime/wechat-default/plugins/check-update.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: db36b24b6a7dbe9197be126b963c675c +guid: a9ebf59502214c651ec435c855bd0c89 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/plugins/screen-adapter.js.meta b/Runtime/wechat-default/plugins/screen-adapter.js.meta index a44f81de1..c7b21cc56 100644 --- a/Runtime/wechat-default/plugins/screen-adapter.js.meta +++ b/Runtime/wechat-default/plugins/screen-adapter.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: ea4320007aa2db45535fcd3fedcc6e3f +guid: 7782e956b2be6bb57afe9260238e2693 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/project.config.json.meta b/Runtime/wechat-default/project.config.json.meta index 91ab4381d..9646702ff 100644 --- a/Runtime/wechat-default/project.config.json.meta +++ b/Runtime/wechat-default/project.config.json.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 640d66690338eaecd8a7fb8318c12ed8 +guid: e3e0a09ed0d3a50696eea330cb6b1fcd DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/texture-config.js.meta b/Runtime/wechat-default/texture-config.js.meta index 4307b5605..0d573f81b 100644 --- a/Runtime/wechat-default/texture-config.js.meta +++ b/Runtime/wechat-default/texture-config.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e039df48f6103eee9804da0dbf57680a +guid: b50a86316eaac3d01beed54510c04bb5 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-namespace.js b/Runtime/wechat-default/unity-namespace.js index c3fde6252..f0db49076 100644 --- a/Runtime/wechat-default/unity-namespace.js +++ b/Runtime/wechat-default/unity-namespace.js @@ -165,8 +165,8 @@ function bindGloblException() { GameGlobal.logmanager.info('game starting', bootinfo); console.info('game starting', bootinfo); } - const appBaseInfo = wx.getAppBaseInfo(); - const deviceInfo = wx.getDeviceInfo(); + const appBaseInfo = wx.getAppBaseInfo ? wx.getAppBaseInfo() : wx.getSystemInfoSync(); + const deviceInfo = wx.getDeviceInfo ? wx.getDeviceInfo() : wx.getSystemInfoSync(); printSystemInfo(appBaseInfo, deviceInfo); } bindGloblException(); diff --git a/Runtime/wechat-default/unity-namespace.js.meta b/Runtime/wechat-default/unity-namespace.js.meta index d816fe7cb..cb84ce3f9 100644 --- a/Runtime/wechat-default/unity-namespace.js.meta +++ b/Runtime/wechat-default/unity-namespace.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 9917ab127befc7ee177057e55d8f48a5 +guid: a47d28eb54d282c8f53feb05f758d5a7 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/TCPSocket/index.js b/Runtime/wechat-default/unity-sdk/TCPSocket/index.js index 9c3208e07..da53bff2a 100644 --- a/Runtime/wechat-default/unity-sdk/TCPSocket/index.js +++ b/Runtime/wechat-default/unity-sdk/TCPSocket/index.js @@ -9,7 +9,7 @@ const wxTCPSocketMessageList = {}; const getTCPSocketObject = getListObject(TCPSocketList, 'TCPSocket'); let wxTCPSocketOnMessageCallback; function WX_CreateTCPSocket() { - const obj = wx.createTCPSocket(); + const obj = wx.createTCPSocket({ type: 'IPv4' }); const key = uid(); TCPSocketList[key] = obj; return key; diff --git a/Runtime/wechat-default/unity-sdk/TCPSocket/index.js.meta b/Runtime/wechat-default/unity-sdk/TCPSocket/index.js.meta index 5cbd79570..acf0f3872 100644 --- a/Runtime/wechat-default/unity-sdk/TCPSocket/index.js.meta +++ b/Runtime/wechat-default/unity-sdk/TCPSocket/index.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 487cdf613f8cb752cbaca31e0d138de6 +guid: bfbeef2cd22dcd64e60e44d0a8fd5ddf DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/UDPSocket/index.js.meta b/Runtime/wechat-default/unity-sdk/UDPSocket/index.js.meta index ce4166fa3..ebcad8166 100644 --- a/Runtime/wechat-default/unity-sdk/UDPSocket/index.js.meta +++ b/Runtime/wechat-default/unity-sdk/UDPSocket/index.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 3da530387fb1faeecd13958909c406e0 +guid: 12b43839c796fac58c7d84c05abd0c66 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/ad.js.meta b/Runtime/wechat-default/unity-sdk/ad.js.meta index 5f2f1859d..4b408f481 100644 --- a/Runtime/wechat-default/unity-sdk/ad.js.meta +++ b/Runtime/wechat-default/unity-sdk/ad.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 198ad119d42105bf8716622dd232947a +guid: b8475727c0402f86318adeb6fb238cbc DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/audio/common.js.meta b/Runtime/wechat-default/unity-sdk/audio/common.js.meta index a5acdce17..8efbed177 100644 --- a/Runtime/wechat-default/unity-sdk/audio/common.js.meta +++ b/Runtime/wechat-default/unity-sdk/audio/common.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c642125e8cc4b90234ca12a935616295 +guid: c18c255df0aa5927af397234226f46f2 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/audio/const.js.meta b/Runtime/wechat-default/unity-sdk/audio/const.js.meta index 7b842591b..e01e978fd 100644 --- a/Runtime/wechat-default/unity-sdk/audio/const.js.meta +++ b/Runtime/wechat-default/unity-sdk/audio/const.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 9139c53e73f708222b75ed3d06b5b598 +guid: 56b881ebf63d3dfc611a2a49fc5cf934 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/audio/index.js.meta b/Runtime/wechat-default/unity-sdk/audio/index.js.meta index 2ccd599a9..270932540 100644 --- a/Runtime/wechat-default/unity-sdk/audio/index.js.meta +++ b/Runtime/wechat-default/unity-sdk/audio/index.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6b204482694e49e567887c4a911574bb +guid: 840bf1578fb00b7bf77cff2f6c91ed61 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/audio/inner-audio.js.meta b/Runtime/wechat-default/unity-sdk/audio/inner-audio.js.meta index 423843231..ca838ce8d 100644 --- a/Runtime/wechat-default/unity-sdk/audio/inner-audio.js.meta +++ b/Runtime/wechat-default/unity-sdk/audio/inner-audio.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f21c4e5aa0f304c285728cb0c62de861 +guid: 8f92d7b25ccdc8a22bcbcc746f6c1db1 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/audio/store.js.meta b/Runtime/wechat-default/unity-sdk/audio/store.js.meta index 11e2bedf8..a7ee254b3 100644 --- a/Runtime/wechat-default/unity-sdk/audio/store.js.meta +++ b/Runtime/wechat-default/unity-sdk/audio/store.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 543ffe10b513826c6454ef07dcc0df3a +guid: 40795b00802a1b2d446be30f4b561132 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/audio/unity-audio.js b/Runtime/wechat-default/unity-sdk/audio/unity-audio.js index 74f032604..112314977 100644 --- a/Runtime/wechat-default/unity-sdk/audio/unity-audio.js +++ b/Runtime/wechat-default/unity-sdk/audio/unity-audio.js @@ -5,6 +5,7 @@ import { isAndroid, isPc, webAudioNeedResume, isSupportBufferURL, isSupportPlayB import { WEBAudio, unityAudioVolume } from './store'; import { TEMP_DIR_PATH } from './const'; import { createInnerAudio, destroyInnerAudio, printErrMsg, resumeWebAudio } from './utils'; +import { debugLog } from '../utils'; const defaultSoundLength = 441000; @@ -205,6 +206,7 @@ export class AudioChannelInstance { } } playUrl(startTime, url, startOffset, volume, soundClip) { + debugLog('playUrl: ', url, startTime, startOffset, volume, soundClip); try { this.setup(url); if (!this.source || !this.source.mediaElement) { @@ -238,6 +240,7 @@ export class AudioChannelInstance { } }); this.source.mediaElement.onPause(() => { + debugLog('onPause'); if (typeof this.source !== 'undefined') { this.source.isPlaying = false; if (this.source.stopTicker) { @@ -247,6 +250,7 @@ export class AudioChannelInstance { } }); this.source.mediaElement.onStop(() => { + debugLog('onStop'); if (typeof this.source !== 'undefined') { if (this.source.playAfterStop) { this.source._reset(); @@ -263,6 +267,7 @@ export class AudioChannelInstance { } }); this.source.mediaElement.onEnded(() => { + debugLog('onEnded'); if (typeof this.source !== 'undefined') { this.source._reset(); this.disconnectSource(); @@ -272,6 +277,7 @@ export class AudioChannelInstance { } }); this.source.mediaElement.onError((e) => { + debugLog('onError', e); printErrMsg(e); const { errMsg } = e; @@ -350,6 +356,10 @@ export class AudioChannelInstance { disconnectSource() { if (this.source) { if (this.source.mediaElement) { + if (this.source.stopTimeout) { + clearTimeout(this.source.stopTimeout); + delete this.source.stopTimeout; + } destroyInnerAudio(this.source.instanceId, false); delete this.source.mediaElement; delete this.source; @@ -669,6 +679,7 @@ export class AudioChannelInstance { if (startDelayMS > startDelayThresholdMS) { if (this.source.playTimeout) { clearTimeout(this.source.playTimeout); + delete this.source.playTimeout; } this.source.playTimeout = setTimeout(() => { if (typeof this.source !== 'undefined') { @@ -691,7 +702,11 @@ export class AudioChannelInstance { const stopDelayThresholdMS = 4; const stopDelayMS = stopTime * 1e3; if (stopDelayMS > stopDelayThresholdMS) { - setTimeout(() => { + if (this.source.stopTimeout) { + clearTimeout(this.source.stopTimeout); + delete this.source.stopTimeout; + } + this.source.stopTimeout = setTimeout(() => { if (this.source && this.source.mediaElement) { this.source.stopCache = true; this.source.mediaElement.stop(); @@ -964,6 +979,7 @@ export default { if (!WEBAudio.audioContext || WEBAudio.audioWebEnabled === 0) { return; } + debugLog('_JS_Sound_Play', bufferInstance, channelInstance, offset, delay); WXWASMSDK._JS_Sound_Stop(channelInstance, 0); const soundClip = WEBAudio.audioInstances[bufferInstance]; const channel = WEBAudio.audioInstances[channelInstance]; @@ -1160,6 +1176,7 @@ export default { if (WEBAudio.audioWebEnabled === 0) { return; } + debugLog('_JS_Sound_Stop', channelInstance, delay); const channel = WEBAudio.audioInstances[channelInstance]; channel.stop(delay); }, diff --git a/Runtime/wechat-default/unity-sdk/audio/unity-audio.js.meta b/Runtime/wechat-default/unity-sdk/audio/unity-audio.js.meta index d6b7797c4..b841392c6 100644 --- a/Runtime/wechat-default/unity-sdk/audio/unity-audio.js.meta +++ b/Runtime/wechat-default/unity-sdk/audio/unity-audio.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 9d5c8a36b05857d2fcfd0c13740f4714 +guid: d7517ecb8615c16170baf69c20c427ea DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/audio/utils.js.meta b/Runtime/wechat-default/unity-sdk/audio/utils.js.meta index 49aa1e8c7..e2e2ddfe4 100644 --- a/Runtime/wechat-default/unity-sdk/audio/utils.js.meta +++ b/Runtime/wechat-default/unity-sdk/audio/utils.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e393ecc07f19956dbfd38a0c598a452e +guid: a15fa9ada1385c3fada61234b9afdbe1 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/authorize.js.meta b/Runtime/wechat-default/unity-sdk/authorize.js.meta index a1aaa0f0b..2c06d7bf9 100644 --- a/Runtime/wechat-default/unity-sdk/authorize.js.meta +++ b/Runtime/wechat-default/unity-sdk/authorize.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 7a39adf312ac62efae5555f371967bf8 +guid: f1cff63b9114265cb33cb295334e7517 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/bluetooth/index.js.meta b/Runtime/wechat-default/unity-sdk/bluetooth/index.js.meta index bca442d1a..61374ae52 100644 --- a/Runtime/wechat-default/unity-sdk/bluetooth/index.js.meta +++ b/Runtime/wechat-default/unity-sdk/bluetooth/index.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4378daad6e70739b33257ff7765e2751 +guid: 7398d524c42b08ddda808ef1b7003dc3 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/camera.js.meta b/Runtime/wechat-default/unity-sdk/camera.js.meta index 34a453795..4ba53f0d7 100644 --- a/Runtime/wechat-default/unity-sdk/camera.js.meta +++ b/Runtime/wechat-default/unity-sdk/camera.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e6d0e1924f5c5161d30ce3de9501f731 +guid: 39569b07e98122a75f063486aff59dec DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/canvas-context.js.meta b/Runtime/wechat-default/unity-sdk/canvas-context.js.meta index 6886794c7..c6ac75629 100644 --- a/Runtime/wechat-default/unity-sdk/canvas-context.js.meta +++ b/Runtime/wechat-default/unity-sdk/canvas-context.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 9e22e14f68f62ba0e165579bf51a291e +guid: 7268c82badac77b42ab674127e0cad24 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/canvas.js b/Runtime/wechat-default/unity-sdk/canvas.js index f9eb7ba58..380a9ee28 100644 --- a/Runtime/wechat-default/unity-sdk/canvas.js +++ b/Runtime/wechat-default/unity-sdk/canvas.js @@ -1,28 +1,6 @@ import response from './response'; import moduleHelper from './module-helper'; -import { formatJsonStr } from './utils'; -function getDefaultData(canvas, conf) { - const config = formatJsonStr(conf); - if (typeof config.x === 'undefined') { - config.x = 0; - } - if (typeof config.y === 'undefined') { - config.y = 0; - } - if (typeof config.width === 'undefined' || config.width === 0) { - config.width = canvas.width; - } - if (typeof config.height === 'undefined' || config.height === 0) { - config.height = canvas.height; - } - if (typeof config.destWidth === 'undefined' || config.destWidth === 0) { - config.destWidth = canvas.width; - } - if (typeof config.destHeight === 'undefined' || config.destHeight === 0) { - config.destHeight = canvas.height; - } - return config; -} +import { getDefaultData } from './utils'; export default { WXToTempFilePathSync(conf) { return canvas.toTempFilePathSync(getDefaultData(canvas, conf)); diff --git a/Runtime/wechat-default/unity-sdk/canvas.js.meta b/Runtime/wechat-default/unity-sdk/canvas.js.meta index 9a4454bb6..5d5783591 100644 --- a/Runtime/wechat-default/unity-sdk/canvas.js.meta +++ b/Runtime/wechat-default/unity-sdk/canvas.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f2a11d5991144a86a670b20749578964 +guid: 8ab8faa140decd653ebeabd343784d64 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/chat.js.meta b/Runtime/wechat-default/unity-sdk/chat.js.meta index fd3ce337c..4006151ec 100644 --- a/Runtime/wechat-default/unity-sdk/chat.js.meta +++ b/Runtime/wechat-default/unity-sdk/chat.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 71c26f436eab689ed46507f13a66491f +guid: 421f2d2040f5f38fe0d5af59065ac302 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/cloud.js.meta b/Runtime/wechat-default/unity-sdk/cloud.js.meta index 0784877ac..8a4428990 100644 --- a/Runtime/wechat-default/unity-sdk/cloud.js.meta +++ b/Runtime/wechat-default/unity-sdk/cloud.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 60bfc910e7a9c20a5f71c797bdc7f15e +guid: 87c14c69dd4eb26e8447e35832742580 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/conf.js.meta b/Runtime/wechat-default/unity-sdk/conf.js.meta index fb9cbde19..a0cc37112 100644 --- a/Runtime/wechat-default/unity-sdk/conf.js.meta +++ b/Runtime/wechat-default/unity-sdk/conf.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 816baf5107f79061712a8214e6ba0558 +guid: 60ef696fc84dc0e3718b82a95a37f542 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/file-info.js.meta b/Runtime/wechat-default/unity-sdk/file-info.js.meta index 5baa93e74..5f1ce1373 100644 --- a/Runtime/wechat-default/unity-sdk/file-info.js.meta +++ b/Runtime/wechat-default/unity-sdk/file-info.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 03de776a63b5a408671f180b6a8092c2 +guid: 115b938e924d976e84f8e4edcc2e7305 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/fix.js.meta b/Runtime/wechat-default/unity-sdk/fix.js.meta index 9aeaa04fb..1d766b5aa 100644 --- a/Runtime/wechat-default/unity-sdk/fix.js.meta +++ b/Runtime/wechat-default/unity-sdk/fix.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f4827657baaba28309e586f77f2fce47 +guid: a19d392e1978c8d1ed5cb69cb816366f DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/font/fix-cmap.js.meta b/Runtime/wechat-default/unity-sdk/font/fix-cmap.js.meta index c9dedfb5c..216bfde35 100644 --- a/Runtime/wechat-default/unity-sdk/font/fix-cmap.js.meta +++ b/Runtime/wechat-default/unity-sdk/font/fix-cmap.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d5fb0bc71319775676a9f491eeb5898c +guid: 38dac57c83a2204a4e578ead8281e0b3 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/font/index.js b/Runtime/wechat-default/unity-sdk/font/index.js index 4e6dd111f..925e34c8d 100644 --- a/Runtime/wechat-default/unity-sdk/font/index.js +++ b/Runtime/wechat-default/unity-sdk/font/index.js @@ -6,7 +6,7 @@ import fixCmapTable from './fix-cmap'; import readMetrics from './read-metrics'; import splitTTCToBufferOnlySC from './split-sc'; -const { platform } = wx.getDeviceInfo(); +const { platform } = wx.getDeviceInfo ? wx.getDeviceInfo() : wx.getSystemInfoSync(); const tempCacheObj = {}; let fontDataCache; diff --git a/Runtime/wechat-default/unity-sdk/font/index.js.meta b/Runtime/wechat-default/unity-sdk/font/index.js.meta index 65589baa9..2603c03cc 100644 --- a/Runtime/wechat-default/unity-sdk/font/index.js.meta +++ b/Runtime/wechat-default/unity-sdk/font/index.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f93003429274e1d8b0d64bdbff499a1c +guid: 7c213402d7d8c283f450610437eec11e DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/font/read-metrics.js.meta b/Runtime/wechat-default/unity-sdk/font/read-metrics.js.meta index 6c826bfab..823d9b327 100644 --- a/Runtime/wechat-default/unity-sdk/font/read-metrics.js.meta +++ b/Runtime/wechat-default/unity-sdk/font/read-metrics.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: fcf9a09d695049217ff8d741e0a06a8b +guid: 4725d6b0f8da7852c7c643506dd97c7e DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/font/split-sc.js.meta b/Runtime/wechat-default/unity-sdk/font/split-sc.js.meta index 06179cfc4..73d43b1e2 100644 --- a/Runtime/wechat-default/unity-sdk/font/split-sc.js.meta +++ b/Runtime/wechat-default/unity-sdk/font/split-sc.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 275afe9204b59d1e517409ade9a6b253 +guid: cac2a977427ee6b288faa022d6469577 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/font/util.js.meta b/Runtime/wechat-default/unity-sdk/font/util.js.meta index e63ab4cbe..d88610bc8 100644 --- a/Runtime/wechat-default/unity-sdk/font/util.js.meta +++ b/Runtime/wechat-default/unity-sdk/font/util.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: becbfe3b7e41d502cb7e38d88fb2f947 +guid: 921780162fce18101480ab9587263611 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/fs.js b/Runtime/wechat-default/unity-sdk/fs.js index a245372af..6ea13c491 100644 --- a/Runtime/wechat-default/unity-sdk/fs.js +++ b/Runtime/wechat-default/unity-sdk/fs.js @@ -408,7 +408,9 @@ export default { }, WX_FileSystemManagerReadSync(option, callbackId) { const fs = wx.getFileSystemManager(); - const res = fs.readSync(formatJsonStr(option)); + const optionConfig = formatJsonStr(option); + optionConfig.arrayBuffer = new ArrayBuffer(optionConfig.arrayBuffer.length); + const res = fs.readSync(optionConfig); cacheArrayBuffer(callbackId, res.arrayBuffer); return JSON.stringify({ bytesRead: res.bytesRead, @@ -438,16 +440,12 @@ export default { const optionConfig = formatJsonStr(option); optionConfig.data = data.buffer; const res = fs.writeSync(optionConfig); - return JSON.stringify({ - mode: res.bytesWritten, - }); + return JSON.stringify(res); }, WX_FileSystemManagerWriteStringSync(option) { const fs = wx.getFileSystemManager(); const res = fs.writeSync(formatJsonStr(option)); - return JSON.stringify({ - mode: res.bytesWritten, - }); + return JSON.stringify(res); }, WX_FileSystemManagerOpenSync(option) { const fs = wx.getFileSystemManager(); diff --git a/Runtime/wechat-default/unity-sdk/fs.js.meta b/Runtime/wechat-default/unity-sdk/fs.js.meta index 0eec2fbfd..883dc65e8 100644 --- a/Runtime/wechat-default/unity-sdk/fs.js.meta +++ b/Runtime/wechat-default/unity-sdk/fs.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 10ac909295b27eed3bd665a5c33ff023 +guid: ba5be929c66fd1aed67edfc4591ba190 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/game-club.js.meta b/Runtime/wechat-default/unity-sdk/game-club.js.meta index ba665ae9f..da545649f 100644 --- a/Runtime/wechat-default/unity-sdk/game-club.js.meta +++ b/Runtime/wechat-default/unity-sdk/game-club.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6b4d470f7b1c1ab2b4d17badd352a731 +guid: 62f1c25c5517328a2743b8acfea2ce84 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/game-recorder.js.meta b/Runtime/wechat-default/unity-sdk/game-recorder.js.meta index 34df6f527..ec3e78582 100644 --- a/Runtime/wechat-default/unity-sdk/game-recorder.js.meta +++ b/Runtime/wechat-default/unity-sdk/game-recorder.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 9001a57879d27f9242ac0f573fccf9b2 +guid: db4031d6963a5b5ea15e653f297153ee DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/gyroscope/index.js.meta b/Runtime/wechat-default/unity-sdk/gyroscope/index.js.meta index 22792d497..4b878ebdb 100644 --- a/Runtime/wechat-default/unity-sdk/gyroscope/index.js.meta +++ b/Runtime/wechat-default/unity-sdk/gyroscope/index.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 617a6684eaf0c338d9659dc0e4266bb5 +guid: fba8e6938bdb2a836657c1f20f53fe72 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/index.js.meta b/Runtime/wechat-default/unity-sdk/index.js.meta index a60bce5cc..5ff3220a4 100644 --- a/Runtime/wechat-default/unity-sdk/index.js.meta +++ b/Runtime/wechat-default/unity-sdk/index.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 28d4f8c7c2b6e2fcbd68f085c4043494 +guid: b770b2c9308737d77534c861131d09b8 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/logger.js.meta b/Runtime/wechat-default/unity-sdk/logger.js.meta index 544566e6e..2d56f8597 100644 --- a/Runtime/wechat-default/unity-sdk/logger.js.meta +++ b/Runtime/wechat-default/unity-sdk/logger.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 829adc3c3252d550950cc0f8435a12d4 +guid: 519ec8fc0d9d8fe30bfeb80f447fdce8 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/mobileKeyboard/index.js.meta b/Runtime/wechat-default/unity-sdk/mobileKeyboard/index.js.meta index ec6509a38..46078b978 100644 --- a/Runtime/wechat-default/unity-sdk/mobileKeyboard/index.js.meta +++ b/Runtime/wechat-default/unity-sdk/mobileKeyboard/index.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d4f455bc0b2f3adb7516ddc4f6c333c6 +guid: e12226904d4a186bae389eb1a52a5417 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/module-helper.js.meta b/Runtime/wechat-default/unity-sdk/module-helper.js.meta index 8656d9829..647ee2b88 100644 --- a/Runtime/wechat-default/unity-sdk/module-helper.js.meta +++ b/Runtime/wechat-default/unity-sdk/module-helper.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e403e14f6976d166a192b4a1298c735c +guid: d11506bdab446fe9988110da4327c7d3 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/open-data.js b/Runtime/wechat-default/unity-sdk/open-data.js index f52c7f458..ca1a2e717 100644 --- a/Runtime/wechat-default/unity-sdk/open-data.js +++ b/Runtime/wechat-default/unity-sdk/open-data.js @@ -1,17 +1,47 @@ +import response from './response'; +import moduleHelper from './module-helper'; +import { getDefaultData, debugLog } from './utils'; +import { isSupportSharedCanvasMode } from '../check-version'; let cachedOpenDataContext; let cachedSharedCanvas; +var SharedCanvasMode; +(function (SharedCanvasMode) { + SharedCanvasMode["ScreenCanvas"] = "screenCanvas"; + SharedCanvasMode["OffScreenCanvas"] = "offscreenCanvas"; +})(SharedCanvasMode || (SharedCanvasMode = {})); +let sharedCanvasMode; +let timerId; +let textureObject = null; +let textureId; -function getOpenDataContext() { - return cachedOpenDataContext || wx.getOpenDataContext(); +function getOpenDataContext(mode) { + if (cachedOpenDataContext) { + return cachedOpenDataContext; + } + + if (!isSupportSharedCanvasMode) { + sharedCanvasMode = SharedCanvasMode.OffScreenCanvas; + } + + if (!sharedCanvasMode) { + if (typeof mode === 'string' && SharedCanvasMode[mode]) { + sharedCanvasMode = SharedCanvasMode[mode]; + } + else { + sharedCanvasMode = SharedCanvasMode.OffScreenCanvas; + } + } + // @ts-ignore + cachedOpenDataContext = wx.getOpenDataContext({ + sharedCanvasMode, + }); + return cachedOpenDataContext; } function getSharedCanvas() { return cachedSharedCanvas || getOpenDataContext().canvas; } -let timerId; -let textureObject = null; -let textureId; function hookUnityRender() { if (!textureId) { @@ -70,10 +100,16 @@ function stopHookUnityRender() { textureObject = null; } export default { + WXGetOpenDataContext(mode) { + debugLog('WXGetOpenDataContext:', mode); + getOpenDataContext(mode); + }, WXDataContextPostMessage(msg) { + debugLog('WXDataContextPostMessage:', msg); getOpenDataContext().postMessage(msg); }, WXShowOpenData(id, x, y, width, height) { + debugLog('WXShowOpenData:', id, x, y, width, height); if (width <= 0 || height <= 0) { console.error('[unity-sdk]: WXShowOpenData要求 width 和 height 参数必须大于0'); } @@ -82,6 +118,12 @@ export default { const sharedCanvas = openDataContext.canvas; sharedCanvas.width = width; sharedCanvas.height = height; + if (sharedCanvasMode === SharedCanvasMode.ScreenCanvas && sharedCanvas.style) { + sharedCanvas.style.left = `${x / window.devicePixelRatio}px`; + sharedCanvas.style.top = `${y / window.devicePixelRatio}px`; + sharedCanvas.style.width = `${width / window.devicePixelRatio}px`; + sharedCanvas.style.height = `${height / window.devicePixelRatio}px`; + } openDataContext.postMessage({ type: 'WXRender', x, @@ -90,13 +132,54 @@ export default { height, devicePixelRatio: window.devicePixelRatio, }); - textureId = id; - startHookUnityRender(); + if (sharedCanvasMode === SharedCanvasMode.OffScreenCanvas) { + textureId = id; + startHookUnityRender(); + } }, WXHideOpenData() { + debugLog('WXHideOpenData'); getOpenDataContext().postMessage({ type: 'WXDestroy', }); - stopHookUnityRender(); + if (sharedCanvasMode === SharedCanvasMode.OffScreenCanvas) { + stopHookUnityRender(); + } + else if (sharedCanvasMode === SharedCanvasMode.ScreenCanvas) { + const sharedCanvas = getSharedCanvas(); + if (sharedCanvas.style) { + sharedCanvas.style.top = '9999px'; + } + } + }, + WXOpenDataToTempFilePathSync(conf) { + debugLog('WXOpenDataToTempFilePathSync', conf); + const sharedCanvas = getSharedCanvas(); + if (!sharedCanvas) { + return 'Please use WX.GetOpenDataContext() first'; + } + return sharedCanvas.toTempFilePathSync(getDefaultData(sharedCanvas, conf)); + }, + WXOpenDataToTempFilePath(conf, s, f, c) { + debugLog('WXOpenDataToTempFilePath', conf); + if (conf) { + const sharedCanvas = getSharedCanvas(); + if (!sharedCanvas) { + console.error('Please use WX.GetOpenDataContext() first'); + return; + } + sharedCanvas.toTempFilePath({ + ...getDefaultData(sharedCanvas, conf), + ...response.handleText(s, f, c), + success: (res) => { + moduleHelper.send('ToTempFilePathCallback', JSON.stringify({ + callbackId: s, + errMsg: res.errMsg, + errCode: res.errCode || 0, + tempFilePath: res.tempFilePath, + })); + }, + }); + } }, }; diff --git a/Runtime/wechat-default/unity-sdk/open-data.js.meta b/Runtime/wechat-default/unity-sdk/open-data.js.meta index 80c162c8a..1291abba9 100644 --- a/Runtime/wechat-default/unity-sdk/open-data.js.meta +++ b/Runtime/wechat-default/unity-sdk/open-data.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c00f9131dca9e57f25e19ef52717fc23 +guid: 7a42bc5aa27d32988f06e42527417df3 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/recorder.js.meta b/Runtime/wechat-default/unity-sdk/recorder.js.meta index 27c5392b9..02cfcf0d1 100644 --- a/Runtime/wechat-default/unity-sdk/recorder.js.meta +++ b/Runtime/wechat-default/unity-sdk/recorder.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 60633f8ea6b5ea336e77c013e910930f +guid: a0561c43255c320390cbcb8098b14257 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/resType.js b/Runtime/wechat-default/unity-sdk/resType.js index 7ce705b83..891bab147 100644 --- a/Runtime/wechat-default/unity-sdk/resType.js +++ b/Runtime/wechat-default/unity-sdk/resType.js @@ -574,6 +574,11 @@ export const ResType = { weakNet: 'bool', errMsg: 'string', }, + GetPhoneNumberSuccessCallbackResult: { + code: 'string', + errMsg: 'string', + errno: 'number', + }, GetPrivacySettingSuccessCallbackResult: { needAuthorization: 'bool', privacyContractName: 'string', @@ -724,6 +729,12 @@ export const ResType = { message: 'string', stack: 'string', }, + OnGamepadConnectedListenerResult: { + gamepad: 'string', + }, + OnGamepadDisconnectedListenerResult: { + gamepad: 'string', + }, OnHandoffListenerResult: { query: 'string', }, @@ -849,17 +860,6 @@ export const ResType = { subscriptionsSetting: 'SubscriptionsSetting', errMsg: 'string', }, - OperateGameRecorderVideoOption: { - atempo: 'number', - audioMix: 'bool', - bgm: 'string', - desc: 'string', - path: 'string', - query: 'string', - timeRange: 'number[]', - title: 'string', - volume: 'number', - }, MediaSource: { url: 'string', poster: 'string', @@ -929,9 +929,6 @@ export const ResType = { anyKeyWord: 'string', errMsg: 'string', }, - ReserveChannelsLiveOption: { - noticeId: 'string', - }, ScanCodeSuccessCallbackResult: { charSet: 'string', path: 'string', diff --git a/Runtime/wechat-default/unity-sdk/resType.js.meta b/Runtime/wechat-default/unity-sdk/resType.js.meta index da7f0d43e..dc3f13a90 100644 --- a/Runtime/wechat-default/unity-sdk/resType.js.meta +++ b/Runtime/wechat-default/unity-sdk/resType.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a48e4269495cacd8bd6e6997d8519641 +guid: 348edb4ee64f926b91ff9eb6240da664 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/resTypeOther.js.meta b/Runtime/wechat-default/unity-sdk/resTypeOther.js.meta index 245cd6b40..f185c0f02 100644 --- a/Runtime/wechat-default/unity-sdk/resTypeOther.js.meta +++ b/Runtime/wechat-default/unity-sdk/resTypeOther.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: b318aa72dd7cb5b899870f2b663c6059 +guid: fa5e371cbfb83734c6a952b3cd505ca2 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/response.js.meta b/Runtime/wechat-default/unity-sdk/response.js.meta index c54e52f90..60a704792 100644 --- a/Runtime/wechat-default/unity-sdk/response.js.meta +++ b/Runtime/wechat-default/unity-sdk/response.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 93cef6d903b49078a1da82c1a88dc838 +guid: 207a8db61e1ba42fa51796a4aaa67e1c DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/sdk.js.meta b/Runtime/wechat-default/unity-sdk/sdk.js.meta index 4ca55c39f..de37a2000 100644 --- a/Runtime/wechat-default/unity-sdk/sdk.js.meta +++ b/Runtime/wechat-default/unity-sdk/sdk.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 3591c13efa588da991648c6ed6a31558 +guid: b9bb8aea30c2afba1b0c1bee313ce0d8 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/share.js.meta b/Runtime/wechat-default/unity-sdk/share.js.meta index 6af883678..3a715056c 100644 --- a/Runtime/wechat-default/unity-sdk/share.js.meta +++ b/Runtime/wechat-default/unity-sdk/share.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 23b9945eb68cce8c506b490a09a25aba +guid: 5c59e1052869ff834ea12abee0f52397 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/storage.js.meta b/Runtime/wechat-default/unity-sdk/storage.js.meta index d7f1d7e89..18b37d720 100644 --- a/Runtime/wechat-default/unity-sdk/storage.js.meta +++ b/Runtime/wechat-default/unity-sdk/storage.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 12dd4a554f6d3402b14e178fcb472f6d +guid: 8aa73593462e5693c6b54b74f27644cc DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/texture.js b/Runtime/wechat-default/unity-sdk/texture.js index 3c1445d19..ad06d3ebd 100644 --- a/Runtime/wechat-default/unity-sdk/texture.js +++ b/Runtime/wechat-default/unity-sdk/texture.js @@ -254,7 +254,7 @@ canvasContext.addCreatedListener(() => { if (GameGlobal.USED_TEXTURE_COMPRESSION) { mod.getSupportedExtensions(); if (GameGlobal.TextureCompressedFormat === '' || GameGlobal.TextureCompressedFormat === 'pvr') { - const { platform } = wx.getDeviceInfo(); + const { platform } = wx.getDeviceInfo ? wx.getDeviceInfo() : wx.getSystemInfoSync(); if (platform === 'ios') { wx.showModal({ title: '提示', diff --git a/Runtime/wechat-default/unity-sdk/texture.js.meta b/Runtime/wechat-default/unity-sdk/texture.js.meta index 5b7738b7d..1346d5632 100644 --- a/Runtime/wechat-default/unity-sdk/texture.js.meta +++ b/Runtime/wechat-default/unity-sdk/texture.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 1ca204b816cb4a1614b72ffca10e6253 +guid: 85ca8ebd772afd36e3792ad309944872 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/touch/index.js.meta b/Runtime/wechat-default/unity-sdk/touch/index.js.meta index a0a5ffd44..484825d49 100644 --- a/Runtime/wechat-default/unity-sdk/touch/index.js.meta +++ b/Runtime/wechat-default/unity-sdk/touch/index.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: b94ae4081525c10cdc9b6a07b82384b3 +guid: 28ab72458df25bec697fe07093866a54 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/upload-file.js.meta b/Runtime/wechat-default/unity-sdk/upload-file.js.meta index 32036f4b9..87a844aaf 100644 --- a/Runtime/wechat-default/unity-sdk/upload-file.js.meta +++ b/Runtime/wechat-default/unity-sdk/upload-file.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 35c124ce6580b1fc49e0f5f20c20a59f +guid: 85c8cd0630c45a5aba2894b6d87949d4 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/userinfo.js.meta b/Runtime/wechat-default/unity-sdk/userinfo.js.meta index 5846865d3..f76ab0b65 100644 --- a/Runtime/wechat-default/unity-sdk/userinfo.js.meta +++ b/Runtime/wechat-default/unity-sdk/userinfo.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6ed59afcc91dc0029786a92946e7107f +guid: de36d717d0a47b75a502f37f219a816c DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/util.js.meta b/Runtime/wechat-default/unity-sdk/util.js.meta index a2c6c6d6d..10a2b8d28 100644 --- a/Runtime/wechat-default/unity-sdk/util.js.meta +++ b/Runtime/wechat-default/unity-sdk/util.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 09c618e1a7be4c5d799bfe35195cd54b +guid: 99610a60fe5f6d0b3ba15d0ce4e0af54 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/utils.js b/Runtime/wechat-default/unity-sdk/utils.js index a8d5da2c0..1d47e36d0 100644 --- a/Runtime/wechat-default/unity-sdk/utils.js +++ b/Runtime/wechat-default/unity-sdk/utils.js @@ -12,6 +12,8 @@ function realUid(length = 20, char = true) { } return id.join(''); } +// 用于调试js代码 +const isDebug = false; const identifierCache = []; const clearIdTicker = {}; const tempCacheObj = {}; @@ -377,3 +379,30 @@ export function stringifyRes(obj) { } return JSON.stringify(obj); } +export function getDefaultData(canvas, conf) { + const config = formatJsonStr(conf); + if (typeof config.x === 'undefined') { + config.x = 0; + } + if (typeof config.y === 'undefined') { + config.y = 0; + } + if (typeof config.width === 'undefined' || config.width === 0) { + config.width = canvas.width; + } + if (typeof config.height === 'undefined' || config.height === 0) { + config.height = canvas.height; + } + if (typeof config.destWidth === 'undefined' || config.destWidth === 0) { + config.destWidth = canvas.width; + } + if (typeof config.destHeight === 'undefined' || config.destHeight === 0) { + config.destHeight = canvas.height; + } + return config; +} +export function debugLog(...args) { + if (isDebug) { + console.log('[debug]', ...args); + } +} diff --git a/Runtime/wechat-default/unity-sdk/utils.js.meta b/Runtime/wechat-default/unity-sdk/utils.js.meta index e7c9d45be..82c553bf0 100644 --- a/Runtime/wechat-default/unity-sdk/utils.js.meta +++ b/Runtime/wechat-default/unity-sdk/utils.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: ca5ec4acf741bbaf0473fbd5d10e2811 +guid: 8aae614cca50b45ed10cd8113434d1b8 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/video.js.meta b/Runtime/wechat-default/unity-sdk/video.js.meta index 8686ccbd3..1c83a045a 100644 --- a/Runtime/wechat-default/unity-sdk/video.js.meta +++ b/Runtime/wechat-default/unity-sdk/video.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c1eaeea7a082a12c34119c57fa9402d1 +guid: 909376c806ba29d0898a9bc0ca0a32cc DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/unity-sdk/video/index.js b/Runtime/wechat-default/unity-sdk/video/index.js index 41885f0ba..c94034672 100644 --- a/Runtime/wechat-default/unity-sdk/video/index.js +++ b/Runtime/wechat-default/unity-sdk/video/index.js @@ -1,11 +1,13 @@ /* eslint-disable @typescript-eslint/prefer-for-of */ /* eslint-disable @typescript-eslint/naming-convention */ import { isH5Renderer, isSupportVideoPlayer, isPc, isDevtools } from '../../check-version'; +import { debugLog } from '../utils'; let FrameworkData = null; -const isWebVideo = isH5Renderer || isPc || isDevtools; -const isDebug = false; + +const isWebVideo = (isH5Renderer && !GameGlobal.isIOSHighPerformanceModePlus) || isPc || isDevtools; const needCache = true; const cacheVideoDecoder = []; +const supportVideoFrame = !!GameGlobal.isIOSHighPerformanceModePlus; const videoInstances = {}; function _JS_Video_CanPlayFormat(format, data) { @@ -25,9 +27,7 @@ function dynCall_vii(...args) { } } function jsVideoEnded() { - if (isDebug) { - console.log('jsVideoEnded'); - } + debugLog('jsVideoEnded'); // @ts-ignore if (this.onendedCallback) { // @ts-ignore @@ -39,9 +39,7 @@ function _JS_Video_Create(url) { if (FrameworkData) { source = FrameworkData.UTF8ToString(url); } - if (isDebug) { - console.log('_JS_Video_Create', source); - } + debugLog('_JS_Video_Create', source); if (isWebVideo) { // @ts-ignore const video = GameGlobal.manager.createWKVideo(source, FrameworkData.GLctx); @@ -65,6 +63,7 @@ function _JS_Video_Create(url) { videoWidth: 0, videoHeight: 0, isReady: false, + stoped: false, paused: false, ended: false, seeking: false, @@ -72,13 +71,16 @@ function _JS_Video_Create(url) { }; // eslint-disable-next-line no-plusplus videoInstances[++videoInstanceIdCounter] = videoInstance; + + videoDecoder.remove(); videoDecoder.on('start', (res) => { - if (isDebug) { - console.warn('wxVideoDecoder start:', res); - } + debugLog('wxVideoDecoder start:', res); videoInstance.paused = false; + videoInstance.stoped = false; if (!videoInstance.isReady) { - videoInstance.duration = res.video?.duration ?? 0; + if (res.video && res.video.duration) { + videoInstance.duration = res.video.duration / 1000; + } videoInstance.videoWidth = res.width ?? 0; videoInstance.videoHeight = res.height ?? 0; videoInstance.isReady = true; @@ -86,25 +88,14 @@ function _JS_Video_Create(url) { } }); videoDecoder.on('stop', (res) => { - if (isDebug) { - console.warn('wxVideoDecoder stop:', res); - } - videoInstance.paused = true; - }); - videoDecoder.on('seek', (res) => { - if (isDebug) { - console.warn('wxVideoDecoder seek:', res); - } + debugLog('wxVideoDecoder stop:', res); + videoInstance.stoped = true; }); videoDecoder.on('bufferchange', (res) => { - if (isDebug) { - console.warn('wxVideoDecoder bufferchange:', res); - } + debugLog('wxVideoDecoder bufferchange:', res); }); videoDecoder.on('ended', (res) => { - if (isDebug) { - console.warn('wxVideoDecoder ended:', res); - } + debugLog('wxVideoDecoder ended:', res); if (videoInstance.loop) { videoInstance.seek(0); } @@ -115,20 +106,42 @@ function _JS_Video_Create(url) { }); // @ts-ignore videoDecoder.on('frame', (res) => { - // @ts-ignore videoInstance.currentTime = res.pts / 1000; - videoInstance.frameData = new Uint8ClampedArray(res.data); + + if (supportVideoFrame) { + + videoInstance.frameData?.close?.(); + } + videoInstance.frameData = res; }); - videoInstance.play = () => videoDecoder.start({ + const startOption = { source, - }); + }; + if (supportVideoFrame) { + startOption.videoDataType = 2; + } + videoInstance.play = () => { + if (videoInstance.seeking) { + videoInstance.seeking = false; + } + if (videoInstance.paused) { + videoInstance.paused = false; + videoDecoder.wait(false); + } + else { + videoDecoder.start(startOption); + } + }; videoInstance.pause = () => { - videoDecoder.stop(); + videoDecoder.wait(true); + videoInstance.paused = true; }; videoInstance.seek = (time) => { // @ts-ignore videoDecoder.avSync.seek({ stamp: time }); + videoInstance.seeking = true; + videoDecoder.emitter.emit('seek', {}); }; videoInstance.play(); videoInstance.destroy = () => { @@ -145,8 +158,10 @@ function _JS_Video_Create(url) { delete videoInstance.videoDecoder; delete videoInstance.onendedCallback; delete videoInstance.frameData; + videoInstance.stoped = false; videoInstance.paused = false; videoInstance.ended = false; + videoInstance.seeking = false; videoInstance.currentTime = 0; videoInstance.onended = null; }; @@ -154,9 +169,7 @@ function _JS_Video_Create(url) { return videoInstanceIdCounter; } function _JS_Video_Destroy(video) { - if (isDebug) { - console.log('_JS_Video_Destroy', video); - } + debugLog('_JS_Video_Destroy', video); videoInstances[video].destroy(); delete videoInstances[video]; } @@ -205,7 +218,7 @@ function _JS_Video_IsPlaying(video) { return v.isPlaying; } const v = videoInstances[video]; - return v.isReady && !v.paused && !v.ended; + return v.isReady && !v.stoped && !v.paused && !v.ended; } function _JS_Video_IsReady(video) { const v = videoInstances[video]; @@ -216,19 +229,15 @@ function _JS_Video_IsSeeking(video) { return !!v.seeking; } function _JS_Video_Pause(video) { - if (isDebug) { - console.log('_JS_Video_Pause'); - } + debugLog('_JS_Video_Pause'); const v = videoInstances[video]; - v.pause(); if (v.loopEndPollInterval) { clearInterval(v.loopEndPollInterval); } + v.pause(); } function _JS_Video_SetLoop(video, loop = false) { - if (isDebug) { - console.log('_JS_Video_SetLoop', video); - } + debugLog('_JS_Video_SetLoop', video, loop); const v = videoInstances[video]; if (v.loopEndPollInterval) { clearInterval(v.loopEndPollInterval); @@ -238,8 +247,16 @@ function _JS_Video_SetLoop(video, loop = false) { v.loopEndPollInterval = setInterval(() => { if (typeof v.currentTime !== 'undefined' && typeof v.lastSeenPlaybackTime !== 'undefined') { - if (v.currentTime < v.lastSeenPlaybackTime) { - jsVideoEnded.apply(v); + const cur = Math.floor(v.currentTime); + const last = Math.floor(v.lastSeenPlaybackTime); + if (cur < last) { + const dur = v.duration; + const margin = 0.2; + const closeToBegin = margin * dur; + const closeToEnd = dur - closeToBegin; + if (cur < closeToBegin && last > closeToEnd) { + jsVideoEnded.apply(v); + } } } v.lastSeenPlaybackTime = v.currentTime; @@ -252,9 +269,7 @@ function _JS_Video_SetLoop(video, loop = false) { } } function jsVideoAllAudioTracksAreDisabled(v) { - if (isDebug) { - console.log('jsVideoAllAudioTracksAreDisabled'); - } + debugLog('jsVideoAllAudioTracksAreDisabled'); if (!v.enabledTracks) { return false; } @@ -266,50 +281,42 @@ function jsVideoAllAudioTracksAreDisabled(v) { return true; } function _JS_Video_Play(video, muted) { - if (isDebug) { - console.log('_JS_Video_Play', video, muted); - } + debugLog('_JS_Video_Play', video, muted); const v = videoInstances[video]; v.muted = muted || jsVideoAllAudioTracksAreDisabled(v); v.play(); _JS_Video_SetLoop(video, v.loop); } function _JS_Video_Seek(video, time) { - if (isDebug) { - console.log('_JS_Video_Seek', video, time); - } + debugLog('_JS_Video_Seek', video, time); const v = videoInstances[video]; v.seek(time); } function _JS_Video_SetEndedHandler(video, ref, onended) { - if (isDebug) { - console.log('_JS_Video_SetEndedHandler', video, ref, onended); - } + debugLog('_JS_Video_SetEndedHandler', video, ref, onended); const v = videoInstances[video]; v.onendedCallback = onended; v.onendedRef = ref; } function _JS_Video_SetErrorHandler(video, ref, onerror) { - if (isDebug) { - console.log('_JS_Video_SetErrorHandler', video, ref, onerror); - } + debugLog('_JS_Video_SetErrorHandler', video, ref, onerror); if (isWebVideo) { videoInstances[video].on('error', (errMsg) => { + debugLog('video error:', errMsg); dynCall_vii(onerror, ref, errMsg); }); } } function _JS_Video_SetMute(video, muted) { - if (isDebug) { - console.log('_JS_Video_SetMute', video, muted); - } + debugLog('_JS_Video_SetMute', video, muted); const v = videoInstances[video]; v.muted = muted || jsVideoAllAudioTracksAreDisabled(v); } +// eslint-disable-next-line @typescript-eslint/no-unused-vars function _JS_Video_SetPlaybackRate(video, rate) { - if (isDebug) { - console.log('_JS_Video_SetPlaybackRate', video, rate); - } + + + @@ -318,9 +325,7 @@ function _JS_Video_SetPlaybackRate(video, rate) { } function _JS_Video_SetReadyHandler(video, ref, onready) { - if (isDebug) { - console.log('_JS_Video_SetReadyHandler', video, ref, onready); - } + debugLog('_JS_Video_SetReadyHandler', video, ref, onready); const v = videoInstances[video]; if (isWebVideo) { v.on('canplay', () => { @@ -337,9 +342,7 @@ function _JS_Video_SetReadyHandler(video, ref, onready) { } } function _JS_Video_SetSeekedOnceHandler(video, ref, onseeked) { - if (isDebug) { - console.log('_JS_Video_SetSeekedOnceHandler', video, ref, onseeked); - } + debugLog('_JS_Video_SetSeekedOnceHandler', video, ref, onseeked); const v = videoInstances[video]; if (isWebVideo) { v.on('seek', () => { @@ -353,9 +356,7 @@ function _JS_Video_SetSeekedOnceHandler(video, ref, onseeked) { } } function _JS_Video_SetVolume(video, volume) { - if (isDebug) { - console.log('_JS_Video_SetVolume'); - } + debugLog('_JS_Video_SetVolume'); videoInstances[video].volume = volume; } function _JS_Video_Time(video) { @@ -395,7 +396,16 @@ function _JS_Video_UpdateToTexture(video, tex) { v.render(); } else { - GLctx.texImage2D(GLctx.TEXTURE_2D, 0, internalFormat, v.videoWidth, v.videoHeight, 0, format, GLctx.UNSIGNED_BYTE, v.frameData); + + const data = v.frameData?.data; + const source = supportVideoFrame ? data : new Uint8ClampedArray(data); + + if (supportVideoFrame) { + GLctx.texImage2D(GLctx.TEXTURE_2D, 0, internalFormat, format, GLctx.UNSIGNED_BYTE, source); + } + else { + GLctx.texImage2D(GLctx.TEXTURE_2D, 0, internalFormat, v.videoWidth, v.videoHeight, 0, format, GLctx.UNSIGNED_BYTE, source); + } } v.previousUploadedWidth = width; v.previousUploadedHeight = height; @@ -406,7 +416,15 @@ function _JS_Video_UpdateToTexture(video, tex) { v.render(); } else { - GLctx.texImage2D(GLctx.TEXTURE_2D, 0, internalFormat, v.videoWidth, v.videoHeight, 0, format, GLctx.UNSIGNED_BYTE, v.frameData); + const data = v.frameData?.data; + const source = supportVideoFrame ? data : new Uint8ClampedArray(data); + + if (supportVideoFrame) { + GLctx.texImage2D(GLctx.TEXTURE_2D, 0, internalFormat, format, GLctx.UNSIGNED_BYTE, source); + } + else { + GLctx.texImage2D(GLctx.TEXTURE_2D, 0, internalFormat, v.videoWidth, v.videoHeight, 0, format, GLctx.UNSIGNED_BYTE, source); + } } } GLctx.pixelStorei(GLctx.UNPACK_FLIP_Y_WEBGL, false); diff --git a/Runtime/wechat-default/unity-sdk/video/index.js.meta b/Runtime/wechat-default/unity-sdk/video/index.js.meta index 716e29edb..a1fa2b329 100644 --- a/Runtime/wechat-default/unity-sdk/video/index.js.meta +++ b/Runtime/wechat-default/unity-sdk/video/index.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a84506f670d649c8f05524d9f47db8f1 +guid: 203b45952a82d3f8c0de652fdadfd202 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/wasmcode/game.js.meta b/Runtime/wechat-default/wasmcode/game.js.meta index bf9ba350d..c77c414c3 100644 --- a/Runtime/wechat-default/wasmcode/game.js.meta +++ b/Runtime/wechat-default/wasmcode/game.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: b65c3645d3c5422e653cd734acfacf40 +guid: 4e558af747a2a3dd02472a337400cca8 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/weapp-adapter.js b/Runtime/wechat-default/weapp-adapter.js index bef552b5c..1ad847b95 100644 --- a/Runtime/wechat-default/weapp-adapter.js +++ b/Runtime/wechat-default/weapp-adapter.js @@ -76,7 +76,7 @@ const isWK = false; _window.canvas.addEventListener = _window.addEventListener; _window.canvas.removeEventListener = _window.removeEventListener; } - const { platform } = wx.getDeviceInfo(); + const { platform } = wx.getDeviceInfo ? wx.getDeviceInfo() : wx.getSystemInfoSync(); // 开发者工具无法重定义 window if (platform === 'devtools') { for (const key in _window) { @@ -1221,7 +1221,7 @@ const isWK = false; }); const _util = __webpack_require__(9); // TODO 需要 wx.getSystemInfo 获取更详细信息 - const { platform } = wx.getDeviceInfo(); + const { platform } = wx.getDeviceInfo ? wx.getDeviceInfo() : wx.getSystemInfoSync(); const navigator = { platform, language: 'zh-cn', diff --git a/Runtime/wechat-default/weapp-adapter.js.meta b/Runtime/wechat-default/weapp-adapter.js.meta index 41d7c63b9..40e396ab3 100644 --- a/Runtime/wechat-default/weapp-adapter.js.meta +++ b/Runtime/wechat-default/weapp-adapter.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: ce22a7e8e841e3894d3725602efc3e11 +guid: b1124cf2843a10d4970a3bd027e685f3 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/wechat-default/workers/response/index.js.meta b/Runtime/wechat-default/workers/response/index.js.meta index 244ad85d7..2846aee8c 100644 --- a/Runtime/wechat-default/workers/response/index.js.meta +++ b/Runtime/wechat-default/workers/response/index.js.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e5d8110c67a6cb166b877d6f59cde69f +guid: 3f8e9cdca0a7130d7be4b6920f09ada9 DefaultImporter: externalObjects: {} userData: