diff --git a/CHANGELOG.md b/CHANGELOG.md index 53d64d0a4..61b40d7ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,23 +6,6 @@ Removed - 删除功能/接口 Fixed - 修复问题 Others - 其他 --> -## 2026-1-13 v0.1.31 【普通更新】 -### Fixed -* 普通:修复glx模式下 createVideo underGameView为true 黑屏的问题 -* 普通:修复build profile在团结1.6之后的导出问题 - -## 2025-11-6 v0.1.30 【重要更新】 -### Feature -* 重要:EmscriptenGLX支持微信压缩纹理 -* 普通:EmscriptenGLX支持Android glReadpixels -* 普通:EmscriptenGLX优化Android CPU与功耗 -* 普通:Metal高帧率下功耗优化 -* 普通:团结引擎buildprofile支持 -### Fixed -* 重要:Metal编码库batch size修复 -* 普通:PageManager相关问题修复 -* 普通:iOS18的微信字体修复 - ## 2025-9-8 v0.1.29 【重要更新】 ### Feature * 普通:本地缓存存在时,UnityWebRequest支持同步方式(API:wx.SetSyncReadCacheEnabled)以加快读取速度 diff --git a/Editor/BuildProfile/WeixinBuildProfileUpdater.cs b/Editor/BuildProfile/WeixinBuildProfileUpdater.cs new file mode 100644 index 000000000..7e7971395 --- /dev/null +++ b/Editor/BuildProfile/WeixinBuildProfileUpdater.cs @@ -0,0 +1,78 @@ +#if TUANJIE_1_6_OR_NEWER && !TUANJIE_1_8_OR_NEWER + +using System.Collections.Generic; +using UnityEditor; +using UnityEditor.ExternalMiniGame; +using UnityEngine; + +namespace WeChatWASM +{ + [InitializeOnLoad] + public class WeixinBuildProfileUpdater + { + static WeixinBuildProfileUpdater() + { + UpdateBuildProfile(); + } + + public static void UpdateBuildProfile() + { + string buildProfilePath = "Assets/Settings/Build Profiles"; + if (!AssetDatabase.IsValidFolder(buildProfilePath)) + { + return; + } + + string[] guids = AssetDatabase.FindAssets("t:BuildProfile", new[] { buildProfilePath }); + foreach (string guid in guids) + { + string assetPath = AssetDatabase.GUIDToAssetPath(guid); + UnityEditor.Build.Profile.BuildProfile buildProfile = AssetDatabase.LoadAssetAtPath(assetPath); + + if (buildProfile != null) + { + bool isDefaultWeixinSettings = buildProfile.miniGameSettings is DefaultWeChatMiniGameSettings; + + // If use DefaultWeChatMiniGameSettings, convert to WeixinMiniGameSettings + if (isDefaultWeixinSettings) + { + var oldSettings = (DefaultWeChatMiniGameSettings)buildProfile.miniGameSettings; + var editor = new WeixinMiniGameSettingsEditor(); + var newSettings = new WeixinMiniGameSettings(editor); + + newSettings.ProjectConf = new WXProjectConf(); + newSettings.SDKOptions = new SDKOptions(); + newSettings.CompileOptions = new CompileOptions(); + newSettings.CompressTexture = new CompressTexture(); + newSettings.FontOptions = new FontOptions(); + + string projJson = JsonUtility.ToJson(oldSettings.ProjectConf, true); + JsonUtility.FromJsonOverwrite(projJson, newSettings.ProjectConf); + string sdkOptionsJson = JsonUtility.ToJson(oldSettings.SDKOptions, true); + JsonUtility.FromJsonOverwrite(sdkOptionsJson, newSettings.SDKOptions); + string compileOptionsJson = JsonUtility.ToJson(oldSettings.CompileOptions, true); + JsonUtility.FromJsonOverwrite(compileOptionsJson, newSettings.CompileOptions); + string compressTextureJson = JsonUtility.ToJson(oldSettings.CompressTexture, true); + JsonUtility.FromJsonOverwrite(compressTextureJson, newSettings.CompressTexture); + string fontOptionsJson = JsonUtility.ToJson(oldSettings.FontOptions, true); + JsonUtility.FromJsonOverwrite(fontOptionsJson, newSettings.FontOptions); + + var property = typeof(UnityEditor.Build.Profile.BuildProfile).GetProperty("miniGameSettings", + System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance); + property.SetValue(buildProfile, newSettings); + buildProfile.miniGameSettings = newSettings; + + EditorUtility.SetDirty(buildProfile); + AssetDatabase.SaveAssets(); + AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(buildProfile)); + + } + + } + } + } + + } + +} +#endif \ No newline at end of file diff --git a/Editor/BuildProfile/WeixinBuildProfileUpdater.cs.meta b/Editor/BuildProfile/WeixinBuildProfileUpdater.cs.meta new file mode 100644 index 000000000..e38a2c474 --- /dev/null +++ b/Editor/BuildProfile/WeixinBuildProfileUpdater.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 741d5b08eb860f748890537f2389546f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/BuildProfile/WeixinMiniGameSettingsEditor.cs b/Editor/BuildProfile/WeixinMiniGameSettingsEditor.cs index 97225378c..347e6f15e 100644 --- a/Editor/BuildProfile/WeixinMiniGameSettingsEditor.cs +++ b/Editor/BuildProfile/WeixinMiniGameSettingsEditor.cs @@ -26,561 +26,13 @@ namespace WeChatWASM private Dictionary formCheckboxData = new Dictionary(); public Texture tex; + public WXSettingsHelper helper = new WXSettingsHelper(); + public override void OnMiniGameSettingsIMGUI(SerializedObject serializedObject, SerializedProperty miniGameProperty) { - OnSettingsGUI(serializedObject, miniGameProperty); + helper.OnSettingsGUI(serializedObject, miniGameProperty); } - public void OnSettingsGUI(SerializedObject serializedObject, SerializedProperty miniGameProperty) - { - loadData(serializedObject, miniGameProperty); - - scrollRoot = EditorGUILayout.BeginScrollView(scrollRoot); - - GUIStyle linkStyle = new GUIStyle(GUI.skin.label); - linkStyle.normal.textColor = Color.yellow; - linkStyle.hover.textColor = Color.yellow; - linkStyle.stretchWidth = false; - linkStyle.alignment = TextAnchor.UpperLeft; - linkStyle.wordWrap = true; - - foldBaseInfo = EditorGUILayout.Foldout(foldBaseInfo, "基本信息"); - if (foldBaseInfo) - { - EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(true)); - - formInput("appid", "游戏AppID"); - formInput("cdn", "游戏资源CDN"); - formInput("projectName", "小游戏项目名"); - formIntPopup("orientation", "游戏方向", new[] { "Portrait", "Landscape", "LandscapeLeft", "LandscapeRight" }, new[] { 0, 1, 2, 3 }); - formInput("memorySize", "UnityHeap预留内存(?)", "单位MB,预分配内存值,超休闲游戏256/中轻度496/重度游戏768,需预估游戏最大UnityHeap值以防止内存自动扩容带来的峰值尖刺。预估方法请查看GIT文档《优化Unity WebGL的内存》"); - - EditorGUILayout.EndVertical(); - } - - foldLoadingConfig = EditorGUILayout.Foldout(foldLoadingConfig, "启动Loading配置"); - if (foldLoadingConfig) - { - EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(true)); - - GUILayout.BeginHorizontal(); - string targetBg = "bgImageSrc"; - EditorGUILayout.LabelField(string.Empty, GUILayout.Width(10)); - tex = (Texture)EditorGUILayout.ObjectField("启动背景图/视频封面", tex, typeof(Texture2D), false); - var currentBgSrc = AssetDatabase.GetAssetPath(tex); - if (!string.IsNullOrEmpty(currentBgSrc) && currentBgSrc != formInputData[targetBg]) - { - formInputData[targetBg] = currentBgSrc; - saveData(serializedObject, miniGameProperty); - } - GUILayout.EndHorizontal(); - - formInput("videoUrl", "加载阶段视频URL"); - formIntPopup("assetLoadType", "首包资源加载方式", new[] { "CDN", "小游戏包内" }, new[] { 0, 1 }); - formCheckbox("compressDataPackage", "压缩首包资源(?)", "将首包资源Brotli压缩, 降低资源大小. 注意: 首次启动耗时可能会增加200ms, 仅推荐使用小游戏分包加载时节省包体大小使用"); - formInput("bundleExcludeExtensions", "不自动缓存文件类型(?)", "(使用;分割)当请求url包含资源'cdn+StreamingAssets'时会自动缓存,但StreamingAssets目录下不是所有文件都需缓存,此选项配置不需要自动缓存的文件拓展名。默认值json"); - formInput("bundleHashLength", "Bundle名称Hash长度(?)", "自定义Bundle文件名中hash部分长度,默认值32,用于缓存控制。"); - formInput("preloadFiles", "预下载文件列表(?)", "使用;间隔,支持模糊匹配"); - - EditorGUILayout.EndVertical(); - } - - foldSDKOptions = EditorGUILayout.Foldout(foldSDKOptions, "SDK功能选项"); - if (foldSDKOptions) - { - EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(true)); - - formCheckbox("useFriendRelation", "使用好友关系链"); - formCheckbox("useMiniGameChat", "使用社交组件"); - formCheckbox("preloadWXFont", "预加载微信字体(?)", "在game.js执行开始时预载微信系统字体,运行期间可使用WX.GetWXFont获取微信字体"); - formCheckbox("disableMultiTouch", "禁止多点触控"); - - EditorGUILayout.EndVertical(); - } - - foldDebugOptions = EditorGUILayout.Foldout(foldDebugOptions, "调试编译选项"); - if (foldDebugOptions) - { - EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(true)); - // formCheckbox("developBuild", "Development Build"); - formCheckbox("autoProfile", "Auto connect Profiler"); - formCheckbox("scriptOnly", "Scripts Only Build"); -#if TUANJIE_2022_3_OR_NEWER - // TODO: if overwrite by OverwritePlayerSettings - bool UseIL2CPP = PlayerSettings.GetScriptingBackend(BuildTargetGroup.WeixinMiniGame) == ScriptingImplementation.IL2CPP; -#else - bool UseIL2CPP = true; -#endif - formCheckbox("il2CppOptimizeSize", "Il2Cpp Optimize Size(?)", "对应于Il2CppCodeGeneration选项,勾选时使用OptimizeSize(默认推荐),生成代码小15%左右,取消勾选则使用OptimizeSpeed。游戏中大量泛型集合的高频访问建议OptimizeSpeed,在使用HybridCLR等第三方组件时只能用OptimizeSpeed。(Dotnet Runtime模式下该选项无效)", !UseIL2CPP); - formCheckbox("profilingFuncs", "Profiling Funcs"); - formCheckbox("profilingMemory", "Profiling Memory"); - - formCheckbox("webgl2", "WebGL2.0(beta)"); - formCheckbox("iOSPerformancePlus", "iOSPerformancePlus(?)", "是否使用iOS高性能+渲染方案,有助于提升渲染兼容性、降低WebContent进程内存"); - formCheckbox("EmscriptenGLX", "EmscriptenGLX(?)", "是否使用EmscriptenGLX渲染方案"); - formCheckbox("iOSMetal", "iOSMetal(?)", "是否使用iOSMetal渲染方案,需要开启iOS高性能+模式,有助于提升运行性能,降低iOS功耗"); - formCheckbox("deleteStreamingAssets", "Clear Streaming Assets"); - formCheckbox("cleanBuild", "Clean WebGL Build"); - // formCheckbox("cleanCloudDev", "Clean Cloud Dev"); - formCheckbox("fbslim", "首包资源优化(?)", "导出时自动清理UnityEditor默认打包但游戏项目从未使用的资源,瘦身首包资源体积。(团结引擎已无需开启该能力)", UnityUtil.GetEngineVersion() > 0, (res) => - { - var fbWin = EditorWindow.GetWindow(typeof(WXFbSettingWindow), false, "首包资源优化配置面板", true); - fbWin.minSize = new Vector2(680, 350); - fbWin.Show(); - }); - formCheckbox("autoAdaptScreen", "自适应屏幕尺寸(?)", "移动端旋转屏幕和PC端拉伸窗口时,自动调整画布尺寸"); - formCheckbox("showMonitorSuggestModal", "显示优化建议弹窗"); - formCheckbox("enableProfileStats", "显示性能面板"); - formCheckbox("enableRenderAnalysis", "显示渲染日志(dev only)"); - - { - formCheckbox("brotliMT", "brotli多线程压缩(?)", "开启多线程压缩可以提高出包速度,但会降低压缩率。如若不使用wasm代码分包请勿用多线程出包上线"); - } - EditorGUILayout.EndVertical(); - } - - if (WXConvertCore.IsInstantGameAutoStreaming()) - { - foldInstantGame = EditorGUILayout.Foldout(foldInstantGame, "Instant Game - AutoStreaming"); - if (foldInstantGame) - { - var automaticfillinstantgame = miniGameProperty.FindPropertyRelative("m_AutomaticFillInstantGame"); - EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(true)); - GUILayout.BeginHorizontal(); - EditorGUILayout.LabelField(string.Empty, GUILayout.Width(10)); - formCheckbox("m_AutomaticFillInstantGame", "自动填写AutoStreaming", "仅在开启AutoStreaming生效"); - GUILayout.EndHorizontal(); - formInput("bundlePathIdentifier", "Bundle Path Identifier"); - formInput("dataFileSubPrefix", "Data File Sub Prefix"); - - EditorGUI.BeginDisabledGroup(true); - formCheckbox("autoUploadFirstBundle", "构建后自动上传首包(?)", "仅在开启AutoStreaming生效", true); - EditorGUI.EndDisabledGroup(); - - GUILayout.BeginHorizontal(); - EditorGUILayout.LabelField(string.Empty, GUILayout.Width(10)); - GUILayout.Label(new GUIContent("清理AS配置(?)", "如需关闭AutoStreaming选用默认发布方案则需要清理AS配置项目。"), GUILayout.Width(140)); - EditorGUI.BeginDisabledGroup(WXConvertCore.IsInstantGameAutoStreaming()); - if (GUILayout.Button(new GUIContent("恢复"), GUILayout.Width(60))) - { - var ProjectConf = miniGameProperty.FindPropertyRelative("ProjectConf"); - string identifier = ProjectConf.FindPropertyRelative("bundlePathIdentifier").stringValue; - string[] identifiers = identifier.Split(";"); - string idStr = ""; - foreach (string id in identifiers) - { - if (id != "AS" && id != "CUS/CustomAB") - { - idStr += id + ";"; - } - } - ProjectConf.FindPropertyRelative("bundlePathIdentifier").stringValue = idStr.Trim(';'); - - if (ProjectConf.FindPropertyRelative("dataFileSubPrefix").stringValue == "CUS") - { - ProjectConf.FindPropertyRelative("dataFileSubPrefix").stringValue = ""; - } - loadData(serializedObject, miniGameProperty); - } - EditorGUI.EndDisabledGroup(); - GUILayout.EndHorizontal(); - - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.LabelField(string.Empty); - if (GUILayout.Button(new GUIContent("了解Instant Game AutoStreaming", ""), linkStyle)) - { - Application.OpenURL("https://github.com/wechat-miniprogram/minigame-unity-webgl-transform/blob/main/Design/InstantGameGuide.md"); - } - EditorGUILayout.EndHorizontal(); - EditorGUILayout.EndVertical(); - } - } - - { - foldFontOptions = EditorGUILayout.Foldout(foldFontOptions, "字体配置"); - if (foldFontOptions) - { - EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(true)); - formCheckbox("CJK_Unified_Ideographs", "基本汉字(?)", "Unicode [0x4e00, 0x9fff]"); - formCheckbox("C0_Controls_and_Basic_Latin", "基本拉丁语(英文大小写、数字、英文标点)(?)", "Unicode [0x0, 0x7f]"); - formCheckbox("CJK_Symbols_and_Punctuation", "中文标点符号(?)", "Unicode [0x3000, 0x303f]"); - formCheckbox("General_Punctuation", "通用标点符号(?)", "Unicode [0x2000, 0x206f]"); - formCheckbox("Enclosed_CJK_Letters_and_Months", "CJK字母及月份(?)", "Unicode [0x3200, 0x32ff]"); - formCheckbox("Vertical_Forms", "中文竖排标点(?)", "Unicode [0xfe10, 0xfe1f]"); - formCheckbox("CJK_Compatibility_Forms", "CJK兼容符号(?)", "Unicode [0xfe30, 0xfe4f]"); - formCheckbox("Miscellaneous_Symbols", "杂项符号(?)", "Unicode [0x2600, 0x26ff]"); - formCheckbox("CJK_Compatibility", "CJK特殊符号(?)", "Unicode [0x3300, 0x33ff]"); - formCheckbox("Halfwidth_and_Fullwidth_Forms", "全角ASCII、全角中英文标点、半宽片假名、半宽平假名、半宽韩文字母(?)", "Unicode [0xff00, 0xffef]"); - formCheckbox("Dingbats", "装饰符号(?)", "Unicode [0x2700, 0x27bf]"); - formCheckbox("Letterlike_Symbols", "字母式符号(?)", "Unicode [0x2100, 0x214f]"); - formCheckbox("Enclosed_Alphanumerics", "带圈或括号的字母数字(?)", "Unicode [0x2460, 0x24ff]"); - formCheckbox("Number_Forms", "数字形式(?)", "Unicode [0x2150, 0x218f]"); - formCheckbox("Currency_Symbols", "货币符号(?)", "Unicode [0x20a0, 0x20cf]"); - formCheckbox("Arrows", "箭头(?)", "Unicode [0x2190, 0x21ff]"); - formCheckbox("Geometric_Shapes", "几何图形(?)", "Unicode [0x25a0, 0x25ff]"); - formCheckbox("Mathematical_Operators", "数学运算符号(?)", "Unicode [0x2200, 0x22ff]"); - formInput("CustomUnicode", "自定义Unicode(?)", "将填入的所有字符强制加入字体预加载列表"); - EditorGUILayout.EndVertical(); - } - } - - EditorGUILayout.EndScrollView(); - saveData(serializedObject, miniGameProperty); - } - - private void loadData(SerializedObject serializedObject, SerializedProperty miniGameProperty) - { - serializedObject.UpdateIfRequiredOrScript(); - var ProjectConf = miniGameProperty.FindPropertyRelative("ProjectConf"); - - // Instant Game - if (WXConvertCore.IsInstantGameAutoStreaming()) - { - var automaticfillinstantgame = miniGameProperty.FindPropertyRelative("m_AutomaticFillInstantGame"); - if (automaticfillinstantgame.boolValue) - { - ProjectConf.FindPropertyRelative("CDN").stringValue = WXConvertCore.GetInstantGameAutoStreamingCDN(); - if (!ProjectConf.FindPropertyRelative("bundlePathIdentifier").stringValue.Contains("AS;")) - { - ProjectConf.FindPropertyRelative("bundlePathIdentifier").stringValue += "AS;"; - } - if (!ProjectConf.FindPropertyRelative("bundlePathIdentifier").stringValue.Contains("CUS/CustomAB;")) - { - ProjectConf.FindPropertyRelative("bundlePathIdentifier").stringValue += "CUS/CustomAB;"; - } - ProjectConf.FindPropertyRelative("dataFileSubPrefix").stringValue = "CUS"; - } - } - - setData("projectName", ProjectConf.FindPropertyRelative("projectName").stringValue); - setData("appid", ProjectConf.FindPropertyRelative("Appid").stringValue); - setData("cdn", ProjectConf.FindPropertyRelative("CDN").stringValue); - setData("assetLoadType", ProjectConf.FindPropertyRelative("assetLoadType").intValue); - setData("compressDataPackage", ProjectConf.FindPropertyRelative("compressDataPackage").boolValue); - setData("videoUrl", ProjectConf.FindPropertyRelative("VideoUrl").stringValue); - setData("orientation", (int)ProjectConf.FindPropertyRelative("Orientation").enumValueIndex); - //setData("dst", ProjectConf.FindPropertyRelative("relativeDST").stringValue); - setData("bundleHashLength", ProjectConf.FindPropertyRelative("bundleHashLength").intValue.ToString()); - setData("bundlePathIdentifier", ProjectConf.FindPropertyRelative("bundlePathIdentifier").stringValue); - setData("bundleExcludeExtensions", ProjectConf.FindPropertyRelative("bundleExcludeExtensions").stringValue); - setData("preloadFiles", ProjectConf.FindPropertyRelative("preloadFiles").stringValue); - - var CompileOptions = miniGameProperty.FindPropertyRelative("CompileOptions"); - // setData("developBuild", CompileOptions.FindPropertyRelative("DevelopBuild").boolValue); - setData("autoProfile", CompileOptions.FindPropertyRelative("AutoProfile").boolValue); - setData("scriptOnly", CompileOptions.FindPropertyRelative("ScriptOnly").boolValue); - setData("il2CppOptimizeSize", CompileOptions.FindPropertyRelative("Il2CppOptimizeSize").boolValue); - setData("profilingFuncs", CompileOptions.FindPropertyRelative("profilingFuncs").boolValue); - setData("profilingMemory", CompileOptions.FindPropertyRelative("ProfilingMemory").boolValue); - setData("deleteStreamingAssets", CompileOptions.FindPropertyRelative("DeleteStreamingAssets").boolValue); - setData("cleanBuild", CompileOptions.FindPropertyRelative("CleanBuild").boolValue); - setData("customNodePath", CompileOptions.FindPropertyRelative("CustomNodePath").stringValue); - setData("webgl2", CompileOptions.FindPropertyRelative("Webgl2").boolValue); - setData("iOSPerformancePlus", CompileOptions.FindPropertyRelative("enableIOSPerformancePlus").boolValue); - setData("iOSMetal", CompileOptions.FindPropertyRelative("enableiOSMetal").boolValue); - setData("EmscriptenGLX", CompileOptions.FindPropertyRelative("enableEmscriptenGLX").boolValue); - setData("fbslim", CompileOptions.FindPropertyRelative("fbslim").boolValue); - - var SDKOptions = miniGameProperty.FindPropertyRelative("SDKOptions"); - setData("useFriendRelation", SDKOptions.FindPropertyRelative("UseFriendRelation").boolValue); - setData("useMiniGameChat", SDKOptions.FindPropertyRelative("UseMiniGameChat").boolValue); - setData("preloadWXFont", SDKOptions.FindPropertyRelative("PreloadWXFont").boolValue); - setData("disableMultiTouch", SDKOptions.FindPropertyRelative("disableMultiTouch").boolValue); - setData("bgImageSrc", ProjectConf.FindPropertyRelative("bgImageSrc").stringValue); - tex = AssetDatabase.LoadAssetAtPath(ProjectConf.FindPropertyRelative("bgImageSrc").stringValue); - setData("memorySize", ProjectConf.FindPropertyRelative("MemorySize").intValue.ToString()); - setData("hideAfterCallMain", ProjectConf.FindPropertyRelative("HideAfterCallMain").boolValue); - - setData("dataFileSubPrefix", ProjectConf.FindPropertyRelative("dataFileSubPrefix").stringValue); - setData("maxStorage", ProjectConf.FindPropertyRelative("maxStorage").intValue.ToString()); - setData("defaultReleaseSize", ProjectConf.FindPropertyRelative("defaultReleaseSize").intValue.ToString()); - setData("texturesHashLength", ProjectConf.FindPropertyRelative("texturesHashLength").intValue.ToString()); - setData("texturesPath", ProjectConf.FindPropertyRelative("texturesPath").stringValue); - setData("needCacheTextures", ProjectConf.FindPropertyRelative("needCacheTextures").boolValue); - setData("loadingBarWidth", ProjectConf.FindPropertyRelative("loadingBarWidth").intValue.ToString()); - setData("needCheckUpdate", ProjectConf.FindPropertyRelative("needCheckUpdate").boolValue); - setData("disableHighPerformanceFallback", ProjectConf.FindPropertyRelative("disableHighPerformanceFallback").boolValue); - setData("autoAdaptScreen", CompileOptions.FindPropertyRelative("autoAdaptScreen").boolValue); - setData("showMonitorSuggestModal", CompileOptions.FindPropertyRelative("showMonitorSuggestModal").boolValue); - setData("enableProfileStats", CompileOptions.FindPropertyRelative("enableProfileStats").boolValue); - setData("enableRenderAnalysis", CompileOptions.FindPropertyRelative("enableRenderAnalysis").boolValue); - setData("brotliMT", CompileOptions.FindPropertyRelative("brotliMT").boolValue); - setData("autoUploadFirstBundle", true); - setData("m_AutomaticFillInstantGame", miniGameProperty.FindPropertyRelative("m_AutomaticFillInstantGame").boolValue); - - // font options - var FontOptions = miniGameProperty.FindPropertyRelative("FontOptions"); - setData("CJK_Unified_Ideographs", FontOptions.FindPropertyRelative("CJK_Unified_Ideographs").boolValue); - setData("C0_Controls_and_Basic_Latin", FontOptions.FindPropertyRelative("C0_Controls_and_Basic_Latin").boolValue); - setData("CJK_Symbols_and_Punctuation", FontOptions.FindPropertyRelative("CJK_Symbols_and_Punctuation").boolValue); - setData("General_Punctuation", FontOptions.FindPropertyRelative("General_Punctuation").boolValue); - setData("Enclosed_CJK_Letters_and_Months", FontOptions.FindPropertyRelative("Enclosed_CJK_Letters_and_Months").boolValue); - setData("Vertical_Forms", FontOptions.FindPropertyRelative("Vertical_Forms").boolValue); - setData("CJK_Compatibility_Forms", FontOptions.FindPropertyRelative("CJK_Compatibility_Forms").boolValue); - setData("Miscellaneous_Symbols", FontOptions.FindPropertyRelative("Miscellaneous_Symbols").boolValue); - setData("CJK_Compatibility", FontOptions.FindPropertyRelative("CJK_Compatibility").boolValue); - setData("Halfwidth_and_Fullwidth_Forms", FontOptions.FindPropertyRelative("Halfwidth_and_Fullwidth_Forms").boolValue); - setData("Dingbats", FontOptions.FindPropertyRelative("Dingbats").boolValue); - setData("Letterlike_Symbols", FontOptions.FindPropertyRelative("Letterlike_Symbols").boolValue); - setData("Enclosed_Alphanumerics", FontOptions.FindPropertyRelative("Enclosed_Alphanumerics").boolValue); - setData("Number_Forms", FontOptions.FindPropertyRelative("Number_Forms").boolValue); - setData("Currency_Symbols", FontOptions.FindPropertyRelative("Currency_Symbols").boolValue); - setData("Arrows", FontOptions.FindPropertyRelative("Arrows").boolValue); - setData("Geometric_Shapes", FontOptions.FindPropertyRelative("Geometric_Shapes").boolValue); - setData("Mathematical_Operators", FontOptions.FindPropertyRelative("Mathematical_Operators").boolValue); - setData("CustomUnicode", FontOptions.FindPropertyRelative("CustomUnicode").stringValue); - } - - private void saveData(SerializedObject serializedObject, SerializedProperty miniGameProperty) - { - serializedObject.UpdateIfRequiredOrScript(); - - var ProjectConf = miniGameProperty.FindPropertyRelative("ProjectConf"); - ProjectConf.FindPropertyRelative("projectName").stringValue = getDataInput("projectName"); - ProjectConf.FindPropertyRelative("Appid").stringValue = getDataInput("appid"); - ProjectConf.FindPropertyRelative("CDN").stringValue = getDataInput("cdn"); - ProjectConf.FindPropertyRelative("assetLoadType").intValue = getDataPop("assetLoadType"); - ProjectConf.FindPropertyRelative("compressDataPackage").boolValue = getDataCheckbox("compressDataPackage"); - ProjectConf.FindPropertyRelative("VideoUrl").stringValue = getDataInput("videoUrl"); - ProjectConf.FindPropertyRelative("Orientation").enumValueIndex = getDataPop("orientation"); - ProjectConf.FindPropertyRelative("relativeDST").stringValue = serializedObject.FindProperty("m_BuildPath").stringValue; - ProjectConf.FindPropertyRelative("DST").stringValue = GetAbsolutePath(config.ProjectConf.relativeDST); - - ProjectConf.FindPropertyRelative("bundleHashLength").intValue = int.Parse(getDataInput("bundleHashLength")); - ProjectConf.FindPropertyRelative("bundlePathIdentifier").stringValue = getDataInput("bundlePathIdentifier"); - ProjectConf.FindPropertyRelative("bundleExcludeExtensions").stringValue = getDataInput("bundleExcludeExtensions"); - ProjectConf.FindPropertyRelative("preloadFiles").stringValue = getDataInput("preloadFiles"); - - var CompileOptions = miniGameProperty.FindPropertyRelative("CompileOptions"); - - CompileOptions.FindPropertyRelative("DevelopBuild").boolValue = serializedObject.FindProperty("m_PlatformSettings").FindPropertyRelative("m_Development").boolValue; - CompileOptions.FindPropertyRelative("AutoProfile").boolValue = getDataCheckbox("autoProfile"); - CompileOptions.FindPropertyRelative("ScriptOnly").boolValue = getDataCheckbox("scriptOnly"); - CompileOptions.FindPropertyRelative("Il2CppOptimizeSize").boolValue = getDataCheckbox("il2CppOptimizeSize"); - CompileOptions.FindPropertyRelative("profilingFuncs").boolValue = getDataCheckbox("profilingFuncs"); - CompileOptions.FindPropertyRelative("ProfilingMemory").boolValue = getDataCheckbox("profilingMemory"); - CompileOptions.FindPropertyRelative("DeleteStreamingAssets").boolValue = getDataCheckbox("deleteStreamingAssets"); - CompileOptions.FindPropertyRelative("CleanBuild").boolValue = getDataCheckbox("cleanBuild"); - CompileOptions.FindPropertyRelative("CustomNodePath").stringValue = getDataInput("customNodePath"); - CompileOptions.FindPropertyRelative("Webgl2").boolValue = getDataCheckbox("webgl2"); - CompileOptions.FindPropertyRelative("enableIOSPerformancePlus").boolValue = getDataCheckbox("iOSPerformancePlus"); - CompileOptions.FindPropertyRelative("enableiOSMetal").boolValue = getDataCheckbox("iOSMetal"); - CompileOptions.FindPropertyRelative("enableEmscriptenGLX").boolValue = getDataCheckbox("EmscriptenGLX"); - CompileOptions.FindPropertyRelative("fbslim").boolValue = getDataCheckbox("fbslim"); - - var SDKOptions = miniGameProperty.FindPropertyRelative("SDKOptions"); - SDKOptions.FindPropertyRelative("UseFriendRelation").boolValue = getDataCheckbox("useFriendRelation"); - SDKOptions.FindPropertyRelative("UseMiniGameChat").boolValue = getDataCheckbox("useMiniGameChat"); - SDKOptions.FindPropertyRelative("PreloadWXFont").boolValue = getDataCheckbox("preloadWXFont"); - SDKOptions.FindPropertyRelative("disableMultiTouch").boolValue = getDataCheckbox("disableMultiTouch"); - ProjectConf.FindPropertyRelative("bgImageSrc").stringValue = getDataInput("bgImageSrc"); - ProjectConf.FindPropertyRelative("MemorySize").intValue = int.Parse(getDataInput("memorySize")); - ProjectConf.FindPropertyRelative("HideAfterCallMain").boolValue = getDataCheckbox("hideAfterCallMain"); - ProjectConf.FindPropertyRelative("dataFileSubPrefix").stringValue = getDataInput("dataFileSubPrefix"); - ProjectConf.FindPropertyRelative("maxStorage").intValue = int.Parse(getDataInput("maxStorage")); - ProjectConf.FindPropertyRelative("defaultReleaseSize").intValue = int.Parse(getDataInput("defaultReleaseSize")); - ProjectConf.FindPropertyRelative("texturesHashLength").intValue = int.Parse(getDataInput("texturesHashLength")); - ProjectConf.FindPropertyRelative("texturesPath").stringValue = getDataInput("texturesPath"); - ProjectConf.FindPropertyRelative("needCacheTextures").boolValue = getDataCheckbox("needCacheTextures"); - ProjectConf.FindPropertyRelative("loadingBarWidth").intValue = int.Parse(getDataInput("loadingBarWidth")); - ProjectConf.FindPropertyRelative("needCheckUpdate").boolValue = getDataCheckbox("needCheckUpdate"); - ProjectConf.FindPropertyRelative("disableHighPerformanceFallback").boolValue = getDataCheckbox("disableHighPerformanceFallback"); - CompileOptions.FindPropertyRelative("autoAdaptScreen").boolValue = getDataCheckbox("autoAdaptScreen"); - CompileOptions.FindPropertyRelative("showMonitorSuggestModal").boolValue = getDataCheckbox("showMonitorSuggestModal"); - CompileOptions.FindPropertyRelative("enableProfileStats").boolValue = getDataCheckbox("enableProfileStats"); - CompileOptions.FindPropertyRelative("enableRenderAnalysis").boolValue = getDataCheckbox("enableRenderAnalysis"); - CompileOptions.FindPropertyRelative("brotliMT").boolValue = getDataCheckbox("brotliMT"); - - // font options - var FontOptions = miniGameProperty.FindPropertyRelative("FontOptions"); - FontOptions.FindPropertyRelative("CJK_Unified_Ideographs").boolValue = getDataCheckbox("CJK_Unified_Ideographs"); - FontOptions.FindPropertyRelative("C0_Controls_and_Basic_Latin").boolValue = getDataCheckbox("C0_Controls_and_Basic_Latin"); - FontOptions.FindPropertyRelative("CJK_Symbols_and_Punctuation").boolValue = getDataCheckbox("CJK_Symbols_and_Punctuation"); - FontOptions.FindPropertyRelative("General_Punctuation").boolValue = getDataCheckbox("General_Punctuation"); - FontOptions.FindPropertyRelative("Enclosed_CJK_Letters_and_Months").boolValue = getDataCheckbox("Enclosed_CJK_Letters_and_Months"); - FontOptions.FindPropertyRelative("Vertical_Forms").boolValue = getDataCheckbox("Vertical_Forms"); - FontOptions.FindPropertyRelative("CJK_Compatibility_Forms").boolValue = getDataCheckbox("CJK_Compatibility_Forms"); - FontOptions.FindPropertyRelative("Miscellaneous_Symbols").boolValue = getDataCheckbox("Miscellaneous_Symbols"); - FontOptions.FindPropertyRelative("CJK_Compatibility").boolValue = getDataCheckbox("CJK_Compatibility"); - FontOptions.FindPropertyRelative("Halfwidth_and_Fullwidth_Forms").boolValue = getDataCheckbox("Halfwidth_and_Fullwidth_Forms"); - FontOptions.FindPropertyRelative("Dingbats").boolValue = getDataCheckbox("Dingbats"); - FontOptions.FindPropertyRelative("Letterlike_Symbols").boolValue = getDataCheckbox("Letterlike_Symbols"); - FontOptions.FindPropertyRelative("Enclosed_Alphanumerics").boolValue = getDataCheckbox("Enclosed_Alphanumerics"); - FontOptions.FindPropertyRelative("Number_Forms").boolValue = getDataCheckbox("Number_Forms"); - FontOptions.FindPropertyRelative("Currency_Symbols").boolValue = getDataCheckbox("Currency_Symbols"); - FontOptions.FindPropertyRelative("Arrows").boolValue = getDataCheckbox("Arrows"); - FontOptions.FindPropertyRelative("Geometric_Shapes").boolValue = getDataCheckbox("Geometric_Shapes"); - FontOptions.FindPropertyRelative("Mathematical_Operators").boolValue = getDataCheckbox("Mathematical_Operators"); - FontOptions.FindPropertyRelative("CustomUnicode").stringValue = getDataInput("CustomUnicode"); - FontOptions.FindPropertyRelative("Arrows").boolValue = getDataCheckbox("Arrows"); - FontOptions.FindPropertyRelative("Geometric_Shapes").boolValue = getDataCheckbox("Geometric_Shapes"); - FontOptions.FindPropertyRelative("Mathematical_Operators").boolValue = getDataCheckbox("Mathematical_Operators"); - FontOptions.FindPropertyRelative("CustomUnicode").stringValue = getDataInput("CustomUnicode"); - - miniGameProperty.FindPropertyRelative("m_AutomaticFillInstantGame").boolValue = getDataCheckbox("m_AutomaticFillInstantGame"); - - serializedObject.ApplyModifiedProperties(); - } - - private bool getDataCheckbox(string target) - { - if (formCheckboxData.ContainsKey(target)) - return formCheckboxData[target]; - return false; - } - - private string getDataInput(string target) - { - if (formInputData.ContainsKey(target)) - return formInputData[target]; - return ""; - } - - private int getDataPop(string target) - { - if (formIntPopupData.ContainsKey(target)) - return formIntPopupData[target]; - return 0; - } - - private void setData(string target, string value) - { - if (formInputData.ContainsKey(target)) - { - formInputData[target] = value; - } - else - { - formInputData.Add(target, value); - } - } - - private void setData(string target, bool value) - { - if (formCheckboxData.ContainsKey(target)) - { - formCheckboxData[target] = value; - } - else - { - formCheckboxData.Add(target, value); - } - } - - private void setData(string target, int value) - { - if (formIntPopupData.ContainsKey(target)) - { - formIntPopupData[target] = value; - } - else - { - formIntPopupData.Add(target, value); - } - } - - private void formInput(string target, string label, string help = null) - { - if (!formInputData.ContainsKey(target)) - { - formInputData[target] = ""; - } - GUILayout.BeginHorizontal(); - EditorGUILayout.LabelField(string.Empty, GUILayout.Width(10)); - if (help == null) - { - GUILayout.Label(label, GUILayout.Width(140)); - } - else - { - GUILayout.Label(new GUIContent(label, help), GUILayout.Width(140)); - } - formInputData[target] = GUILayout.TextField(formInputData[target], GUILayout.MaxWidth(EditorGUIUtility.currentViewWidth - 195)); - GUILayout.EndHorizontal(); - } - - private void formCheckbox(string target, string label, string help = null, bool disable = false, Action setting = null) - { - if (!formCheckboxData.ContainsKey(target)) - { - formCheckboxData[target] = false; - } - GUILayout.BeginHorizontal(); - EditorGUILayout.LabelField(string.Empty, GUILayout.Width(10)); - if (help == null) - { - GUILayout.Label(label, GUILayout.Width(140)); - } - else - { - GUILayout.Label(new GUIContent(label, help), GUILayout.Width(140)); - } - EditorGUI.BeginDisabledGroup(disable); - formCheckboxData[target] = EditorGUILayout.Toggle(disable ? false : formCheckboxData[target]); - - if (setting != null) - { - EditorGUILayout.LabelField("", GUILayout.Width(10)); - // ���ð�ť - if (GUILayout.Button(new GUIContent("����"), GUILayout.Width(40), GUILayout.Height(18))) - { - setting?.Invoke(true); - } - EditorGUILayout.LabelField("", GUILayout.MinWidth(10)); - } - - EditorGUI.EndDisabledGroup(); - - if (setting == null) - EditorGUILayout.LabelField(string.Empty); - GUILayout.EndHorizontal(); - } - - private void formIntPopup(string target, string label, string[] options, int[] values) - { - if (!formIntPopupData.ContainsKey(target)) - { - formIntPopupData[target] = 0; - } - GUILayout.BeginHorizontal(); - EditorGUILayout.LabelField(string.Empty, GUILayout.Width(10)); - GUILayout.Label(label, GUILayout.Width(140)); - formIntPopupData[target] = EditorGUILayout.IntPopup(formIntPopupData[target], options, values, GUILayout.MaxWidth(EditorGUIUtility.currentViewWidth - 195)); - GUILayout.EndHorizontal(); - } - - public static bool IsAbsolutePath(string path) - { - // 检查是否为空或空白 - if (string.IsNullOrWhiteSpace(path)) - { - return false; - } - - // 在 Windows 上,检查驱动器字母或网络路径 - if (Application.platform == RuntimePlatform.WindowsEditor && Path.IsPathRooted(path)) - { - return true; - } - - // 在 Unix/Linux 和 macOS 上,检查是否以 '/' 开头 - if (Application.platform == RuntimePlatform.OSXEditor && path.StartsWith("/")) - { - return true; - } - - return false; // 否则为相对路径 - } - - public static string GetAbsolutePath(string path) - { - if (IsAbsolutePath(path)) - { - return path; - } - string projectRootPath = System.IO.Path.GetFullPath(Application.dataPath + "/../"); - return Path.Combine(projectRootPath, path); - } } } #endif diff --git a/Editor/WXConvertCore.cs b/Editor/WXConvertCore.cs index b43838284..08f39476d 100644 --- a/Editor/WXConvertCore.cs +++ b/Editor/WXConvertCore.cs @@ -34,7 +34,14 @@ namespace WeChatWASM if(UnityUtil.GetEngineVersion() == UnityUtil.EngineVersion.Tuanjie) { var absolutePath = Path.GetFullPath("Packages/com.qq.weixin.minigame/WebGLTemplates/WXTemplate2022TJ"); - PlayerSettings.WeixinMiniGame.template = $"PATH:{absolutePath}"; + if (!Directory.Exists(absolutePath)) + { + PlayerSettings.WeixinMiniGame.template = $"{templateHeader}WXTemplate2022TJ"; + } + else + { + PlayerSettings.WeixinMiniGame.template = $"PATH:{absolutePath}"; + } } else { @@ -421,24 +428,24 @@ namespace WeChatWASM bool showEnableGLX2022Plugin = config.CompileOptions.enableEmscriptenGLX && IsCompatibleWithUnity202203OrNewer(); var glx2022Importer = AssetImporter.GetAtPath(glLibs[0]) as PluginImporter; - #if PLATFORM_WEIXINMINIGAME +#if PLATFORM_WEIXINMINIGAME glx2022Importer.SetCompatibleWithPlatform(BuildTarget.WeixinMiniGame, showEnableGLX2022Plugin); - #else - glx2022Importer.SetCompatibleWithPlatform(BuildTarget.WebGL, showEnableGLX2022Plugin); - #endif +#else + glx2022Importer.SetCompatibleWithPlatform(BuildTarget.WebGL, showEnableGLX2022Plugin); +#endif SetPluginCompatibilityByModifyingMetadataFile(glLibs[0], showEnableGLX2022Plugin); } - + { // unity2021 lib引入 bool showEnableGLX2021Plugin = config.CompileOptions.enableEmscriptenGLX && IsCompatibleWithUnity202102To202203(); var glx2021Importer = AssetImporter.GetAtPath(glLibs[1]) as PluginImporter; - #if PLATFORM_WEIXINMINIGAME +#if PLATFORM_WEIXINMINIGAME glx2021Importer.SetCompatibleWithPlatform(BuildTarget.WeixinMiniGame, showEnableGLX2021Plugin); - #else - glx2021Importer.SetCompatibleWithPlatform(BuildTarget.WebGL, showEnableGLX2021Plugin); - #endif +#else + glx2021Importer.SetCompatibleWithPlatform(BuildTarget.WebGL, showEnableGLX2021Plugin); +#endif SetPluginCompatibilityByModifyingMetadataFile(glLibs[1], showEnableGLX2021Plugin); } @@ -966,7 +973,7 @@ namespace WeChatWASM { new Rule() { - old = "if (GameGlobal.unityNamespace.enableProfileStats)", + old = "if (GameGlobal.unityNamespace.enableProfileStats)", newStr = "if (GameGlobal.unityNamespace.enableProfileStats || (typeof GameGlobal.manager.getWXAppCheatMonitor === 'function' && GameGlobal.manager.getWXAppCheatMonitor().shouldForceShowPerfMonitor()))" } }; diff --git a/Editor/WXEditorSettingHelper.cs b/Editor/WXEditorSettingHelper.cs index c6f91baae..a7f7417b2 100644 --- a/Editor/WXEditorSettingHelper.cs +++ b/Editor/WXEditorSettingHelper.cs @@ -80,54 +80,14 @@ namespace WeChatWASM PluginUpdateManager.CheckUpdateOnce(); scrollRoot = EditorGUILayout.BeginScrollView(scrollRoot); - GUIStyle linkStyle = new GUIStyle(GUI.skin.label); - linkStyle.normal.textColor = Color.yellow; - linkStyle.hover.textColor = Color.yellow; - linkStyle.stretchWidth = false; - linkStyle.alignment = TextAnchor.UpperLeft; - linkStyle.wordWrap = true; + GUIStyle linkStyle = GetLinkStyle(); foldBaseInfo = EditorGUILayout.Foldout(foldBaseInfo, "基本信息"); if (foldBaseInfo) { EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(true)); - - this.formInput("appid", "游戏AppID"); - this.formInput("cdn", "游戏资源CDN"); - this.formInput("projectName", "小游戏项目名"); - this.formIntPopup("orientation", "游戏方向", new[] { "Portrait", "Landscape", "LandscapeLeft", "LandscapeRight" }, new[] { 0, 1, 2, 3 }); - this.formInput("memorySize", "UnityHeap预留内存(?)", "单位MB,预分配内存值,超休闲游戏256/中轻度496/重度游戏768,需预估游戏最大UnityHeap值以防止内存自动扩容带来的峰值尖刺。预估方法请查看GIT文档《优化Unity WebGL的内存》"); - - GUILayout.BeginHorizontal(); - string targetDst = "dst"; - if (!formInputData.ContainsKey(targetDst)) - { - formInputData[targetDst] = ""; - } - EditorGUILayout.LabelField(string.Empty, GUILayout.Width(10)); - GUILayout.Label(new GUIContent("导出路径(?)", "支持输入相对于项目根目录的相对路径,如:wxbuild"), GUILayout.Width(140)); - formInputData[targetDst] = GUILayout.TextField(formInputData[targetDst], GUILayout.MaxWidth(EditorGUIUtility.currentViewWidth - 270)); - if (GUILayout.Button(new GUIContent("打开"), GUILayout.Width(40))) - { - if (!formInputData[targetDst].Trim().Equals(string.Empty)) - { - EditorUtility.RevealInFinder(GetAbsolutePath(formInputData[targetDst])); - } - GUIUtility.ExitGUI(); - } - if (GUILayout.Button(new GUIContent("选择"), GUILayout.Width(40))) - { - var dstPath = EditorUtility.SaveFolderPanel("选择你的游戏导出目录", string.Empty, string.Empty); - if (dstPath != string.Empty) - { - formInputData[targetDst] = dstPath; - this.saveData(); - } - GUIUtility.ExitGUI(); - } - GUILayout.EndHorizontal(); - - + OnSettingBaseInfo(); + OnSettingChooseFolder(); EditorGUILayout.EndVertical(); } @@ -148,12 +108,7 @@ namespace WeChatWASM } GUILayout.EndHorizontal(); - this.formInput("videoUrl", "加载阶段视频URL"); - this.formIntPopup("assetLoadType", "首包资源加载方式", new[] { "CDN", "小游戏包内" }, new[] { 0, 1 }); - this.formCheckbox("compressDataPackage", "压缩首包资源(?)", "将首包资源Brotli压缩, 降低资源大小. 注意: 首次启动耗时可能会增加200ms, 仅推荐使用小游戏分包加载时节省包体大小使用"); - this.formInput("bundleExcludeExtensions", "不自动缓存文件类型(?)", "(使用;分割)当请求url包含资源'cdn+StreamingAssets'时会自动缓存,但StreamingAssets目录下不是所有文件都需缓存,此选项配置不需要自动缓存的文件拓展名。默认值json"); - this.formInput("bundleHashLength", "Bundle名称Hash长度(?)", "自定义Bundle文件名中hash部分长度,默认值32,用于缓存控制。"); - this.formInput("preloadFiles", "预下载文件列表(?)", "使用;间隔,支持模糊匹配"); + OnSettingLoadingConfig(); EditorGUILayout.EndVertical(); } @@ -162,55 +117,14 @@ namespace WeChatWASM if (foldSDKOptions) { EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(true)); - - this.formCheckbox("useFriendRelation", "使用好友关系链"); - this.formCheckbox("useMiniGameChat", "使用社交组件"); - this.formCheckbox("preloadWXFont", "预加载微信字体(?)", "在game.js执行开始时预载微信系统字体,运行期间可使用WX.GetWXFont获取微信字体"); - this.formCheckbox("disableMultiTouch", "禁用多点触控"); - + OnSettingSDKOptions(); EditorGUILayout.EndVertical(); } foldDebugOptions = EditorGUILayout.Foldout(foldDebugOptions, "调试编译选项"); if (foldDebugOptions) { - EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(true)); - - - this.formCheckbox("developBuild", "Development Build", "", false, null, OnDevelopmentBuildToggleChanged); - this.formCheckbox("autoProfile", "Auto connect Profiler"); - this.formCheckbox("scriptOnly", "Scripts Only Build"); - this.formCheckbox("il2CppOptimizeSize", "Il2Cpp Optimize Size(?)", "对应于Il2CppCodeGeneration选项,勾选时使用OptimizeSize(默认推荐),生成代码小15%左右,取消勾选则使用OptimizeSpeed。游戏中大量泛型集合的高频访问建议OptimizeSpeed,在使用HybridCLR等第三方组件时只能用OptimizeSpeed。(Dotnet Runtime模式下该选项无效)", !UseIL2CPP); - this.formCheckbox("profilingFuncs", "Profiling Funcs"); - this.formCheckbox("profilingMemory", "Profiling Memory"); - this.formCheckbox("webgl2", "WebGL2.0"); - this.formCheckbox("iOSPerformancePlus", "iOSPerformancePlus(?)", "是否使用iOS高性能+渲染方案,有助于提升渲染兼容性、降低WebContent进程内存"); - this.formCheckbox("EmscriptenGLX", "EmscriptenGLX(?)", "是否使用EmscriptenGLX渲染方案"); - this.formCheckbox("iOSMetal", "iOSMetal(?)", "是否使用iOSMetal渲染方案,需要开启iOS高性能+模式,有助于提升运行性能,降低iOS功耗"); - this.formCheckbox("deleteStreamingAssets", "Clear Streaming Assets"); - this.formCheckbox("cleanBuild", "Clean WebGL Build"); - // this.formCheckbox("cleanCloudDev", "Clean Cloud Dev"); - this.formCheckbox("fbslim", "首包资源优化(?)", "导出时自动清理UnityEditor默认打包但游戏项目从未使用的资源,瘦身首包资源体积。(团结引擎已无需开启该能力)", UnityUtil.GetEngineVersion() > 0, (res) => - { - var fbWin = EditorWindow.GetWindow(typeof(WXFbSettingWindow), false, "首包资源优化配置面板", true); - fbWin.minSize = new Vector2(680, 350); - fbWin.Show(); - }); - this.formCheckbox("autoAdaptScreen", "自适应屏幕尺寸(?)", "移动端旋转屏幕和PC端拉伸窗口时,自动调整画布尺寸"); - this.formCheckbox("showMonitorSuggestModal", "显示优化建议弹窗"); - this.formCheckbox("enableProfileStats", "显示性能面板"); - this.formCheckbox("enableRenderAnalysis", "显示渲染日志(dev only)"); - this.formCheckbox("brotliMT", "brotli多线程压缩(?)", "开启多线程压缩可以提高出包速度,但会降低压缩率。如若不使用wasm代码分包请勿用多线程出包上线"); -#if UNITY_6000_0_OR_NEWER - this.formCheckbox("enableWasm2023", "WebAssembly 2023(?)", "WebAssembly 2023包括对WebAssembly.Table和BigInt的支持。(Android (Android 10 or later recommended), iOS (iOS 15 or later recommended))"); -#endif - - if (m_EnablePerfTool) - { - this.formCheckbox("enablePerfAnalysis", "集成性能分析工具", "将性能分析工具集成入Development Build包中", false, null, OnPerfAnalysisFeatureToggleChanged); - } - - EditorGUILayout.EndVertical(); + OnSettingDebugOptions(true); } @@ -265,31 +179,268 @@ namespace WeChatWASM if (foldFontOptions) { EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(true)); - this.formCheckbox("CJK_Unified_Ideographs", "基本汉字(?)", "Unicode [0x4e00, 0x9fff]"); - this.formCheckbox("C0_Controls_and_Basic_Latin", "基本拉丁语(英文大小写、数字、英文标点)(?)", "Unicode [0x0, 0x7f]"); - this.formCheckbox("CJK_Symbols_and_Punctuation", "中文标点符号(?)", "Unicode [0x3000, 0x303f]"); - this.formCheckbox("General_Punctuation", "通用标点符号(?)", "Unicode [0x2000, 0x206f]"); - this.formCheckbox("Enclosed_CJK_Letters_and_Months", "CJK字母及月份(?)", "Unicode [0x3200, 0x32ff]"); - this.formCheckbox("Vertical_Forms", "中文竖排标点(?)", "Unicode [0xfe10, 0xfe1f]"); - this.formCheckbox("CJK_Compatibility_Forms", "CJK兼容符号(?)", "Unicode [0xfe30, 0xfe4f]"); - this.formCheckbox("Miscellaneous_Symbols", "杂项符号(?)", "Unicode [0x2600, 0x26ff]"); - this.formCheckbox("CJK_Compatibility", "CJK特殊符号(?)", "Unicode [0x3300, 0x33ff]"); - this.formCheckbox("Halfwidth_and_Fullwidth_Forms", "全角ASCII、全角中英文标点、半宽片假名、半宽平假名、半宽韩文字母(?)", "Unicode [0xff00, 0xffef]"); - this.formCheckbox("Dingbats", "装饰符号(?)", "Unicode [0x2700, 0x27bf]"); - this.formCheckbox("Letterlike_Symbols", "字母式符号(?)", "Unicode [0x2100, 0x214f]"); - this.formCheckbox("Enclosed_Alphanumerics", "带圈或括号的字母数字(?)", "Unicode [0x2460, 0x24ff]"); - this.formCheckbox("Number_Forms", "数字形式(?)", "Unicode [0x2150, 0x218f]"); - this.formCheckbox("Currency_Symbols", "货币符号(?)", "Unicode [0x20a0, 0x20cf]"); - this.formCheckbox("Arrows", "箭头(?)", "Unicode [0x2190, 0x21ff]"); - this.formCheckbox("Geometric_Shapes", "几何图形(?)", "Unicode [0x25a0, 0x25ff]"); - this.formCheckbox("Mathematical_Operators", "数学运算符号(?)", "Unicode [0x2200, 0x22ff]"); - this.formInput("CustomUnicode", "自定义Unicode(?)", "将填入的所有字符强制加入字体预加载列表"); + OnSettingFontOptions(); EditorGUILayout.EndVertical(); } EditorGUILayout.EndScrollView(); } + public void OnSettingsGUI(SerializedObject serializedObject, SerializedProperty miniGameProperty) + { + loadData(serializedObject, miniGameProperty); + + scrollRoot = EditorGUILayout.BeginScrollView(scrollRoot); + + GUIStyle linkStyle = GetLinkStyle(); + + foldBaseInfo = EditorGUILayout.Foldout(foldBaseInfo, "基本信息"); + if (foldBaseInfo) + { + EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(true)); + OnSettingBaseInfo(); + EditorGUILayout.EndVertical(); + } + + foldLoadingConfig = EditorGUILayout.Foldout(foldLoadingConfig, "启动Loading配置"); + if (foldLoadingConfig) + { + EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(true)); + + // Call saveData(serializedObject, miniGameProperty) not saveData() + GUILayout.BeginHorizontal(); + string targetBg = "bgImageSrc"; + EditorGUILayout.LabelField(string.Empty, GUILayout.Width(10)); + tex = (Texture)EditorGUILayout.ObjectField("启动背景图/视频封面", tex, typeof(Texture2D), false); + var currentBgSrc = AssetDatabase.GetAssetPath(tex); + if (!string.IsNullOrEmpty(currentBgSrc) && currentBgSrc != formInputData[targetBg]) + { + formInputData[targetBg] = currentBgSrc; + saveData(serializedObject, miniGameProperty); + } + GUILayout.EndHorizontal(); + + OnSettingLoadingConfig(); + + EditorGUILayout.EndVertical(); + } + + foldSDKOptions = EditorGUILayout.Foldout(foldSDKOptions, "SDK功能选项"); + if (foldSDKOptions) + { + EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(true)); + OnSettingSDKOptions(); + EditorGUILayout.EndVertical(); + } + + foldDebugOptions = EditorGUILayout.Foldout(foldDebugOptions, "调试编译选项"); + if (foldDebugOptions) + { + OnSettingDebugOptions(false); + } + + if (WXConvertCore.IsInstantGameAutoStreaming()) + { + foldInstantGame = EditorGUILayout.Foldout(foldInstantGame, "Instant Game - AutoStreaming"); + if (foldInstantGame) + { + EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(true)); + formInput("bundlePathIdentifier", "Bundle Path Identifier"); + formInput("dataFileSubPrefix", "Data File Sub Prefix"); + + EditorGUI.BeginDisabledGroup(true); + formCheckbox("autoUploadFirstBundle", "构建后自动上传首包(?)", "仅在开启AutoStreaming生效", true); + EditorGUI.EndDisabledGroup(); + + GUILayout.BeginHorizontal(); + EditorGUILayout.LabelField(string.Empty, GUILayout.Width(10)); + GUILayout.Label(new GUIContent("清理AS配置(?)", "如需关闭AutoStreaming选用默认发布方案则需要清理AS配置项目。"), GUILayout.Width(140)); + EditorGUI.BeginDisabledGroup(WXConvertCore.IsInstantGameAutoStreaming()); + // It is not same as OnSettingsGUI(EditorWindow) + if (GUILayout.Button(new GUIContent("恢复"), GUILayout.Width(60))) + { + var ProjectConf = miniGameProperty.FindPropertyRelative("ProjectConf"); + string identifier = ProjectConf.FindPropertyRelative("bundlePathIdentifier").stringValue; + string[] identifiers = identifier.Split(";"); + string idStr = ""; + foreach (string id in identifiers) + { + if (id != "AS" && id != "CUS/CustomAB") + { + idStr += id + ";"; + } + } + ProjectConf.FindPropertyRelative("bundlePathIdentifier").stringValue = idStr.Trim(';'); + + if (ProjectConf.FindPropertyRelative("dataFileSubPrefix").stringValue == "CUS") + { + ProjectConf.FindPropertyRelative("dataFileSubPrefix").stringValue = ""; + } + loadData(serializedObject, miniGameProperty); + } + EditorGUI.EndDisabledGroup(); + GUILayout.EndHorizontal(); + + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField(string.Empty); + if (GUILayout.Button(new GUIContent("了解Instant Game AutoStreaming", ""), linkStyle)) + { + Application.OpenURL("https://github.com/wechat-miniprogram/minigame-unity-webgl-transform/blob/main/Design/InstantGameGuide.md"); + } + EditorGUILayout.EndHorizontal(); + EditorGUILayout.EndVertical(); + } + } + + foldFontOptions = EditorGUILayout.Foldout(foldFontOptions, "字体配置"); + if (foldFontOptions) + { + EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(true)); + OnSettingFontOptions(); + EditorGUILayout.EndVertical(); + } + + EditorGUILayout.EndScrollView(); + saveData(serializedObject, miniGameProperty); + } + + private GUIStyle GetLinkStyle() + { + GUIStyle linkStyle = new GUIStyle(GUI.skin.label); + linkStyle.normal.textColor = Color.yellow; + linkStyle.hover.textColor = Color.yellow; + linkStyle.stretchWidth = false; + linkStyle.alignment = TextAnchor.UpperLeft; + linkStyle.wordWrap = true; + return linkStyle; + } + + private void OnSettingBaseInfo() + { + this.formInput("appid", "游戏AppID"); + this.formInput("cdn", "游戏资源CDN"); + this.formInput("projectName", "小游戏项目名"); + this.formIntPopup("orientation", "游戏方向", new[] { "Portrait", "Landscape", "LandscapeLeft", "LandscapeRight" }, new[] { 0, 1, 2, 3 }); + this.formInput("memorySize", "UnityHeap预留内存(?)", "单位MB,预分配内存值,超休闲游戏256/中轻度496/重度游戏768,需预估游戏最大UnityHeap值以防止内存自动扩容带来的峰值尖刺。预估方法请查看GIT文档《优化Unity WebGL的内存》"); + } + + private void OnSettingChooseFolder() + { + GUILayout.BeginHorizontal(); + string targetDst = "dst"; + if (!formInputData.ContainsKey(targetDst)) + { + formInputData[targetDst] = ""; + } + EditorGUILayout.LabelField(string.Empty, GUILayout.Width(10)); + GUILayout.Label(new GUIContent("导出路径(?)", "支持输入相对于项目根目录的相对路径,如:wxbuild"), GUILayout.Width(140)); + formInputData[targetDst] = GUILayout.TextField(formInputData[targetDst], GUILayout.MaxWidth(EditorGUIUtility.currentViewWidth - 270)); + if (GUILayout.Button(new GUIContent("打开"), GUILayout.Width(40))) + { + if (!formInputData[targetDst].Trim().Equals(string.Empty)) + { + EditorUtility.RevealInFinder(GetAbsolutePath(formInputData[targetDst])); + } + GUIUtility.ExitGUI(); + } + if (GUILayout.Button(new GUIContent("选择"), GUILayout.Width(40))) + { + var dstPath = EditorUtility.SaveFolderPanel("选择你的游戏导出目录", string.Empty, string.Empty); + if (dstPath != string.Empty) + { + formInputData[targetDst] = dstPath; + this.saveData(); + } + GUIUtility.ExitGUI(); + } + GUILayout.EndHorizontal(); + } + + private void OnSettingLoadingConfig() + { + this.formInput("videoUrl", "加载阶段视频URL"); + this.formIntPopup("assetLoadType", "首包资源加载方式", new[] { "CDN", "小游戏包内" }, new[] { 0, 1 }); + this.formCheckbox("compressDataPackage", "压缩首包资源(?)", "将首包资源Brotli压缩, 降低资源大小. 注意: 首次启动耗时可能会增加200ms, 仅推荐使用小游戏分包加载时节省包体大小使用"); + this.formInput("bundleExcludeExtensions", "不自动缓存文件类型(?)", "(使用;分割)当请求url包含资源'cdn+StreamingAssets'时会自动缓存,但StreamingAssets目录下不是所有文件都需缓存,此选项配置不需要自动缓存的文件拓展名。默认值json"); + this.formInput("bundleHashLength", "Bundle名称Hash长度(?)", "自定义Bundle文件名中hash部分长度,默认值32,用于缓存控制。"); + this.formInput("preloadFiles", "预下载文件列表(?)", "使用;间隔,支持模糊匹配"); + } + + private void OnSettingSDKOptions() + { + formCheckbox("useFriendRelation", "使用好友关系链"); + formCheckbox("useMiniGameChat", "使用社交组件"); + formCheckbox("preloadWXFont", "预加载微信字体(?)", "在game.js执行开始时预载微信系统字体,运行期间可使用WX.GetWXFont获取微信字体"); + formCheckbox("disableMultiTouch", "禁止多点触控"); + } + + private void OnSettingDebugOptions(bool showDevBuild) + { + EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(true)); + + if (showDevBuild) + { + this.formCheckbox("developBuild", "Development Build", "", false, null, OnDevelopmentBuildToggleChanged); + } + this.formCheckbox("autoProfile", "Auto connect Profiler"); + this.formCheckbox("scriptOnly", "Scripts Only Build"); + this.formCheckbox("il2CppOptimizeSize", "Il2Cpp Optimize Size(?)", "对应于Il2CppCodeGeneration选项,勾选时使用OptimizeSize(默认推荐),生成代码小15%左右,取消勾选则使用OptimizeSpeed。游戏中大量泛型集合的高频访问建议OptimizeSpeed,在使用HybridCLR等第三方组件时只能用OptimizeSpeed。(Dotnet Runtime模式下该选项无效)", !UseIL2CPP); + this.formCheckbox("profilingFuncs", "Profiling Funcs"); + this.formCheckbox("profilingMemory", "Profiling Memory"); + this.formCheckbox("webgl2", "WebGL2.0"); + this.formCheckbox("iOSPerformancePlus", "iOSPerformancePlus(?)", "是否使用iOS高性能+渲染方案,有助于提升渲染兼容性、降低WebContent进程内存"); + this.formCheckbox("EmscriptenGLX", "EmscriptenGLX(?)", "是否使用EmscriptenGLX渲染方案"); + this.formCheckbox("iOSMetal", "iOSMetal(?)", "是否使用iOSMetal渲染方案,需要开启iOS高性能+模式,有助于提升运行性能,降低iOS功耗"); + this.formCheckbox("deleteStreamingAssets", "Clear Streaming Assets"); + this.formCheckbox("cleanBuild", "Clean WebGL Build"); + // this.formCheckbox("cleanCloudDev", "Clean Cloud Dev"); + this.formCheckbox("fbslim", "首包资源优化(?)", "导出时自动清理UnityEditor默认打包但游戏项目从未使用的资源,瘦身首包资源体积。(团结引擎已无需开启该能力)", UnityUtil.GetEngineVersion() > 0, (res) => + { + var fbWin = EditorWindow.GetWindow(typeof(WXFbSettingWindow), false, "首包资源优化配置面板", true); + fbWin.minSize = new Vector2(680, 350); + fbWin.Show(); + }); + this.formCheckbox("autoAdaptScreen", "自适应屏幕尺寸(?)", "移动端旋转屏幕和PC端拉伸窗口时,自动调整画布尺寸"); + this.formCheckbox("showMonitorSuggestModal", "显示优化建议弹窗"); + this.formCheckbox("enableProfileStats", "显示性能面板"); + this.formCheckbox("enableRenderAnalysis", "显示渲染日志(dev only)"); + this.formCheckbox("brotliMT", "brotli多线程压缩(?)", "开启多线程压缩可以提高出包速度,但会降低压缩率。如若不使用wasm代码分包请勿用多线程出包上线"); +#if UNITY_6000_0_OR_NEWER + this.formCheckbox("enableWasm2023", "WebAssembly 2023(?)", "WebAssembly 2023包括对WebAssembly.Table和BigInt的支持。(Android (Android 10 or later recommended), iOS (iOS 15 or later recommended))"); +#endif + + if (m_EnablePerfTool) + { + this.formCheckbox("enablePerfAnalysis", "集成性能分析工具", "将性能分析工具集成入Development Build包中", false, null, OnPerfAnalysisFeatureToggleChanged); + } + + EditorGUILayout.EndVertical(); + } + + private void OnSettingFontOptions() + { + formCheckbox("CJK_Unified_Ideographs", "基本汉字(?)", "Unicode [0x4e00, 0x9fff]"); + formCheckbox("C0_Controls_and_Basic_Latin", "基本拉丁语(英文大小写、数字、英文标点)(?)", "Unicode [0x0, 0x7f]"); + formCheckbox("CJK_Symbols_and_Punctuation", "中文标点符号(?)", "Unicode [0x3000, 0x303f]"); + formCheckbox("General_Punctuation", "通用标点符号(?)", "Unicode [0x2000, 0x206f]"); + formCheckbox("Enclosed_CJK_Letters_and_Months", "CJK字母及月份(?)", "Unicode [0x3200, 0x32ff]"); + formCheckbox("Vertical_Forms", "中文竖排标点(?)", "Unicode [0xfe10, 0xfe1f]"); + formCheckbox("CJK_Compatibility_Forms", "CJK兼容符号(?)", "Unicode [0xfe30, 0xfe4f]"); + formCheckbox("Miscellaneous_Symbols", "杂项符号(?)", "Unicode [0x2600, 0x26ff]"); + formCheckbox("CJK_Compatibility", "CJK特殊符号(?)", "Unicode [0x3300, 0x33ff]"); + formCheckbox("Halfwidth_and_Fullwidth_Forms", "全角ASCII、全角中英文标点、半宽片假名、半宽平假名、半宽韩文字母(?)", "Unicode [0xff00, 0xffef]"); + formCheckbox("Dingbats", "装饰符号(?)", "Unicode [0x2700, 0x27bf]"); + formCheckbox("Letterlike_Symbols", "字母式符号(?)", "Unicode [0x2100, 0x214f]"); + formCheckbox("Enclosed_Alphanumerics", "带圈或括号的字母数字(?)", "Unicode [0x2460, 0x24ff]"); + formCheckbox("Number_Forms", "数字形式(?)", "Unicode [0x2150, 0x218f]"); + formCheckbox("Currency_Symbols", "货币符号(?)", "Unicode [0x20a0, 0x20cf]"); + formCheckbox("Arrows", "箭头(?)", "Unicode [0x2190, 0x21ff]"); + formCheckbox("Geometric_Shapes", "几何图形(?)", "Unicode [0x25a0, 0x25ff]"); + formCheckbox("Mathematical_Operators", "数学运算符号(?)", "Unicode [0x2200, 0x22ff]"); + formInput("CustomUnicode", "自定义Unicode(?)", "将填入的所有字符强制加入字体预加载列表"); + } + + public void OnBuildButtonGUI(EditorWindow window) { GUIStyle linkStyle = new GUIStyle(GUI.skin.label); @@ -426,162 +577,454 @@ namespace WeChatWASM } } - this.setData("projectName", config.ProjectConf.projectName); - this.setData("appid", config.ProjectConf.Appid); - this.setData("cdn", config.ProjectConf.CDN); - this.setData("assetLoadType", config.ProjectConf.assetLoadType); - this.setData("compressDataPackage", config.ProjectConf.compressDataPackage); - this.setData("videoUrl", config.ProjectConf.VideoUrl); - this.setData("orientation", (int)config.ProjectConf.Orientation); - this.setData("dst", config.ProjectConf.relativeDST); - this.setData("bundleHashLength", config.ProjectConf.bundleHashLength.ToString()); - this.setData("bundlePathIdentifier", config.ProjectConf.bundlePathIdentifier); - this.setData("bundleExcludeExtensions", config.ProjectConf.bundleExcludeExtensions); - this.setData("preloadFiles", config.ProjectConf.preloadFiles); - this.setData("developBuild", config.CompileOptions.DevelopBuild); - this.setData("autoProfile", config.CompileOptions.AutoProfile); - this.setData("scriptOnly", config.CompileOptions.ScriptOnly); - this.setData("il2CppOptimizeSize", config.CompileOptions.Il2CppOptimizeSize); - this.setData("profilingFuncs", config.CompileOptions.profilingFuncs); - this.setData("profilingMemory", config.CompileOptions.ProfilingMemory); - this.setData("deleteStreamingAssets", config.CompileOptions.DeleteStreamingAssets); - this.setData("cleanBuild", config.CompileOptions.CleanBuild); - this.setData("customNodePath", config.CompileOptions.CustomNodePath); - this.setData("webgl2", config.CompileOptions.Webgl2); - this.setData("iOSPerformancePlus", config.CompileOptions.enableIOSPerformancePlus); - this.setData("iOSMetal", config.CompileOptions.enableiOSMetal); - this.setData("EmscriptenGLX", config.CompileOptions.enableEmscriptenGLX); - this.setData("fbslim", config.CompileOptions.fbslim); - this.setData("useFriendRelation", config.SDKOptions.UseFriendRelation); - this.setData("useMiniGameChat", config.SDKOptions.UseMiniGameChat); - this.setData("preloadWXFont", config.SDKOptions.PreloadWXFont); - this.setData("disableMultiTouch", config.SDKOptions.disableMultiTouch); - this.setData("bgImageSrc", config.ProjectConf.bgImageSrc); - tex = AssetDatabase.LoadAssetAtPath(config.ProjectConf.bgImageSrc); - this.setData("memorySize", config.ProjectConf.MemorySize.ToString()); - this.setData("hideAfterCallMain", config.ProjectConf.HideAfterCallMain); - - this.setData("dataFileSubPrefix", config.ProjectConf.dataFileSubPrefix); - this.setData("maxStorage", config.ProjectConf.maxStorage.ToString()); - this.setData("defaultReleaseSize", config.ProjectConf.defaultReleaseSize.ToString()); - this.setData("texturesHashLength", config.ProjectConf.texturesHashLength.ToString()); - this.setData("texturesPath", config.ProjectConf.texturesPath); - this.setData("needCacheTextures", config.ProjectConf.needCacheTextures); - this.setData("loadingBarWidth", config.ProjectConf.loadingBarWidth.ToString()); - this.setData("needCheckUpdate", config.ProjectConf.needCheckUpdate); - this.setData("disableHighPerformanceFallback", config.ProjectConf.disableHighPerformanceFallback); - this.setData("autoAdaptScreen", config.CompileOptions.autoAdaptScreen); - this.setData("showMonitorSuggestModal", config.CompileOptions.showMonitorSuggestModal); - this.setData("enableProfileStats", config.CompileOptions.enableProfileStats); - this.setData("enableRenderAnalysis", config.CompileOptions.enableRenderAnalysis); - this.setData("brotliMT", config.CompileOptions.brotliMT); -#if UNITY_6000_0_OR_NEWER - this.setData("enableWasm2023", config.CompileOptions.enableWasm2023); -#endif - this.setData("enablePerfAnalysis", config.CompileOptions.enablePerfAnalysis); this.setData("autoUploadFirstBundle", true); + loadProjectConfData(config.ProjectConf); + loadSDKOptionsData(config.SDKOptions); + loadCompileOptionsData(config.CompileOptions); + loadFontOptionsData(config.FontOptions); + } - // font options - this.setData("CJK_Unified_Ideographs", config.FontOptions.CJK_Unified_Ideographs); - this.setData("C0_Controls_and_Basic_Latin", config.FontOptions.C0_Controls_and_Basic_Latin); - this.setData("CJK_Symbols_and_Punctuation", config.FontOptions.CJK_Symbols_and_Punctuation); - this.setData("General_Punctuation", config.FontOptions.General_Punctuation); - this.setData("Enclosed_CJK_Letters_and_Months", config.FontOptions.Enclosed_CJK_Letters_and_Months); - this.setData("Vertical_Forms", config.FontOptions.Vertical_Forms); - this.setData("CJK_Compatibility_Forms", config.FontOptions.CJK_Compatibility_Forms); - this.setData("Miscellaneous_Symbols", config.FontOptions.Miscellaneous_Symbols); - this.setData("CJK_Compatibility", config.FontOptions.CJK_Compatibility); - this.setData("Halfwidth_and_Fullwidth_Forms", config.FontOptions.Halfwidth_and_Fullwidth_Forms); - this.setData("Dingbats", config.FontOptions.Dingbats); - this.setData("Letterlike_Symbols", config.FontOptions.Letterlike_Symbols); - this.setData("Enclosed_Alphanumerics", config.FontOptions.Enclosed_Alphanumerics); - this.setData("Number_Forms", config.FontOptions.Number_Forms); - this.setData("Currency_Symbols", config.FontOptions.Currency_Symbols); - this.setData("Arrows", config.FontOptions.Arrows); - this.setData("Geometric_Shapes", config.FontOptions.Geometric_Shapes); - this.setData("Mathematical_Operators", config.FontOptions.Mathematical_Operators); - this.setData("CustomUnicode", config.FontOptions.CustomUnicode); + private void loadData(SerializedObject serializedObject, SerializedProperty miniGameProperty) + { + serializedObject.UpdateIfRequiredOrScript(); + var ProjectConf = miniGameProperty.FindPropertyRelative("ProjectConf"); + + // Instant Game + if (WXConvertCore.IsInstantGameAutoStreaming()) + { + var automaticfillinstantgame = miniGameProperty.FindPropertyRelative("m_AutomaticFillInstantGame"); + if (automaticfillinstantgame.boolValue) + { + ProjectConf.FindPropertyRelative("CDN").stringValue = WXConvertCore.GetInstantGameAutoStreamingCDN(); + if (!ProjectConf.FindPropertyRelative("bundlePathIdentifier").stringValue.Contains("AS;")) + { + ProjectConf.FindPropertyRelative("bundlePathIdentifier").stringValue += "AS;"; + } + if (!ProjectConf.FindPropertyRelative("bundlePathIdentifier").stringValue.Contains("CUS/CustomAB;")) + { + ProjectConf.FindPropertyRelative("bundlePathIdentifier").stringValue += "CUS/CustomAB;"; + } + ProjectConf.FindPropertyRelative("dataFileSubPrefix").stringValue = "CUS"; + } + } + + var _ProjectConf = new WXProjectConf(); + deserializeProjectConf(_ProjectConf, ProjectConf); + loadProjectConfData(_ProjectConf); + + var SDKOptions = miniGameProperty.FindPropertyRelative("SDKOptions"); + var _SDKOptions = new SDKOptions(); + deserializeSDKOptions(_SDKOptions, SDKOptions); + loadSDKOptionsData(_SDKOptions); + + var CompileOptions = miniGameProperty.FindPropertyRelative("CompileOptions"); + var _CompileOptions = new CompileOptions(); + deserializeCompileOptions(_CompileOptions, CompileOptions); + loadCompileOptionsData(_CompileOptions); + + var FontOptions = miniGameProperty.FindPropertyRelative("FontOptions"); + var _FontOptions = new FontOptions(); + deserializeFontOptions(_FontOptions, FontOptions); + loadFontOptionsData(_FontOptions); + } + + private void loadProjectConfData(WXProjectConf ProjectConf) + { + this.setData("projectName", ProjectConf.projectName); + this.setData("appid", ProjectConf.Appid); + this.setData("cdn", ProjectConf.CDN); + this.setData("assetLoadType", ProjectConf.assetLoadType); + this.setData("compressDataPackage", ProjectConf.compressDataPackage); + this.setData("videoUrl", ProjectConf.VideoUrl); + this.setData("orientation", (int)ProjectConf.Orientation); + this.setData("dst", ProjectConf.relativeDST); + this.setData("bundleHashLength", ProjectConf.bundleHashLength.ToString()); + this.setData("bundlePathIdentifier", ProjectConf.bundlePathIdentifier); + this.setData("bundleExcludeExtensions", ProjectConf.bundleExcludeExtensions); + this.setData("preloadFiles", ProjectConf.preloadFiles); + this.setData("bgImageSrc", ProjectConf.bgImageSrc); + + tex = AssetDatabase.LoadAssetAtPath(ProjectConf.bgImageSrc); + this.setData("memorySize", ProjectConf.MemorySize.ToString()); + this.setData("hideAfterCallMain", ProjectConf.HideAfterCallMain); + + this.setData("dataFileSubPrefix", ProjectConf.dataFileSubPrefix); + this.setData("maxStorage", ProjectConf.maxStorage.ToString()); + this.setData("defaultReleaseSize", ProjectConf.defaultReleaseSize.ToString()); + this.setData("texturesHashLength", ProjectConf.texturesHashLength.ToString()); + this.setData("texturesPath", ProjectConf.texturesPath); + this.setData("needCacheTextures", ProjectConf.needCacheTextures); + this.setData("loadingBarWidth", ProjectConf.loadingBarWidth.ToString()); + this.setData("needCheckUpdate", ProjectConf.needCheckUpdate); + this.setData("disableHighPerformanceFallback", ProjectConf.disableHighPerformanceFallback); + } + + private void loadSDKOptionsData(SDKOptions SDKOptions) + { + this.setData("useFriendRelation", SDKOptions.UseFriendRelation); + this.setData("useMiniGameChat", SDKOptions.UseMiniGameChat); + this.setData("preloadWXFont", SDKOptions.PreloadWXFont); + this.setData("disableMultiTouch", SDKOptions.disableMultiTouch); + } + + private void loadCompileOptionsData(CompileOptions CompileOptions) + { + this.setData("developBuild", CompileOptions.DevelopBuild); + this.setData("autoProfile", CompileOptions.AutoProfile); + this.setData("scriptOnly", CompileOptions.ScriptOnly); + this.setData("il2CppOptimizeSize", CompileOptions.Il2CppOptimizeSize); + this.setData("profilingFuncs", CompileOptions.profilingFuncs); + this.setData("profilingMemory", CompileOptions.ProfilingMemory); + this.setData("deleteStreamingAssets", CompileOptions.DeleteStreamingAssets); + this.setData("cleanBuild", CompileOptions.CleanBuild); + this.setData("customNodePath", CompileOptions.CustomNodePath); + this.setData("webgl2", CompileOptions.Webgl2); + this.setData("iOSPerformancePlus", CompileOptions.enableIOSPerformancePlus); + this.setData("iOSMetal", CompileOptions.enableiOSMetal); + this.setData("EmscriptenGLX", CompileOptions.enableEmscriptenGLX); + this.setData("fbslim", CompileOptions.fbslim); + this.setData("autoAdaptScreen", CompileOptions.autoAdaptScreen); + this.setData("showMonitorSuggestModal", CompileOptions.showMonitorSuggestModal); + this.setData("enableProfileStats", CompileOptions.enableProfileStats); + this.setData("enableRenderAnalysis", CompileOptions.enableRenderAnalysis); + this.setData("brotliMT", CompileOptions.brotliMT); +#if UNITY_6000_0_OR_NEWER + this.setData("enableWasm2023", CompileOptions.enableWasm2023); +#endif + this.setData("enablePerfAnalysis", CompileOptions.enablePerfAnalysis); + } + + private void loadFontOptionsData(FontOptions FontOptions) + { + this.setData("CJK_Unified_Ideographs", FontOptions.CJK_Unified_Ideographs); + this.setData("C0_Controls_and_Basic_Latin", FontOptions.C0_Controls_and_Basic_Latin); + this.setData("CJK_Symbols_and_Punctuation", FontOptions.CJK_Symbols_and_Punctuation); + this.setData("General_Punctuation", FontOptions.General_Punctuation); + this.setData("Enclosed_CJK_Letters_and_Months", FontOptions.Enclosed_CJK_Letters_and_Months); + this.setData("Vertical_Forms", FontOptions.Vertical_Forms); + this.setData("CJK_Compatibility_Forms", FontOptions.CJK_Compatibility_Forms); + this.setData("Miscellaneous_Symbols", FontOptions.Miscellaneous_Symbols); + this.setData("CJK_Compatibility", FontOptions.CJK_Compatibility); + this.setData("Halfwidth_and_Fullwidth_Forms", FontOptions.Halfwidth_and_Fullwidth_Forms); + this.setData("Dingbats", FontOptions.Dingbats); + this.setData("Letterlike_Symbols", FontOptions.Letterlike_Symbols); + this.setData("Enclosed_Alphanumerics", FontOptions.Enclosed_Alphanumerics); + this.setData("Number_Forms", FontOptions.Number_Forms); + this.setData("Currency_Symbols", FontOptions.Currency_Symbols); + this.setData("Arrows", FontOptions.Arrows); + this.setData("Geometric_Shapes", FontOptions.Geometric_Shapes); + this.setData("Mathematical_Operators", FontOptions.Mathematical_Operators); + this.setData("CustomUnicode", FontOptions.CustomUnicode); } private void saveData() { - config.ProjectConf.projectName = this.getDataInput("projectName"); - config.ProjectConf.Appid = this.getDataInput("appid"); - config.ProjectConf.CDN = this.getDataInput("cdn"); - config.ProjectConf.assetLoadType = this.getDataPop("assetLoadType"); - config.ProjectConf.compressDataPackage = this.getDataCheckbox("compressDataPackage"); - config.ProjectConf.VideoUrl = this.getDataInput("videoUrl"); - config.ProjectConf.Orientation = (WXScreenOritation)this.getDataPop("orientation"); - config.ProjectConf.relativeDST = this.getDataInput("dst"); - config.ProjectConf.DST = GetAbsolutePath(config.ProjectConf.relativeDST); - config.ProjectConf.bundleHashLength = int.Parse(this.getDataInput("bundleHashLength")); - config.ProjectConf.bundlePathIdentifier = this.getDataInput("bundlePathIdentifier"); - config.ProjectConf.bundleExcludeExtensions = this.getDataInput("bundleExcludeExtensions"); - config.ProjectConf.preloadFiles = this.getDataInput("preloadFiles"); - config.CompileOptions.DevelopBuild = this.getDataCheckbox("developBuild"); - config.CompileOptions.AutoProfile = this.getDataCheckbox("autoProfile"); - config.CompileOptions.ScriptOnly = this.getDataCheckbox("scriptOnly"); - config.CompileOptions.Il2CppOptimizeSize = this.getDataCheckbox("il2CppOptimizeSize"); - config.CompileOptions.profilingFuncs = this.getDataCheckbox("profilingFuncs"); - config.CompileOptions.ProfilingMemory = this.getDataCheckbox("profilingMemory"); - config.CompileOptions.DeleteStreamingAssets = this.getDataCheckbox("deleteStreamingAssets"); - config.CompileOptions.CleanBuild = this.getDataCheckbox("cleanBuild"); - config.CompileOptions.CustomNodePath = this.getDataInput("customNodePath"); - config.CompileOptions.Webgl2 = this.getDataCheckbox("webgl2"); - config.CompileOptions.enableIOSPerformancePlus = this.getDataCheckbox("iOSPerformancePlus"); - config.CompileOptions.enableiOSMetal = this.getDataCheckbox("iOSMetal"); - config.CompileOptions.enableEmscriptenGLX = this.getDataCheckbox("EmscriptenGLX"); - config.CompileOptions.fbslim = this.getDataCheckbox("fbslim"); - config.SDKOptions.UseFriendRelation = this.getDataCheckbox("useFriendRelation"); - config.SDKOptions.UseMiniGameChat = this.getDataCheckbox("useMiniGameChat"); - config.SDKOptions.PreloadWXFont = this.getDataCheckbox("preloadWXFont"); - config.SDKOptions.disableMultiTouch = this.getDataCheckbox("disableMultiTouch"); - config.ProjectConf.bgImageSrc = this.getDataInput("bgImageSrc"); - config.ProjectConf.MemorySize = int.Parse(this.getDataInput("memorySize")); - config.ProjectConf.HideAfterCallMain = this.getDataCheckbox("hideAfterCallMain"); - config.ProjectConf.dataFileSubPrefix = this.getDataInput("dataFileSubPrefix"); - config.ProjectConf.maxStorage = int.Parse(this.getDataInput("maxStorage")); - config.ProjectConf.defaultReleaseSize = int.Parse(this.getDataInput("defaultReleaseSize")); - config.ProjectConf.texturesHashLength = int.Parse(this.getDataInput("texturesHashLength")); - config.ProjectConf.texturesPath = this.getDataInput("texturesPath"); - config.ProjectConf.needCacheTextures = this.getDataCheckbox("needCacheTextures"); - config.ProjectConf.loadingBarWidth = int.Parse(this.getDataInput("loadingBarWidth")); - config.ProjectConf.needCheckUpdate = this.getDataCheckbox("needCheckUpdate"); - config.ProjectConf.disableHighPerformanceFallback = this.getDataCheckbox("disableHighPerformanceFallback"); - config.CompileOptions.autoAdaptScreen = this.getDataCheckbox("autoAdaptScreen"); - config.CompileOptions.showMonitorSuggestModal = this.getDataCheckbox("showMonitorSuggestModal"); - config.CompileOptions.enableProfileStats = this.getDataCheckbox("enableProfileStats"); - config.CompileOptions.enableRenderAnalysis = this.getDataCheckbox("enableRenderAnalysis"); - config.CompileOptions.brotliMT = this.getDataCheckbox("brotliMT"); -#if UNITY_6000_0_OR_NEWER - config.CompileOptions.enableWasm2023 = this.getDataCheckbox("enableWasm2023"); -#endif - config.CompileOptions.enablePerfAnalysis = this.getDataCheckbox("enablePerfAnalysis"); - - // font options - config.FontOptions.CJK_Unified_Ideographs = this.getDataCheckbox("CJK_Unified_Ideographs"); - config.FontOptions.C0_Controls_and_Basic_Latin = this.getDataCheckbox("C0_Controls_and_Basic_Latin"); - config.FontOptions.CJK_Symbols_and_Punctuation = this.getDataCheckbox("CJK_Symbols_and_Punctuation"); - config.FontOptions.General_Punctuation = this.getDataCheckbox("General_Punctuation"); - config.FontOptions.Enclosed_CJK_Letters_and_Months = this.getDataCheckbox("Enclosed_CJK_Letters_and_Months"); - config.FontOptions.Vertical_Forms = this.getDataCheckbox("Vertical_Forms"); - config.FontOptions.CJK_Compatibility_Forms = this.getDataCheckbox("CJK_Compatibility_Forms"); - config.FontOptions.Miscellaneous_Symbols = this.getDataCheckbox("Miscellaneous_Symbols"); - config.FontOptions.CJK_Compatibility = this.getDataCheckbox("CJK_Compatibility"); - config.FontOptions.Halfwidth_and_Fullwidth_Forms = this.getDataCheckbox("Halfwidth_and_Fullwidth_Forms"); - config.FontOptions.Dingbats = this.getDataCheckbox("Dingbats"); - config.FontOptions.Letterlike_Symbols = this.getDataCheckbox("Letterlike_Symbols"); - config.FontOptions.Enclosed_Alphanumerics = this.getDataCheckbox("Enclosed_Alphanumerics"); - config.FontOptions.Number_Forms = this.getDataCheckbox("Number_Forms"); - config.FontOptions.Currency_Symbols = this.getDataCheckbox("Currency_Symbols"); - config.FontOptions.Arrows = this.getDataCheckbox("Arrows"); - config.FontOptions.Geometric_Shapes = this.getDataCheckbox("Geometric_Shapes"); - config.FontOptions.Mathematical_Operators = this.getDataCheckbox("Mathematical_Operators"); - config.FontOptions.CustomUnicode = this.getDataInput("CustomUnicode"); + saveProjectConfData(config.ProjectConf); + saveSDKOptionsData(config.SDKOptions); + saveCompileOptionsData(config.CompileOptions); + saveFontOptionsData(config.FontOptions); ApplyPerfAnalysisSetting(); } + private void saveData(SerializedObject serializedObject, SerializedProperty miniGameProperty) + { + serializedObject.UpdateIfRequiredOrScript(); + + var ProjectConf = miniGameProperty.FindPropertyRelative("ProjectConf"); + var _ProjectConf = new WXProjectConf(); + saveProjectConfData(_ProjectConf); + serializeProjectConf(_ProjectConf, ProjectConf); + + var CompileOptions = miniGameProperty.FindPropertyRelative("CompileOptions"); + var _CompileOptions = new CompileOptions(); + saveCompileOptionsData(_CompileOptions); + serializeCompileOptions(_CompileOptions, CompileOptions); + + var SDKOptions = miniGameProperty.FindPropertyRelative("SDKOptions"); + var _SDKOptions = new SDKOptions(); + saveSDKOptionsData(_SDKOptions); + serializeSDKOptions(_SDKOptions, SDKOptions); + + var FontOptions = miniGameProperty.FindPropertyRelative("FontOptions"); + var _FontOptions = new FontOptions(); + saveFontOptionsData(_FontOptions); + serializeFontOptions(_FontOptions, FontOptions); + + miniGameProperty.FindPropertyRelative("m_AutomaticFillInstantGame").boolValue = getDataCheckbox("m_AutomaticFillInstantGame"); + + serializedObject.ApplyModifiedProperties(); + } + + private void saveProjectConfData(WXProjectConf ProjectConf) + { + ProjectConf.projectName = this.getDataInput("projectName"); + ProjectConf.Appid = this.getDataInput("appid"); + ProjectConf.CDN = this.getDataInput("cdn"); + ProjectConf.assetLoadType = this.getDataPop("assetLoadType"); + ProjectConf.compressDataPackage = this.getDataCheckbox("compressDataPackage"); + ProjectConf.VideoUrl = this.getDataInput("videoUrl"); + ProjectConf.Orientation = (WXScreenOritation)this.getDataPop("orientation"); + ProjectConf.relativeDST = this.getDataInput("dst"); + ProjectConf.DST = GetAbsolutePath(ProjectConf.relativeDST); + ProjectConf.bundleHashLength = int.Parse(this.getDataInput("bundleHashLength")); + ProjectConf.bundlePathIdentifier = this.getDataInput("bundlePathIdentifier"); + ProjectConf.bundleExcludeExtensions = this.getDataInput("bundleExcludeExtensions"); + ProjectConf.preloadFiles = this.getDataInput("preloadFiles"); + + ProjectConf.bgImageSrc = this.getDataInput("bgImageSrc"); + ProjectConf.MemorySize = int.Parse(this.getDataInput("memorySize")); + ProjectConf.HideAfterCallMain = this.getDataCheckbox("hideAfterCallMain"); + ProjectConf.dataFileSubPrefix = this.getDataInput("dataFileSubPrefix"); + ProjectConf.maxStorage = int.Parse(this.getDataInput("maxStorage")); + ProjectConf.defaultReleaseSize = int.Parse(this.getDataInput("defaultReleaseSize")); + ProjectConf.texturesHashLength = int.Parse(this.getDataInput("texturesHashLength")); + ProjectConf.texturesPath = this.getDataInput("texturesPath"); + ProjectConf.needCacheTextures = this.getDataCheckbox("needCacheTextures"); + ProjectConf.loadingBarWidth = int.Parse(this.getDataInput("loadingBarWidth")); + ProjectConf.needCheckUpdate = this.getDataCheckbox("needCheckUpdate"); + ProjectConf.disableHighPerformanceFallback = this.getDataCheckbox("disableHighPerformanceFallback"); + } + + private void saveSDKOptionsData(SDKOptions SDKOptions) + { + SDKOptions.UseFriendRelation = this.getDataCheckbox("useFriendRelation"); + SDKOptions.UseMiniGameChat = this.getDataCheckbox("useMiniGameChat"); + SDKOptions.PreloadWXFont = this.getDataCheckbox("preloadWXFont"); + SDKOptions.disableMultiTouch = this.getDataCheckbox("disableMultiTouch"); + } + + private void saveCompileOptionsData(CompileOptions CompileOptions) + { + CompileOptions.DevelopBuild = this.getDataCheckbox("developBuild"); + CompileOptions.AutoProfile = this.getDataCheckbox("autoProfile"); + CompileOptions.ScriptOnly = this.getDataCheckbox("scriptOnly"); + CompileOptions.Il2CppOptimizeSize = this.getDataCheckbox("il2CppOptimizeSize"); + CompileOptions.profilingFuncs = this.getDataCheckbox("profilingFuncs"); + CompileOptions.ProfilingMemory = this.getDataCheckbox("profilingMemory"); + CompileOptions.DeleteStreamingAssets = this.getDataCheckbox("deleteStreamingAssets"); + CompileOptions.CleanBuild = this.getDataCheckbox("cleanBuild"); + CompileOptions.CustomNodePath = this.getDataInput("customNodePath"); + CompileOptions.Webgl2 = this.getDataCheckbox("webgl2"); + CompileOptions.enableIOSPerformancePlus = this.getDataCheckbox("iOSPerformancePlus"); + CompileOptions.enableiOSMetal = this.getDataCheckbox("iOSMetal"); + CompileOptions.enableEmscriptenGLX = this.getDataCheckbox("EmscriptenGLX"); + CompileOptions.fbslim = this.getDataCheckbox("fbslim"); + + CompileOptions.autoAdaptScreen = this.getDataCheckbox("autoAdaptScreen"); + CompileOptions.showMonitorSuggestModal = this.getDataCheckbox("showMonitorSuggestModal"); + CompileOptions.enableProfileStats = this.getDataCheckbox("enableProfileStats"); + CompileOptions.enableRenderAnalysis = this.getDataCheckbox("enableRenderAnalysis"); + CompileOptions.brotliMT = this.getDataCheckbox("brotliMT"); +#if UNITY_6000_0_OR_NEWER + CompileOptions.enableWasm2023 = this.getDataCheckbox("enableWasm2023"); +#endif + CompileOptions.enablePerfAnalysis = this.getDataCheckbox("enablePerfAnalysis"); + } + + private void saveFontOptionsData(FontOptions FontOptions) + { + FontOptions.CJK_Unified_Ideographs = this.getDataCheckbox("CJK_Unified_Ideographs"); + FontOptions.C0_Controls_and_Basic_Latin = this.getDataCheckbox("C0_Controls_and_Basic_Latin"); + FontOptions.CJK_Symbols_and_Punctuation = this.getDataCheckbox("CJK_Symbols_and_Punctuation"); + FontOptions.General_Punctuation = this.getDataCheckbox("General_Punctuation"); + FontOptions.Enclosed_CJK_Letters_and_Months = this.getDataCheckbox("Enclosed_CJK_Letters_and_Months"); + FontOptions.Vertical_Forms = this.getDataCheckbox("Vertical_Forms"); + FontOptions.CJK_Compatibility_Forms = this.getDataCheckbox("CJK_Compatibility_Forms"); + FontOptions.Miscellaneous_Symbols = this.getDataCheckbox("Miscellaneous_Symbols"); + FontOptions.CJK_Compatibility = this.getDataCheckbox("CJK_Compatibility"); + FontOptions.Halfwidth_and_Fullwidth_Forms = this.getDataCheckbox("Halfwidth_and_Fullwidth_Forms"); + FontOptions.Dingbats = this.getDataCheckbox("Dingbats"); + FontOptions.Letterlike_Symbols = this.getDataCheckbox("Letterlike_Symbols"); + FontOptions.Enclosed_Alphanumerics = this.getDataCheckbox("Enclosed_Alphanumerics"); + FontOptions.Number_Forms = this.getDataCheckbox("Number_Forms"); + FontOptions.Currency_Symbols = this.getDataCheckbox("Currency_Symbols"); + FontOptions.Arrows = this.getDataCheckbox("Arrows"); + FontOptions.Geometric_Shapes = this.getDataCheckbox("Geometric_Shapes"); + FontOptions.Mathematical_Operators = this.getDataCheckbox("Mathematical_Operators"); + FontOptions.CustomUnicode = this.getDataInput("CustomUnicode"); + } + + private void deserializeProjectConf(WXProjectConf _ProjectConf, SerializedProperty ProjectConf) + { + _ProjectConf.projectName = ProjectConf.FindPropertyRelative("projectName").stringValue; + _ProjectConf.Appid = ProjectConf.FindPropertyRelative("Appid").stringValue; + _ProjectConf.CDN = ProjectConf.FindPropertyRelative("CDN").stringValue; + _ProjectConf.assetLoadType = ProjectConf.FindPropertyRelative("assetLoadType").intValue; + _ProjectConf.compressDataPackage = ProjectConf.FindPropertyRelative("compressDataPackage").boolValue; + _ProjectConf.VideoUrl = ProjectConf.FindPropertyRelative("VideoUrl").stringValue; + _ProjectConf.Orientation = (WXScreenOritation)ProjectConf.FindPropertyRelative("Orientation").enumValueIndex; + _ProjectConf.relativeDST = ProjectConf.FindPropertyRelative("relativeDST").stringValue; + _ProjectConf.DST = ProjectConf.FindPropertyRelative("DST").stringValue; + + _ProjectConf.bundleHashLength = ProjectConf.FindPropertyRelative("bundleHashLength").intValue; + _ProjectConf.bundlePathIdentifier = ProjectConf.FindPropertyRelative("bundlePathIdentifier").stringValue; + _ProjectConf.bundleExcludeExtensions = ProjectConf.FindPropertyRelative("bundleExcludeExtensions").stringValue; + _ProjectConf.preloadFiles = ProjectConf.FindPropertyRelative("preloadFiles").stringValue; + _ProjectConf.bgImageSrc = ProjectConf.FindPropertyRelative("bgImageSrc").stringValue; + _ProjectConf.MemorySize = ProjectConf.FindPropertyRelative("MemorySize").intValue; + _ProjectConf.HideAfterCallMain = ProjectConf.FindPropertyRelative("HideAfterCallMain").boolValue; + _ProjectConf.dataFileSubPrefix = ProjectConf.FindPropertyRelative("dataFileSubPrefix").stringValue; + _ProjectConf.maxStorage = ProjectConf.FindPropertyRelative("maxStorage").intValue; + _ProjectConf.defaultReleaseSize = ProjectConf.FindPropertyRelative("defaultReleaseSize").intValue; + _ProjectConf.texturesHashLength = ProjectConf.FindPropertyRelative("texturesHashLength").intValue; + _ProjectConf.texturesPath = ProjectConf.FindPropertyRelative("texturesPath").stringValue; + _ProjectConf.needCacheTextures = ProjectConf.FindPropertyRelative("needCacheTextures").boolValue; + _ProjectConf.loadingBarWidth = ProjectConf.FindPropertyRelative("loadingBarWidth").intValue; + _ProjectConf.needCheckUpdate = ProjectConf.FindPropertyRelative("needCheckUpdate").boolValue; + _ProjectConf.disableHighPerformanceFallback = ProjectConf.FindPropertyRelative("disableHighPerformanceFallback").boolValue; + } + private void serializeProjectConf(WXProjectConf _ProjectConf, SerializedProperty ProjectConf) + { + ProjectConf.FindPropertyRelative("projectName").stringValue = _ProjectConf.projectName; + ProjectConf.FindPropertyRelative("Appid").stringValue = _ProjectConf.Appid; + ProjectConf.FindPropertyRelative("CDN").stringValue = _ProjectConf.CDN; + ProjectConf.FindPropertyRelative("assetLoadType").intValue = _ProjectConf.assetLoadType; + ProjectConf.FindPropertyRelative("compressDataPackage").boolValue = _ProjectConf.compressDataPackage; + ProjectConf.FindPropertyRelative("VideoUrl").stringValue = _ProjectConf.VideoUrl; + ProjectConf.FindPropertyRelative("Orientation").enumValueIndex = (int)_ProjectConf.Orientation; + ProjectConf.FindPropertyRelative("relativeDST").stringValue = _ProjectConf.relativeDST; + ProjectConf.FindPropertyRelative("DST").stringValue = _ProjectConf.DST; + + ProjectConf.FindPropertyRelative("bundleHashLength").intValue = _ProjectConf.bundleHashLength; + ProjectConf.FindPropertyRelative("bundlePathIdentifier").stringValue = _ProjectConf.bundlePathIdentifier; + ProjectConf.FindPropertyRelative("bundleExcludeExtensions").stringValue = _ProjectConf.bundleExcludeExtensions; + ProjectConf.FindPropertyRelative("preloadFiles").stringValue = _ProjectConf.preloadFiles; + ProjectConf.FindPropertyRelative("bgImageSrc").stringValue = _ProjectConf.bgImageSrc; + ProjectConf.FindPropertyRelative("MemorySize").intValue = _ProjectConf.MemorySize; + ProjectConf.FindPropertyRelative("HideAfterCallMain").boolValue = _ProjectConf.HideAfterCallMain; + ProjectConf.FindPropertyRelative("dataFileSubPrefix").stringValue = _ProjectConf.dataFileSubPrefix; + ProjectConf.FindPropertyRelative("maxStorage").intValue = _ProjectConf.maxStorage; + ProjectConf.FindPropertyRelative("defaultReleaseSize").intValue = _ProjectConf.defaultReleaseSize; + ProjectConf.FindPropertyRelative("texturesHashLength").intValue = _ProjectConf.texturesHashLength; + ProjectConf.FindPropertyRelative("texturesPath").stringValue = _ProjectConf.texturesPath; + ProjectConf.FindPropertyRelative("needCacheTextures").boolValue = _ProjectConf.needCacheTextures; + ProjectConf.FindPropertyRelative("loadingBarWidth").intValue = _ProjectConf.loadingBarWidth; + ProjectConf.FindPropertyRelative("needCheckUpdate").boolValue = _ProjectConf.needCheckUpdate; + ProjectConf.FindPropertyRelative("disableHighPerformanceFallback").boolValue = _ProjectConf.disableHighPerformanceFallback; + + //miniGameProperty.FindPropertyRelative("m_AutomaticFillInstantGame").boolValue = getDataCheckbox("m_AutomaticFillInstantGame"); + + } + + private void deserializeSDKOptions(SDKOptions _SDKOptions, SerializedProperty SDKOptions) + { + _SDKOptions.UseFriendRelation = SDKOptions.FindPropertyRelative("UseFriendRelation").boolValue; + _SDKOptions.UseMiniGameChat = SDKOptions.FindPropertyRelative("UseMiniGameChat").boolValue; + _SDKOptions.PreloadWXFont = SDKOptions.FindPropertyRelative("PreloadWXFont").boolValue; + _SDKOptions.disableMultiTouch = SDKOptions.FindPropertyRelative("disableMultiTouch").boolValue; + } + private void serializeSDKOptions(SDKOptions _SDKOptionsf, SerializedProperty SDKOptions) + { + SDKOptions.FindPropertyRelative("UseFriendRelation").boolValue = _SDKOptionsf.UseFriendRelation; + SDKOptions.FindPropertyRelative("UseMiniGameChat").boolValue = _SDKOptionsf.UseMiniGameChat; + SDKOptions.FindPropertyRelative("PreloadWXFont").boolValue = _SDKOptionsf.PreloadWXFont; + SDKOptions.FindPropertyRelative("disableMultiTouch").boolValue = _SDKOptionsf.disableMultiTouch; + } + + private void deserializeCompileOptions(CompileOptions _CompileOptions, SerializedProperty CompileOptions) + { + //CompileOptions.FindPropertyRelative("DevelopBuild").boolValue = serializedObject.FindProperty("m_PlatformSettings").FindPropertyRelative("m_Development").boolValue; + _CompileOptions.DevelopBuild = CompileOptions.FindPropertyRelative("DevelopBuild").boolValue; + _CompileOptions.AutoProfile = CompileOptions.FindPropertyRelative("AutoProfile").boolValue; + _CompileOptions.ScriptOnly = CompileOptions.FindPropertyRelative("ScriptOnly").boolValue; + _CompileOptions.Il2CppOptimizeSize = CompileOptions.FindPropertyRelative("Il2CppOptimizeSize").boolValue; + _CompileOptions.profilingFuncs = CompileOptions.FindPropertyRelative("profilingFuncs").boolValue; + _CompileOptions.ProfilingMemory = CompileOptions.FindPropertyRelative("ProfilingMemory").boolValue; + _CompileOptions.DeleteStreamingAssets = CompileOptions.FindPropertyRelative("DeleteStreamingAssets").boolValue; + _CompileOptions.CleanBuild = CompileOptions.FindPropertyRelative("CleanBuild").boolValue; + _CompileOptions.CustomNodePath = CompileOptions.FindPropertyRelative("CustomNodePath").stringValue; + _CompileOptions.Webgl2 = CompileOptions.FindPropertyRelative("Webgl2").boolValue; + _CompileOptions.enableIOSPerformancePlus = CompileOptions.FindPropertyRelative("enableIOSPerformancePlus").boolValue; + _CompileOptions.enableiOSMetal = CompileOptions.FindPropertyRelative("enableiOSMetal").boolValue; + _CompileOptions.enableEmscriptenGLX = CompileOptions.FindPropertyRelative("enableEmscriptenGLX").boolValue; + _CompileOptions.fbslim = CompileOptions.FindPropertyRelative("fbslim").boolValue; + + _CompileOptions.autoAdaptScreen = CompileOptions.FindPropertyRelative("autoAdaptScreen").boolValue; + _CompileOptions.showMonitorSuggestModal = CompileOptions.FindPropertyRelative("showMonitorSuggestModal").boolValue; + _CompileOptions.enableProfileStats = CompileOptions.FindPropertyRelative("enableProfileStats").boolValue; + _CompileOptions.enableRenderAnalysis = CompileOptions.FindPropertyRelative("enableRenderAnalysis").boolValue; + _CompileOptions.brotliMT = CompileOptions.FindPropertyRelative("brotliMT").boolValue; +#if UNITY_6000_0_OR_NEWER + _CompileOptions.enableWasm2023 = CompileOptions.FindPropertyRelative("enableWasm2023").boolValue; +#endif + _CompileOptions.enablePerfAnalysis = CompileOptions.FindPropertyRelative("enablePerfAnalysis").boolValue; + } + private void serializeCompileOptions(CompileOptions _CompileOptions, SerializedProperty CompileOptions) + { + //CompileOptions.FindPropertyRelative("DevelopBuild").boolValue = serializedObject.FindProperty("m_PlatformSettings").FindPropertyRelative("m_Development").boolValue; + CompileOptions.FindPropertyRelative("AutoProfile").boolValue = _CompileOptions.AutoProfile; + CompileOptions.FindPropertyRelative("ScriptOnly").boolValue = _CompileOptions.ScriptOnly; + CompileOptions.FindPropertyRelative("Il2CppOptimizeSize").boolValue = _CompileOptions.Il2CppOptimizeSize; + CompileOptions.FindPropertyRelative("profilingFuncs").boolValue = _CompileOptions.profilingFuncs; + CompileOptions.FindPropertyRelative("ProfilingMemory").boolValue = _CompileOptions.ProfilingMemory; + CompileOptions.FindPropertyRelative("DeleteStreamingAssets").boolValue = _CompileOptions.DeleteStreamingAssets; + CompileOptions.FindPropertyRelative("CleanBuild").boolValue = _CompileOptions.CleanBuild; + CompileOptions.FindPropertyRelative("CustomNodePath").stringValue = _CompileOptions.CustomNodePath; + CompileOptions.FindPropertyRelative("Webgl2").boolValue = _CompileOptions.Webgl2; + CompileOptions.FindPropertyRelative("enableIOSPerformancePlus").boolValue = _CompileOptions.enableIOSPerformancePlus; + CompileOptions.FindPropertyRelative("enableiOSMetal").boolValue = _CompileOptions.enableiOSMetal; + CompileOptions.FindPropertyRelative("enableEmscriptenGLX").boolValue = _CompileOptions.enableEmscriptenGLX; + CompileOptions.FindPropertyRelative("fbslim").boolValue = _CompileOptions.fbslim; + + CompileOptions.FindPropertyRelative("autoAdaptScreen").boolValue = _CompileOptions.autoAdaptScreen; + CompileOptions.FindPropertyRelative("showMonitorSuggestModal").boolValue = _CompileOptions.showMonitorSuggestModal; + CompileOptions.FindPropertyRelative("enableProfileStats").boolValue = _CompileOptions.enableProfileStats; + CompileOptions.FindPropertyRelative("enableRenderAnalysis").boolValue = _CompileOptions.enableRenderAnalysis; + CompileOptions.FindPropertyRelative("brotliMT").boolValue = _CompileOptions.brotliMT; + + } + + private void deserializeFontOptions(FontOptions _FontOptions, SerializedProperty FontOptions) + { + _FontOptions.CJK_Unified_Ideographs = FontOptions.FindPropertyRelative("CJK_Unified_Ideographs").boolValue; + _FontOptions.C0_Controls_and_Basic_Latin = FontOptions.FindPropertyRelative("C0_Controls_and_Basic_Latin").boolValue; + _FontOptions.CJK_Symbols_and_Punctuation = FontOptions.FindPropertyRelative("CJK_Symbols_and_Punctuation").boolValue; + _FontOptions.General_Punctuation = FontOptions.FindPropertyRelative("General_Punctuation").boolValue; + _FontOptions.Enclosed_CJK_Letters_and_Months = FontOptions.FindPropertyRelative("Enclosed_CJK_Letters_and_Months").boolValue; + _FontOptions.Vertical_Forms = FontOptions.FindPropertyRelative("Vertical_Forms").boolValue; + _FontOptions.CJK_Compatibility_Forms = FontOptions.FindPropertyRelative("CJK_Compatibility_Forms").boolValue; + _FontOptions.Miscellaneous_Symbols = FontOptions.FindPropertyRelative("Miscellaneous_Symbols").boolValue; + _FontOptions.CJK_Compatibility = FontOptions.FindPropertyRelative("CJK_Compatibility").boolValue; + _FontOptions.Halfwidth_and_Fullwidth_Forms = FontOptions.FindPropertyRelative("Halfwidth_and_Fullwidth_Forms").boolValue; + _FontOptions.Dingbats = FontOptions.FindPropertyRelative("Dingbats").boolValue; + _FontOptions.Letterlike_Symbols = FontOptions.FindPropertyRelative("Letterlike_Symbols").boolValue; + _FontOptions.Enclosed_Alphanumerics = FontOptions.FindPropertyRelative("Enclosed_Alphanumerics").boolValue; + _FontOptions.Number_Forms = FontOptions.FindPropertyRelative("Number_Forms").boolValue; + _FontOptions.Currency_Symbols = FontOptions.FindPropertyRelative("Currency_Symbols").boolValue; + _FontOptions.Arrows = FontOptions.FindPropertyRelative("Arrows").boolValue; + _FontOptions.Geometric_Shapes = FontOptions.FindPropertyRelative("Geometric_Shapes").boolValue; + _FontOptions.Mathematical_Operators = FontOptions.FindPropertyRelative("Mathematical_Operators").boolValue; + _FontOptions.CustomUnicode = FontOptions.FindPropertyRelative("CustomUnicode").stringValue; + } + private void serializeFontOptions(FontOptions _FontOptions, SerializedProperty FontOptions) + { + FontOptions.FindPropertyRelative("CJK_Unified_Ideographs").boolValue = _FontOptions.CJK_Unified_Ideographs; + FontOptions.FindPropertyRelative("C0_Controls_and_Basic_Latin").boolValue = _FontOptions.C0_Controls_and_Basic_Latin; + FontOptions.FindPropertyRelative("CJK_Symbols_and_Punctuation").boolValue = _FontOptions.CJK_Symbols_and_Punctuation; + FontOptions.FindPropertyRelative("General_Punctuation").boolValue = _FontOptions.General_Punctuation; + FontOptions.FindPropertyRelative("Enclosed_CJK_Letters_and_Months").boolValue = _FontOptions.Enclosed_CJK_Letters_and_Months; + FontOptions.FindPropertyRelative("Vertical_Forms").boolValue = _FontOptions.Vertical_Forms; + FontOptions.FindPropertyRelative("CJK_Compatibility_Forms").boolValue = _FontOptions.CJK_Compatibility_Forms; + FontOptions.FindPropertyRelative("Miscellaneous_Symbols").boolValue = _FontOptions.Miscellaneous_Symbols; + FontOptions.FindPropertyRelative("CJK_Compatibility").boolValue = _FontOptions.CJK_Compatibility; + FontOptions.FindPropertyRelative("Halfwidth_and_Fullwidth_Forms").boolValue = _FontOptions.Halfwidth_and_Fullwidth_Forms; + FontOptions.FindPropertyRelative("Dingbats").boolValue = _FontOptions.Dingbats; + FontOptions.FindPropertyRelative("Letterlike_Symbols").boolValue = _FontOptions.Letterlike_Symbols; + FontOptions.FindPropertyRelative("Enclosed_Alphanumerics").boolValue = _FontOptions.Enclosed_Alphanumerics; + FontOptions.FindPropertyRelative("Number_Forms").boolValue = _FontOptions.Number_Forms; + FontOptions.FindPropertyRelative("Currency_Symbols").boolValue = _FontOptions.Currency_Symbols; + FontOptions.FindPropertyRelative("Arrows").boolValue = _FontOptions.Arrows; + FontOptions.FindPropertyRelative("Geometric_Shapes").boolValue = _FontOptions.Geometric_Shapes; + FontOptions.FindPropertyRelative("Mathematical_Operators").boolValue = _FontOptions.Mathematical_Operators; + FontOptions.FindPropertyRelative("CustomUnicode").stringValue = _FontOptions.CustomUnicode; + FontOptions.FindPropertyRelative("Arrows").boolValue = _FontOptions.Arrows; + FontOptions.FindPropertyRelative("Geometric_Shapes").boolValue = _FontOptions.Geometric_Shapes; + FontOptions.FindPropertyRelative("Mathematical_Operators").boolValue = _FontOptions.Mathematical_Operators; + FontOptions.FindPropertyRelative("CustomUnicode").stringValue = _FontOptions.CustomUnicode; + } + + private string getDataInput(string target) { if (this.formInputData.ContainsKey(target)) diff --git a/Editor/WXExtDef.cs b/Editor/WXExtDef.cs index 54f139a28..864feebb5 100644 --- a/Editor/WXExtDef.cs +++ b/Editor/WXExtDef.cs @@ -107,6 +107,8 @@ namespace WeChatWASM #else WXExtEnvDef.SETDEF("PLATFORM_WEIXINMINIGAME", false); #endif + // TODO: 根据实际Emscripten版本检测逻辑来设置此值,当前暂时hardcode为true + WXExtEnvDef.SETDEF("UNITY_NEW_EMSCRIPTEN", true); RegisterController(); } diff --git a/Editor/WXPluginVersion.cs b/Editor/WXPluginVersion.cs index e9d555a4d..b8733b40b 100644 --- a/Editor/WXPluginVersion.cs +++ b/Editor/WXPluginVersion.cs @@ -2,7 +2,7 @@ namespace WeChatWASM { public class WXPluginVersion { - public static string pluginVersion = "202601131148"; // 这一行不要改他,导出的时候会自动替换 + public static string pluginVersion = "202603130254"; // 这一行不要改他,导出的时候会自动替换 } public class WXPluginConf diff --git a/Editor/wx-editor.dll b/Editor/wx-editor.dll index 2c7b37d3c..86db96f6d 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 f8ad6267b..eeb6c9620 100644 --- a/Editor/wx-editor.xml.meta +++ b/Editor/wx-editor.xml.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f847db20faa66610af5948c280c4a736 +guid: f28ad698909063047c117d2e6fea3231 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/Plugins/wx-perf.dll b/Runtime/Plugins/wx-perf.dll index 5d0b9cded..6be8ebf8a 100644 Binary files a/Runtime/Plugins/wx-perf.dll and b/Runtime/Plugins/wx-perf.dll differ diff --git a/Runtime/Plugins/wx-runtime-editor.dll b/Runtime/Plugins/wx-runtime-editor.dll index 99b1791cc..ab2b3bd5b 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 64b02fa45..49960d977 100644 --- a/Runtime/Plugins/wx-runtime-editor.xml +++ b/Runtime/Plugins/wx-runtime-editor.xml @@ -4,6 +4,91 @@ wx-runtime-editor + + + WX数据保护插件使用示例 + 演示如何使用数据保护功能来保护游戏中的重要数值 + + + + + 示例1:基础用法 - 存储和读取数据 + + + + + 示例2:安全获取数据(推荐方式) + + + + + 示例3:存储复杂对象 + + + + + 示例4:数据管理 + + + + + 数据篡改事件处理 + + + + + 处理数据篡改 + + + + + 示例:玩家属性数据结构 + 注意:使用 JsonUtility 序列化时,必须使用公共字段 + + + + + 游戏货币管理器示例 + 封装常用的货币操作,简化调用 + + + + + 初始化货币数据 + + + + + 获取金币数量 + + + + + 增加金币 + + + + + 消费金币 + + 是否消费成功 + + + + 获取钻石数量 + + + + + 增加钻石 + + + + + 消费钻石 + + 是否消费成功 + Banner 广告,详见 https://developers.weixin.qq.com/minigame/dev/guide/open-ability/ad/banner-ad.html @@ -3119,6 +3204,36 @@  是否结束 + + + 事件ID,开发者自行维护(必需) + + + + + 事件耗时,单位ms(可选)不填时为0 + + + + + 事件结果,默认成功(可选)不填时默认成功 + + + + + reportGameEvent的事件类型 + + + + + 成功事件 + + + + + 失败事件 + + 错误码,文档可见 https://developers.weixin.qq.com/minigame/dev/api/open-api/openlink/wx.createPageManager.html @@ -3295,7 +3410,7 @@ 需要基础库: `2.10.0` 小程序版本 可选值: - - 'develop': 开发版; + - 'develop': 开发版,提交代码审核时默认使用开发版进行审核。; - 'trial': 体验版; - 'release': 正式版; @@ -3371,6 +3486,11 @@ 允许微信读写日历的开关 + + + PC 内核版本号,仅在 PC 端存在该值 + + 客户端基础库版本 @@ -3473,6 +3593,14 @@ 客户端平台 + 可选值: + - 'ios': iOS微信(包含 iPhone、iPad); + - 'android': Android微信; + - 'ohos': HarmonyOS 手机端微信; + - 'ohos_pc': HarmonyOS PC微信; + - 'windows': Windows微信; + - 'mac': macOS微信; + - 'devtools': 微信开发者工具; @@ -3480,6 +3608,16 @@ 操作系统及版本 + + + 当前是否处于直接广告中 + + + + + 当前是否处于蒙层阶段 + + 需要基础库: `2.20.0` @@ -3546,6 +3684,11 @@ 直播间 id + + + 宿主传递的数据,第三方 app 中运行小游戏时返回 + + 启动小游戏的 query 参数 @@ -3576,6 +3719,11 @@ shareTicket,详见[获取更多转发信息](#) + + + 宿主app对应的场景值 + + 下边界坐标,单位:px @@ -3606,11 +3754,86 @@ 宽度,单位:px + + + 擂台赛组件领奖信息 + + 通知组件信息 + + + 福利组件信息 + + + + + 组件的名称 + + + + + 领取事件详情(只在onOfficialComponentsInfoChange回调中返回) + + + + + 奖励领取结果:1-全部成功, 2-部分成功(礼物达到领取上限), 3-领奖失败 + + + + + 是否收到了稀有奖励 + + + + + 用户领取的奖励列表 + + + + + 奖励类型:0-道具礼包, 1-微信蓝包, 2-h5商家券, 3-现金红包, 4-小程序券, 5-盲盒 + + + + + 奖励来源信息 + + + + + 获取的奖励数量 + + + + + 道具列表 + + + + + 奖励类型:1-普通奖励, 2-稀有奖励 + + + + + 礼包名称 + + + + + 道具名称 + + + + + 道具数量 + + 组件的布局位置信息 @@ -3626,6 +3849,46 @@ 组件的名称 + + + 可领取的好友礼包数量 + + + + + 可领取的礼包数量 + + + + + 组件的名称 + + + + + 领取事件详情(只在onOfficialComponentsInfoChange回调中返回) + + + + + 礼包描述,只有 gift 类型才有 + + + + + 礼包图标,只有 gift 类型才有 + + + + + 礼包名称,只有 gift 类型才有 + + + + + gift: 礼包, friendGift: 好友礼包 + + 当前占用的空间大小, 单位 KB @@ -3772,7 +4035,8 @@ 可选值: - 'ios': iOS微信(包含 iPhone、iPad); - 'android': Android微信; - - 'ohos': HarmonyOS微信; + - 'ohos': HarmonyOS 手机端微信; + - 'ohos_pc': HarmonyOS PC微信; - 'windows': Windows微信; - 'mac': macOS微信; - 'devtools': 微信开发者工具; @@ -4427,6 +4691,36 @@ 是否被添加至 「我的小程序」 + + + 错误信息 + + + + + 支付支持信息对象 + + + + + 调用结果信息,格式为 "checkIsSupportMidasPayment:ok" + + + + + 是否支持支付,true 表示支持,false 表示不支持 + + + + + 错误码,0 表示成功 + + + + + 错误信息,"success" 表示成功 + + 最多可以选择的图片张数 @@ -5595,22 +5889,22 @@ 预告状态:0可用 1取消 2已用 - + 敏感数据对应的云 ID,开通[云开发](https://developers.weixin.qq.com/minigame/dev/wxcloud/basis/getting-started.html)的小程序才会返回,可通过云调用直接获取开放数据,详细见[云调用直接获取开放数据](https://developers.weixin.qq.com/minigame/dev/guide/open-ability/signature.html#method-cloud) - + 包括敏感数据在内的完整转发信息的加密数据,详细见[加密数据解密算法](https://developers.weixin.qq.com/minigame/dev/guide/open-ability/signature.html) - + 错误信息 - + 加密算法的初始向量,详细见[加密数据解密算法](https://developers.weixin.qq.com/minigame/dev/guide/open-ability/signature.html) @@ -5705,6 +5999,21 @@ 实验参数数组,不填则获取所有实验参数 + + + 实验ID,标识实验 + + + + + 参数名称 + + + + + 参数值 + + 需要基础库: `3.7.8` @@ -5826,6 +6135,67 @@ 本机局域网子网掩码,基础库 2.24.0 开始支持 + + + 需要基础库: `1.6.0` + 传入 true 会返回高度信息,由于获取高度需要较高精确度,会减慢接口返回速度 + + + + + 需要基础库: `2.9.0` + 高精度定位超时时间(ms),指定时间内返回最高精度,该值3000ms以上高精度定位才有效果 + + + + + 需要基础库: `2.9.0` + 开启高精度定位 + + + + + wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标 + + + + + 位置的精确度,反应与真实位置之间的接近程度,可以理解成10即与真实位置相差10m,越小越精确 + + + + + 需要基础库: `1.2.0` + 高度,单位 m + + + + + 需要基础库: `1.2.0` + 水平精度,单位 m + + + + + 纬度,范围为 -90~90,负数表示南纬 + + + + + 经度,范围为 -180~180,负数表示西经 + + + + + 速度,单位 m/s + + + + + 需要基础库: `1.2.0` + 垂直精度,单位 m(Android 无法获取,返回 0) + + 需要基础库: `2.22.1` @@ -5941,6 +6311,17 @@ - itemSettings 只返回用户勾选过订阅面板中的“总是保持以上选择,不再询问”的订阅消息。 + + + shareTicket,详见[获取更多转发信息](#) + + + + + 需要基础库: `1.9.90` + 超时时间,单位 ms + + 封面广告组件展示状态码 @@ -6487,6 +6868,11 @@ 用短链打开小程序时当前页面携带的查询字符串。小程序中使用时,应在进入页面时调用 `wx.onCopyUrl` 自定义 `query`,退出页面时调用 `wx.offCopyUrl`,防止影响其它页面。 + + + 短链中的自定义标题,显示在小程序名称之后,可以不填 + + 当 手机坐标 X/Y 和 地球 X/Y 重合时,绕着 Z 轴转动的夹角为 alpha,范围值为 [0, 2*PI)。逆时针转动为正。 @@ -6510,6 +6896,21 @@ - 'landscapeReverse': 横屏反方向,以 HOME 键在屏幕左侧为反方向; + + + 当前直玩广告是否由于异常流程而结束(如 下拉/搜索 进入正在直玩广告流程中的游戏) + + + + + 当前是否处于直接广告中 + + + + + 当前是否处于蒙层阶段 + + 错误信息,包含堆栈 @@ -6905,7 +7306,7 @@ - 视频号 id + 视频号id(参考格式为:sphcqO59YEPCvoe;查看路径为:微信客户端->我tab->视频号->右上角.->视频号名字-视频号ID) @@ -7225,6 +7626,53 @@ 自定义维度,基础库 v2.14.0 开始支持可选 + + + 错误信息 + | 错误码 | 错误信息 | 说明 | + | - | - | - | + | 0 | 人脸识别成功 | | + | 2002004 | 人脸识别失败 | | + | 2002006 | 用户取消/超时/不同意,导致未完成人脸识别 | | + | 2002007 | 本用户7天内人脸识别已通过,通过日期为XX | | + | 2002008 | 本日已调起过人脸识别或者本月调用次数已达上限 | | + | 2002009 | 无权限发起人脸识别 | | + + + + + 错误码 + | 错误码 | 错误信息 | 说明 | + | - | - | - | + | 0 | 人脸识别成功 | | + | 2002004 | 人脸识别失败 | | + | 2002006 | 用户取消/超时/不同意,导致未完成人脸识别 | | + | 2002007 | 本用户7天内人脸识别已通过,通过日期为XX | | + | 2002008 | 本日已调起过人脸识别或者本月调用次数已达上限 | | + | 2002009 | 无权限发起人脸识别 | | + + + + + 人脸核身会话唯一标识(小程序后台根据「用户实名信息(姓名+身份证)」调用微信后台[getVerifyId](https://developers.weixin.qq.com/miniprogram/dev/server/API/face/api_getverifyid.html)接口获取) + + + + + 错误信息 + | 错误码 | 错误信息 | 说明 | + | - | - | - | + | 0 | 人脸识别完成(需要通过[queryVerifyInfo](https://developers.weixin.qq.com/miniprogram/dev/server/API/face/api_queryverifyinfo.html)接口查询人脸核身真实验证结果) | | + + + + + 错误码 + | 错误码 | 错误信息 | 说明 | + | - | - | - | + | 0 | 人脸识别完成(需要通过[queryVerifyInfo](https://developers.weixin.qq.com/miniprogram/dev/server/API/face/api_queryverifyinfo.html)接口查询人脸核身真实验证结果) | | + + 购买数量。mode=game 时必填。购买数量。详见 [buyQuantity 限制说明](#buyQuantity限制说明)。 @@ -7610,7 +8058,7 @@ - 自定义的登录态 + 自定义的登录态。上限 1024 字符。 diff --git a/Runtime/Plugins/wx-runtime-editor.xml.meta b/Runtime/Plugins/wx-runtime-editor.xml.meta index d26b0d0b9..03260d756 100644 --- a/Runtime/Plugins/wx-runtime-editor.xml.meta +++ b/Runtime/Plugins/wx-runtime-editor.xml.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 86cfe097f9cce0b88db9414b86df4ed1 +guid: 625380e1add3a3e297bf7ab65038a313 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/Plugins/wx-runtime.dll b/Runtime/Plugins/wx-runtime.dll index 102563c71..b0e3d01c8 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 1838a1584..65fae8683 100644 --- a/Runtime/Plugins/wx-runtime.xml +++ b/Runtime/Plugins/wx-runtime.xml @@ -4,12 +4,91 @@ wx-runtime - + - 覆盖unity的PlayerPrefs - 注意:调用均为同步调用, 容易阻塞游戏主线程造成卡顿,不建议频繁调用 + WX数据保护插件使用示例 + 演示如何使用数据保护功能来保护游戏中的重要数值 + + + 示例1:基础用法 - 存储和读取数据 + + + + + 示例2:安全获取数据(推荐方式) + + + + + 示例3:存储复杂对象 + + + + + 示例4:数据管理 + + + + + 数据篡改事件处理 + + + + + 处理数据篡改 + + + + + 示例:玩家属性数据结构 + 注意:使用 JsonUtility 序列化时,必须使用公共字段 + + + + + 游戏货币管理器示例 + 封装常用的货币操作,简化调用 + + + + + 初始化货币数据 + + + + + 获取金币数量 + + + + + 增加金币 + + + + + 消费金币 + + 是否消费成功 + + + + 获取钻石数量 + + + + + 增加钻石 + + + + + 消费钻石 + + 是否消费成功 + Banner 广告,详见 https://developers.weixin.qq.com/minigame/dev/guide/open-ability/ad/banner-ad.html @@ -3125,6 +3204,36 @@  是否结束 + + + 事件ID,开发者自行维护(必需) + + + + + 事件耗时,单位ms(可选)不填时为0 + + + + + 事件结果,默认成功(可选)不填时默认成功 + + + + + reportGameEvent的事件类型 + + + + + 成功事件 + + + + + 失败事件 + + 错误码,文档可见 https://developers.weixin.qq.com/minigame/dev/api/open-api/openlink/wx.createPageManager.html @@ -3301,7 +3410,7 @@ 需要基础库: `2.10.0` 小程序版本 可选值: - - 'develop': 开发版; + - 'develop': 开发版,提交代码审核时默认使用开发版进行审核。; - 'trial': 体验版; - 'release': 正式版; @@ -3377,6 +3486,11 @@ 允许微信读写日历的开关 + + + PC 内核版本号,仅在 PC 端存在该值 + + 客户端基础库版本 @@ -3479,6 +3593,14 @@ 客户端平台 + 可选值: + - 'ios': iOS微信(包含 iPhone、iPad); + - 'android': Android微信; + - 'ohos': HarmonyOS 手机端微信; + - 'ohos_pc': HarmonyOS PC微信; + - 'windows': Windows微信; + - 'mac': macOS微信; + - 'devtools': 微信开发者工具; @@ -3486,6 +3608,16 @@ 操作系统及版本 + + + 当前是否处于直接广告中 + + + + + 当前是否处于蒙层阶段 + + 需要基础库: `2.20.0` @@ -3552,6 +3684,11 @@ 直播间 id + + + 宿主传递的数据,第三方 app 中运行小游戏时返回 + + 启动小游戏的 query 参数 @@ -3582,6 +3719,11 @@ shareTicket,详见[获取更多转发信息](#) + + + 宿主app对应的场景值 + + 下边界坐标,单位:px @@ -3612,11 +3754,86 @@ 宽度,单位:px + + + 擂台赛组件领奖信息 + + 通知组件信息 + + + 福利组件信息 + + + + + 组件的名称 + + + + + 领取事件详情(只在onOfficialComponentsInfoChange回调中返回) + + + + + 奖励领取结果:1-全部成功, 2-部分成功(礼物达到领取上限), 3-领奖失败 + + + + + 是否收到了稀有奖励 + + + + + 用户领取的奖励列表 + + + + + 奖励类型:0-道具礼包, 1-微信蓝包, 2-h5商家券, 3-现金红包, 4-小程序券, 5-盲盒 + + + + + 奖励来源信息 + + + + + 获取的奖励数量 + + + + + 道具列表 + + + + + 奖励类型:1-普通奖励, 2-稀有奖励 + + + + + 礼包名称 + + + + + 道具名称 + + + + + 道具数量 + + 组件的布局位置信息 @@ -3632,6 +3849,46 @@ 组件的名称 + + + 可领取的好友礼包数量 + + + + + 可领取的礼包数量 + + + + + 组件的名称 + + + + + 领取事件详情(只在onOfficialComponentsInfoChange回调中返回) + + + + + 礼包描述,只有 gift 类型才有 + + + + + 礼包图标,只有 gift 类型才有 + + + + + 礼包名称,只有 gift 类型才有 + + + + + gift: 礼包, friendGift: 好友礼包 + + 当前占用的空间大小, 单位 KB @@ -3778,7 +4035,8 @@ 可选值: - 'ios': iOS微信(包含 iPhone、iPad); - 'android': Android微信; - - 'ohos': HarmonyOS微信; + - 'ohos': HarmonyOS 手机端微信; + - 'ohos_pc': HarmonyOS PC微信; - 'windows': Windows微信; - 'mac': macOS微信; - 'devtools': 微信开发者工具; @@ -4433,6 +4691,36 @@ 是否被添加至 「我的小程序」 + + + 错误信息 + + + + + 支付支持信息对象 + + + + + 调用结果信息,格式为 "checkIsSupportMidasPayment:ok" + + + + + 是否支持支付,true 表示支持,false 表示不支持 + + + + + 错误码,0 表示成功 + + + + + 错误信息,"success" 表示成功 + + 最多可以选择的图片张数 @@ -5601,22 +5889,22 @@ 预告状态:0可用 1取消 2已用 - + 敏感数据对应的云 ID,开通[云开发](https://developers.weixin.qq.com/minigame/dev/wxcloud/basis/getting-started.html)的小程序才会返回,可通过云调用直接获取开放数据,详细见[云调用直接获取开放数据](https://developers.weixin.qq.com/minigame/dev/guide/open-ability/signature.html#method-cloud) - + 包括敏感数据在内的完整转发信息的加密数据,详细见[加密数据解密算法](https://developers.weixin.qq.com/minigame/dev/guide/open-ability/signature.html) - + 错误信息 - + 加密算法的初始向量,详细见[加密数据解密算法](https://developers.weixin.qq.com/minigame/dev/guide/open-ability/signature.html) @@ -5711,6 +5999,21 @@ 实验参数数组,不填则获取所有实验参数 + + + 实验ID,标识实验 + + + + + 参数名称 + + + + + 参数值 + + 需要基础库: `3.7.8` @@ -5832,6 +6135,67 @@ 本机局域网子网掩码,基础库 2.24.0 开始支持 + + + 需要基础库: `1.6.0` + 传入 true 会返回高度信息,由于获取高度需要较高精确度,会减慢接口返回速度 + + + + + 需要基础库: `2.9.0` + 高精度定位超时时间(ms),指定时间内返回最高精度,该值3000ms以上高精度定位才有效果 + + + + + 需要基础库: `2.9.0` + 开启高精度定位 + + + + + wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标 + + + + + 位置的精确度,反应与真实位置之间的接近程度,可以理解成10即与真实位置相差10m,越小越精确 + + + + + 需要基础库: `1.2.0` + 高度,单位 m + + + + + 需要基础库: `1.2.0` + 水平精度,单位 m + + + + + 纬度,范围为 -90~90,负数表示南纬 + + + + + 经度,范围为 -180~180,负数表示西经 + + + + + 速度,单位 m/s + + + + + 需要基础库: `1.2.0` + 垂直精度,单位 m(Android 无法获取,返回 0) + + 需要基础库: `2.22.1` @@ -5947,6 +6311,17 @@ - itemSettings 只返回用户勾选过订阅面板中的“总是保持以上选择,不再询问”的订阅消息。 + + + shareTicket,详见[获取更多转发信息](#) + + + + + 需要基础库: `1.9.90` + 超时时间,单位 ms + + 封面广告组件展示状态码 @@ -6493,6 +6868,11 @@ 用短链打开小程序时当前页面携带的查询字符串。小程序中使用时,应在进入页面时调用 `wx.onCopyUrl` 自定义 `query`,退出页面时调用 `wx.offCopyUrl`,防止影响其它页面。 + + + 短链中的自定义标题,显示在小程序名称之后,可以不填 + + 当 手机坐标 X/Y 和 地球 X/Y 重合时,绕着 Z 轴转动的夹角为 alpha,范围值为 [0, 2*PI)。逆时针转动为正。 @@ -6516,6 +6896,21 @@ - 'landscapeReverse': 横屏反方向,以 HOME 键在屏幕左侧为反方向; + + + 当前直玩广告是否由于异常流程而结束(如 下拉/搜索 进入正在直玩广告流程中的游戏) + + + + + 当前是否处于直接广告中 + + + + + 当前是否处于蒙层阶段 + + 错误信息,包含堆栈 @@ -6911,7 +7306,7 @@ - 视频号 id + 视频号id(参考格式为:sphcqO59YEPCvoe;查看路径为:微信客户端->我tab->视频号->右上角.->视频号名字-视频号ID) @@ -7231,6 +7626,53 @@ 自定义维度,基础库 v2.14.0 开始支持可选 + + + 错误信息 + | 错误码 | 错误信息 | 说明 | + | - | - | - | + | 0 | 人脸识别成功 | | + | 2002004 | 人脸识别失败 | | + | 2002006 | 用户取消/超时/不同意,导致未完成人脸识别 | | + | 2002007 | 本用户7天内人脸识别已通过,通过日期为XX | | + | 2002008 | 本日已调起过人脸识别或者本月调用次数已达上限 | | + | 2002009 | 无权限发起人脸识别 | | + + + + + 错误码 + | 错误码 | 错误信息 | 说明 | + | - | - | - | + | 0 | 人脸识别成功 | | + | 2002004 | 人脸识别失败 | | + | 2002006 | 用户取消/超时/不同意,导致未完成人脸识别 | | + | 2002007 | 本用户7天内人脸识别已通过,通过日期为XX | | + | 2002008 | 本日已调起过人脸识别或者本月调用次数已达上限 | | + | 2002009 | 无权限发起人脸识别 | | + + + + + 人脸核身会话唯一标识(小程序后台根据「用户实名信息(姓名+身份证)」调用微信后台[getVerifyId](https://developers.weixin.qq.com/miniprogram/dev/server/API/face/api_getverifyid.html)接口获取) + + + + + 错误信息 + | 错误码 | 错误信息 | 说明 | + | - | - | - | + | 0 | 人脸识别完成(需要通过[queryVerifyInfo](https://developers.weixin.qq.com/miniprogram/dev/server/API/face/api_queryverifyinfo.html)接口查询人脸核身真实验证结果) | | + + + + + 错误码 + | 错误码 | 错误信息 | 说明 | + | - | - | - | + | 0 | 人脸识别完成(需要通过[queryVerifyInfo](https://developers.weixin.qq.com/miniprogram/dev/server/API/face/api_queryverifyinfo.html)接口查询人脸核身真实验证结果) | | + + 购买数量。mode=game 时必填。购买数量。详见 [buyQuantity 限制说明](#buyQuantity限制说明)。 @@ -7616,7 +8058,7 @@ - 自定义的登录态 + 自定义的登录态。上限 1024 字符。 @@ -9125,5 +9567,11 @@ 注册监听录制事件的回调函数。当对应事件触发时,回调函数会被执行 + + + 覆盖unity的PlayerPrefs + 注意:调用均为同步调用, 容易阻塞游戏主线程造成卡顿,不建议频繁调用 + + diff --git a/Runtime/Plugins/wx-runtime.xml.meta b/Runtime/Plugins/wx-runtime.xml.meta index abf9e048d..160824a6e 100644 --- a/Runtime/Plugins/wx-runtime.xml.meta +++ b/Runtime/Plugins/wx-runtime.xml.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 9a7c16358edeccc9e6507105d15b2cd3 +guid: 3166ccff8d439341f110770c595609f8 DefaultImporter: externalObjects: {} userData: diff --git a/Runtime/WX.cs b/Runtime/WX.cs index 0049afc2d..6f6c03762 100644 --- a/Runtime/WX.cs +++ b/Runtime/WX.cs @@ -107,6 +107,69 @@ namespace WeChatWASM WXSDKManagerHandler.Instance.CheckIsAddedToMyMiniProgram(callback); } + /// + /// [wx.checkIsSupportFacialRecognition(Object object)](https://developers.weixin.qq.com/minigame/dev/api/open-api/face/wx.checkIsSupportFacialRecognition.html) + /// 需要基础库: `3.8.12` + /// 检查当前设备是否支持人脸识别能力 + /// **示例代码** + /// ```js + /// wx.checkIsSupportFacialRecognition({ + /// success() { + /// // 支持人脸识别 + /// }, + /// fail() { + /// // 不支持人脸识别 + /// }, + /// }) + /// ``` + /// + public static void CheckIsSupportFacialRecognition(CheckIsSupportFacialRecognitionOption callback) + { + WXSDKManagerHandler.Instance.CheckIsSupportFacialRecognition(callback); + } + + /// + /// [wx.checkIsSupportMidasPayment(Object object)](https://developers.weixin.qq.com/minigame/dev/api/midas-payment/wx.checkIsSupportMidasPayment.html) + /// 需要基础库: `3.10.3` + /// 检查当前环境是否支持虚拟支付。使用前请注意阅读[相关说明](https://developers.weixin.qq.com/minigame/dev/guide/open-ability/virtual-payment/virtual-payment2.html)。 + /// **平台支持说明** + /// - Android、Windows、OHOS 平台:默认支持虚拟支付,接口直接返回支持 + /// - iOS 平台:需满足以下环境要求才可能支持虚拟支付 + /// - 操作系统要求:使用 iPhone 或者 iPad,iOS 15 及以上版本 + /// - 基础库版本要求:3.10.3 及以上 + /// - 客户端版本要求:8.0.68 及以上 + /// - 苹果支付不支持使用沙箱环境,仅支持使用现网环境 + /// **注意事项** + /// 若该 API 都不存在,则 iOS 一定不支持虚拟支付,请保持旧版本逻辑。 + /// **示例代码** + /// ```js + /// if (wx.checkIsSupportMidasPayment) { + /// wx.checkIsSupportMidasPayment({ + /// success(res) { + /// console.log('支持检查结果:', res) + /// if (res.data.allow_pay) { + /// console.log('当前环境支持支付') + /// // 可以继续调用支付相关接口 + /// } else { + /// console.log('当前环境不支持支付') + /// // 请自行适配用户提示文案 + /// } + /// }, + /// fail(err) { + /// console.error('检查支持情况失败:', err) + /// }, + /// complete() { + /// console.log('检查完成') + /// } + /// }) + /// } + /// ``` + /// + public static void CheckIsSupportMidasPayment(CheckIsSupportMidasPaymentOption callback) + { + WXSDKManagerHandler.Instance.CheckIsSupportMidasPayment(callback); + } + /// /// [wx.checkSession(Object object)](https://developers.weixin.qq.com/minigame/dev/api/open-api/login/wx.checkSession.html) /// 检查登录态 session_key 是否过期。 @@ -279,7 +342,7 @@ namespace WeChatWASM /// /// [wx.exitChatTool(Object object)](https://developers.weixin.qq.com/minigame/dev/api/chattool/wx.exitChatTool.html) /// 需要基础库: `3.7.12` - /// 退出聊天工具模式 + /// 退出聊天工具开放能力模式 /// public static void ExitChatTool(ExitChatToolOption callback) { @@ -675,6 +738,7 @@ namespace WeChatWASM /// | 8 | 当天(自然日)赞官方贴子数 | 无需传入 | | /// | 9 | 当天(自然日)评论官方贴子数 | 无需传入 | | /// | 10 | 当天(自然日)发表到本圈子话题的贴子数 | 传入话题id,从mp-游戏圈话题管理处获取 | | + /// | 11 | 用户最近一次推荐游戏时间 | 无需传入 | 秒级时间戳 | | /// **encryptedData 解密后得到的 GameClubData 的结构** /// | 属性 | 类型 | 说明 | /// | ------- | ------- | -------------------------------------- | @@ -691,9 +755,22 @@ namespace WeChatWASM } /// - /// [wx.getGameExptInfo(Object object)](https://developers.weixin.qq.com/minigame/dev/api/data-analysis/wx.getGameExptInfo.html) + /// [wx.getGameExptInfo(Object options)](https://developers.weixin.qq.com/minigame/dev/api/data-analysis/wx.getGameExptInfo.html) /// 需要基础库: `3.8.8` /// 给定实验参数数组,获取对应的实验参数值 + /// **示例代码** + /// ```js + /// wx.getGameExptInfo({ + /// keyList: ['experiment_key1', 'experiment_key2'], + /// success(res) { + /// res.list.forEach((expParam) => { + /// console.log('实验ID:', expParam.expt_id); + /// console.log('参数名:', expParam.param_name); + /// console.log('参数值:', expParam.param_value); + /// }) + /// } + /// }); + /// ``` /// public static void GetGameExptInfo(GetGameExptInfoOption callback) { @@ -790,6 +867,14 @@ namespace WeChatWASM WXSDKManagerHandler.Instance.GetLocalIPAddress(callback); } + /// + /// [wx.getLocation(Object object)](https://developers.weixin.qq.com/minigame/dev/api/location/wx.getLocation.html) + /// + public static void GetLocation(GetLocationOption callback) + { + WXSDKManagerHandler.Instance.GetLocation(callback); + } + /// /// [wx.getNetworkType(Object object)](https://developers.weixin.qq.com/minigame/dev/api/device/network/wx.getNetworkType.html) /// 获取网络类型 @@ -916,6 +1001,15 @@ namespace WeChatWASM WXSDKManagerHandler.Instance.GetSetting(callback); } + /// + /// [wx.getShareInfo(Object object)](https://developers.weixin.qq.com/minigame/dev/api/share/wx.getShareInfo.html) + /// 需要基础库: `1.1.0` + /// + public static void GetShareInfo(GetShareInfoOption callback) + { + WXSDKManagerHandler.Instance.GetShareInfo(callback); + } + /// /// [wx.getShowSplashAdStatus(Object object)](https://developers.weixin.qq.com/minigame/dev/api/ad/wx.getShowSplashAdStatus.html) /// 需要基础库: `3.7.8` @@ -1262,9 +1356,6 @@ namespace WeChatWASM /// 从 2.3.0 版本开始,若用户未点击小程序页面任意位置,则开发者将无法调用此接口自动跳转至其他小程序。 /// ##### 需要用户确认跳转 /// 从 2.3.0 版本开始,在跳转至其他小程序前,将统一增加弹窗,询问是否跳转,用户确认后才可以跳转其他小程序。如果用户点击取消,则回调 `fail cancel`。 - /// ##### 无需声明跳转名单,不限跳转数量(众测中) - /// 1. 从2020年4月24日起,使用跳转其他小程序功能将无需在全局配置中声明跳转名单,调用此接口时将不再校验所跳转的 AppID 是否在 navigateToMiniProgramAppIdList 中。 - /// 2. 从2020年4月24日起,跳转其他小程序将不再受数量限制,使用此功能时请注意遵守运营规范。 /// **运营规范** /// 平台将坚决打击小程序盒子等互推行为,使用此功能时请严格遵守[《微信小程序平台运营规范》](https://developers.weixin.qq.com/miniprogram/product/#_5-10-%E4%BA%92%E6%8E%A8%E8%A1%8C%E4%B8%BA),若发现小程序违反运营规范将被下架处理。 /// **关于调试** @@ -1700,6 +1791,125 @@ namespace WeChatWASM WXSDKManagerHandler.Instance.ReportScene(callback); } + /// + /// [wx.requestFacialRecognition(Object object)](https://developers.weixin.qq.com/minigame/dev/api/open-api/account-info/wx.requestFacialRecognition.html) + /// 需要基础库: `3.11.2` + /// 腾讯游戏人脸识别验证功能是基于健康系统防沉迷体系,用于识别疑似未成年人冒用成年人账号游玩游戏的行为,是防止未成年人沉迷网络游戏的一项重要措施。本接口是为开通虚拟支付功能的小游戏开发者提供的,此接口是基于人脸识别的未成年人身份核验接口。本次识别是根据用户在腾讯健康系统中留存的实名信息进行验证,结果将直接返回至开发者。 + /// **接口限额** + /// - 超出限额后将返回错误码 2002008(频率控制) + /// - 1天内全部游戏对一个用户只能调起1次人脸识别 + /// - 若用户人脸识别通过:7天内不能再被弹出人脸识别 + /// - 根据小游戏评级每个月限制使用次数,一旦发现恶意滥用接口,会取消使用资格。具体使用次数如下: + /// - S级:300次/月 + /// - A级:100次/月 + /// - B级:30次/月 + /// **处理流程** + /// 人脸识别流程图 + /// **示例代码** + /// ```js + /// // 实际业务场景:防沉迷身份验证 + /// function checkUserIdentity() { + /// wx.requestFacialRecognition({ + /// success(res) { + /// // 场景 1:本次人脸识别通过 + /// // res = { errCode: 0, errMsg: 'ok' } + /// console.log('人脸识别成功:', res) + /// // 允许继续游戏 + /// startGame() + /// }, + /// fail(err) { + /// console.error('人脸识别失败:', err) + /// let tipMessage = '' + /// let shouldBlock = false // 是否需要阻断游戏 + /// // 根据错误码进行不同处理 + /// switch (err.errCode) { + /// case 2002004: + /// // 人脸识别失败(需要阻断) + /// // err = { errCode: 2002004, errMsg: '人脸识别失败' } + /// tipMessage = '识别失败,请稍后重试' + /// shouldBlock = true + /// break + /// case 2002006: + /// // 用户取消/超时/不同意,导致未完成人脸识别(需要阻断) + /// // err = { errCode: 2002006, errMsg: '用户取消' } + /// tipMessage = '您已取消验证,无法继续游戏' + /// shouldBlock = true + /// break + /// case 2002007: + /// // 本用户7天内人脸识别已通过(可以继续游戏) + /// // err = { errCode: 2002007, errMsg: '本用户7天内人脸识别已通过,通过日期为2024-01-15' } + /// tipMessage = '您已完成验证' + /// shouldBlock = false + /// break + /// case 2002008: + /// // 频率控制:本日已调起过人脸识别 or 本月调用次数已达上限(可以继续游戏) + /// // err = { errCode: 2002008, errMsg: '本日已调起过人脸识别' } + /// // 或 err = { errCode: 2002008, errMsg: '本月调用次数已达上限' } + /// tipMessage = '今日验证次数已达上限' + /// shouldBlock = false + /// break + /// case 2002009: + /// // 无权限发起人脸识别(可以继续游戏) + /// // err = { errCode: 2002009, errMsg: '无权限发起人脸识别' } + /// tipMessage = '暂无权限使用此功能' + /// shouldBlock = false + /// break + /// default: + /// // 系统异常等其他错误(可以继续游戏,避免影响正常用户) + /// tipMessage = '系统异常,请稍后重试' + /// shouldBlock = false + /// } + /// if (tipMessage) { + /// wx.showModal({ + /// title: '提示', + /// content: tipMessage, + /// showCancel: false + /// }) + /// } + /// if (shouldBlock) { + /// // 仅对识别失败(2002004)和用户取消(2002006)阻断游戏 + /// restrictGameFeatures() + /// } else { + /// // 其他情况允许继续游戏 + /// startGame() + /// } + /// }, + /// complete(res) { + /// // 无论成功失败均会触发 + /// console.log('人脸识别流程结束:', res) + /// } + /// }) + /// } + /// ``` + /// + public static void RequestFacialRecognition(RequestFacialRecognitionOption callback) + { + WXSDKManagerHandler.Instance.RequestFacialRecognition(callback); + } + + /// + /// [wx.requestFacialVerify(Object object)](https://developers.weixin.qq.com/minigame/dev/api/open-api/face/wx.requestFacialVerify.html) + /// 需要基础库: `3.8.12` + /// 对用户实名信息进行基于生物识别的人脸核身验证 + /// **示例代码** + /// ```js + /// wx.requestFacialVerify({ + /// // 人脸核身会话唯一标识 + /// verifyId: 'xxx', + /// success() { + /// // 人脸核身验证成功,需要通知小程序后台根据本次人脸核身会话唯一标识 verifyId 字段调用微信后台 queryVerifyInfo 接口查询人脸核身真实验证结果。 + /// }, + /// fail() { + /// // 人脸核身验证失败 + /// }, + /// }) + /// ``` + /// + public static void RequestFacialVerify(RequestFacialVerifyOption callback) + { + WXSDKManagerHandler.Instance.RequestFacialVerify(callback); + } + /// /// [wx.requestMidasFriendPayment(Object object)](https://developers.weixin.qq.com/minigame/dev/api/midas-payment/wx.requestMidasFriendPayment.html) /// 需要基础库: `2.11.0` @@ -2043,6 +2253,8 @@ namespace WeChatWASM /// [wx.setDeviceOrientation(Object object)](https://developers.weixin.qq.com/minigame/dev/api/device/orientation/wx.setDeviceOrientation.html) /// 需要基础库: `2.26.0` /// 切换横竖屏。接口调用成功后会触发 wx.onDeviceOrientationChange 事件 + /// **注意** + /// - PC小程序处于全屏时,无法切换横竖屏。 /// public static void SetDeviceOrientation(SetDeviceOrientationOption callback) { @@ -2763,6 +2975,15 @@ namespace WeChatWASM WXSDKManagerHandler.Instance.ReportEvent(eventId, data); } + /// + /// [wx.reportMonitor(string name, number value)](https://developers.weixin.qq.com/minigame/dev/api/data-analysis/wx.reportMonitor.html) + /// 需要基础库: `2.1.2` + /// + public static void ReportMonitor(string name, double value) + { + WXSDKManagerHandler.Instance.ReportMonitor(name, value); + } + /// /// [wx.reportPerformance(Number id, Number value, String|Array dimensions)](https://developers.weixin.qq.com/minigame/dev/api/base/performance/wx.reportPerformance.html) /// 需要基础库: `2.10.0` @@ -3027,6 +3248,7 @@ namespace WeChatWASM /// 监听搜索到新设备的事件 /// **注意** /// - 若在 [wx.onBluetoothDeviceFound](https://developers.weixin.qq.com/minigame/dev/api/device/bluetooth/wx.onBluetoothDeviceFound.html) 回调了某个设备,则此设备会添加到 [wx.getBluetoothDevices](https://developers.weixin.qq.com/minigame/dev/api/device/bluetooth/wx.getBluetoothDevices.html) 接口获取到的数组中。 + /// - 地址变化这个是鸿蒙系统特性,小程序可以不缓存地址,重新搜索连接。 /// **示例代码** /// [在微信开发者工具中查看示例](https://developers.weixin.qq.com/s/pQU51zmz7a3K) /// ```js @@ -3121,6 +3343,34 @@ namespace WeChatWASM WXSDKManagerHandler.Instance.OffDeviceOrientationChange(result); } + /// + /// [wx.onDirectAdStatusChange(function listener)](https://developers.weixin.qq.com/minigame/dev/api/ad/wx.onDirectAdStatusChange.html) + /// 需要基础库: `3.11.2` + /// 监听监听直玩广告状态变化 + /// **示例代码** + /// ```js + /// wx.onDirectAdStatusChange(res => { + /// // 会有如下的几种状态值组合 + /// // a) { isInMask: true, isInDirectGameAd: true } -> 表示当前正在直玩广告 且 未戳破蒙层 + /// // b) { isInMask: false, isInDirectGameAd: true } -> 表示当前正在直玩广告 且 戳破了蒙层 + /// // c) { isInMask: false, isInDirectGameAd: false, isEndByAbnormal: false }, -> 表示倒计时结束了,并且选择了继续玩 + /// // d) { isInMask: false, isInDirectGameAd: false, isEndByAbnormal: true }, -> 表示由于异常流程而结束 + /// console.log(res.isInMask) + /// console.log(res.isInDirectGameAd) + /// console.log(res.isEndByAbnormal) + /// }) + /// ``` + /// + public static void OnDirectAdStatusChange(Action result) + { + WXSDKManagerHandler.Instance.OnDirectAdStatusChange(result); + } + + public static void OffDirectAdStatusChange(Action result) + { + WXSDKManagerHandler.Instance.OffDirectAdStatusChange(result); + } + /// /// [wx.onError(function listener)](https://developers.weixin.qq.com/minigame/dev/api/base/app/app-event/wx.onError.html) /// 监听全局错误事件 @@ -3495,21 +3745,21 @@ namespace WeChatWASM /// 需要基础库: `2.8.1` /// 监听用户主动截屏事件。用户使用系统截屏按键截屏时触发,只能注册一个监听 /// **示例代码** + /// 页面要先调用wx.showShareMenu()来允许调用 /// ```js /// wx.onUserCaptureScreen(function (res) { /// console.log('用户截屏了') /// return { /// query: "parameter=test", // 通过截屏图片打开小程序的query参数 /// promise: new Promise((resolve) => { // 通过promise延时传递小程序的query参数 - /// setTimeout(() => { - /// resolve({ - /// query: "parameter=test2", - /// }) - /// }, 1000) // 在1秒内对query进行解析 - /// }) + /// setTimeout(() => { + /// resolve({ + /// query: "parameter=test2", + /// }) + /// }, 1000) // 在1秒内对query进行解析 + /// }) /// } - /// } - /// ) + /// }) /// ``` /// public static void OnUserCaptureScreen(Action result) @@ -3643,7 +3893,7 @@ namespace WeChatWASM /// /// [wx.onCopyUrl(function listener)](https://developers.weixin.qq.com/minigame/dev/api/share/wx.onCopyUrl.html) /// 需要基础库: `2.14.3` - /// 监听用户点击右上角菜单的「复制链接」按钮时触发的事件。本接口为 Beta 版本,暂只在 Android 平台支持。 + /// 监听用户点击右上角菜单的「复制链接」按钮时触发的事件。 /// public static void OnCopyUrl(Action> callback) { @@ -3831,6 +4081,23 @@ namespace WeChatWASM return WXSDKManagerHandler.GetDeviceInfo(); } + /// + /// [Object wx.getDirectAdStatusSync()](https://developers.weixin.qq.com/minigame/dev/api/ad/wx.getDirectAdStatusSync.html) + /// 需要基础库: `3.11.2` + /// 获取直玩广告组件展示状态。 + /// **示例代码** + /// ```js + /// const statusInfo = wx.getDirectAdStatusSync(); + /// console.log(statusInfo.isInMask) // 当前是否在蒙层阶段 + /// console.log(statusInfo.isInDirectGameAd) // 当前是否在直玩广告中 + /// ``` + /// + /// + public static DirectAdStatusInfo GetDirectAdStatusSync() + { + return WXSDKManagerHandler.GetDirectAdStatusSync(); + } + /// /// [Object wx.getEnterOptionsSync()](https://developers.weixin.qq.com/minigame/dev/api/base/app/life-cycle/wx.getEnterOptionsSync.html) /// 需要基础库: `2.13.2` @@ -4045,19 +4312,19 @@ namespace WeChatWASM } /// - /// [[ImageData](https://developers.weixin.qq.com/minigame/dev/api/render/image/ImageData.html) wx.createImageData(number width, number height)](https://developers.weixin.qq.com/minigame/dev/api/render/image/wx.createImageData.html) + /// [[ImageData](https://developers.weixin.qq.com/minigame/dev/api/render/image/ImageData.html) wx.createImageData(number width, number height, Uint8ClampedArray data)](https://developers.weixin.qq.com/minigame/dev/api/render/image/wx.createImageData.html) /// 需要基础库: `3.4.10` - /// 这里有两种使用方法, 一种是指定ImageData的宽和高, 另外一种是使用ImageData, 通过它本身的宽高尺寸来构建新的对象。 + /// 这里有两种使用方法, 一种是指定ImageData的宽和高, 另外一种使用已有的ImageData的图像二进制数据,来构建新的对象。 /// **示例代码** /// ```js - /// const imageData1 = wx.createImageData(100, 100) - /// const imageData2 = wx.createImageData(imageData1) + /// const imageData1 = wx.createImageData(100, 100) + /// const imageData2 = wx.createImageData(imageData1.data, 100, 100) /// ``` /// /// - public static ImageData CreateImageData(double width, double height) + public static ImageData CreateImageData(double width, double height, int[] data) { - return WXSDKManagerHandler.CreateImageData(width, height); + return WXSDKManagerHandler.CreateImageData(width, height, data); } /// diff --git a/Runtime/WXBase.cs b/Runtime/WXBase.cs index fed9ae2b8..7f7718edd 100644 --- a/Runtime/WXBase.cs +++ b/Runtime/WXBase.cs @@ -1136,6 +1136,14 @@ namespace WeChatWASM { WXSDKManagerHandler.Instance.NotifyMiniProgramPlayableStatus(option); } + /// + /// 上报自定义打点数据 + /// + /// + public static void ReportGameEvent(ReportGameEventOption option) + { + WXSDKManagerHandler.Instance.ReportGameEvent(option); + } #endregion #region 虚拟支付 /// diff --git a/Runtime/WXTouchInputModule.cs b/Runtime/WXTouchInputModule.cs new file mode 100644 index 000000000..a685c29bc --- /dev/null +++ b/Runtime/WXTouchInputModule.cs @@ -0,0 +1,186 @@ +#if UNITY_WEBGL || WEIXINMINIGAME || UNITY_EDITOR +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.EventSystems; +using UnityEngine.UI; + +/** + * WxTouch输入模块,结合 WXTouchInputOverride 使用 + * 用于拦截所有Button事件调用,确保事件只被触发一次,避免重复触发问题 + * 除会拦截带 Button 组件的 ExecuteEvents.pointerClickHandler 事件外,逻辑与 StandaloneInputModule 均一致 + * 需要在场景中添加 WXTouchInputOverride 组件使用,且保证不要有其他的 StandaloneInputModule + */ +public class WXTouchInputModule : StandaloneInputModule +{ + private const float doubleClickTime = 0.3f; + + public override void Process() + { + if (!eventSystem.isFocused && ShouldIgnoreEventsOnNoFocus()) + return; + bool usedEvent = SendUpdateEventToSelectedObject(); + if (!ProcessTouchEvents() && input.mousePresent) + ProcessMouseEvent(); + if (eventSystem.sendNavigationEvents) + { + if (!usedEvent) + usedEvent |= SendMoveEventToSelectedObject(); + + if (!usedEvent) + SendSubmitEventToSelectedObject(); + } + } + + private bool ShouldIgnoreEventsOnNoFocus() + { +#if UNITY_EDITOR + return !UnityEditor.EditorApplication.isRemoteConnected; +#else + return true; +#endif + } + + private bool ProcessTouchEvents() + { + for (int i = 0; i < input.touchCount; ++i) + { + Touch touch = input.GetTouch(i); + if (touch.type == TouchType.Indirect) + continue; + + bool released; + bool pressed; + var pointer = GetTouchPointerEventData(touch, out pressed, out released); + + ProcessTouchPress(pointer, pressed, released); + + if (!released) + { + ProcessMove(pointer); + ProcessDrag(pointer); + } + else + RemovePointerData(pointer); + } + return input.touchCount > 0; + } + + // released 后会拦截 Button 的 ExecuteEvents.pointerClickHandler ,其余逻辑与 StandaloneInputModule 保持一致 + protected new void ProcessTouchPress(PointerEventData pointerEvent, bool pressed, bool released) + { + var currentOverGo = pointerEvent.pointerCurrentRaycast.gameObject; + + // PointerDown notification + if (pressed) + { + pointerEvent.eligibleForClick = true; + pointerEvent.delta = Vector2.zero; + pointerEvent.dragging = false; + pointerEvent.useDragThreshold = true; + pointerEvent.pressPosition = pointerEvent.position; + pointerEvent.pointerPressRaycast = pointerEvent.pointerCurrentRaycast; + + DeselectIfSelectionChanged(currentOverGo, pointerEvent); + + if (pointerEvent.pointerEnter != currentOverGo) + { + // send a pointer enter to the touched element if it isn't the one to select... + HandlePointerExitAndEnter(pointerEvent, currentOverGo); + pointerEvent.pointerEnter = currentOverGo; + } + + var resetDiffTime = Time.unscaledTime - pointerEvent.clickTime; + if (resetDiffTime >= doubleClickTime) + { + pointerEvent.clickCount = 0; + } + + // search for the control that will receive the press + // if we can't find a press handler set the press + // handler to be what would receive a click. + var newPressed = ExecuteEvents.ExecuteHierarchy(currentOverGo, pointerEvent, ExecuteEvents.pointerDownHandler); + + var newClick = ExecuteEvents.GetEventHandler(currentOverGo); + + // didnt find a press handler... search for a click handler + if (newPressed == null) + newPressed = newClick; + + // Debug.Log("Pressed: " + newPressed); + + float time = Time.unscaledTime; + + if (newPressed == pointerEvent.lastPress) + { + var diffTime = time - pointerEvent.clickTime; + if (diffTime < doubleClickTime) + ++pointerEvent.clickCount; + else + pointerEvent.clickCount = 1; + + pointerEvent.clickTime = time; + } + else + { + pointerEvent.clickCount = 1; + } + + pointerEvent.pointerPress = newPressed; + pointerEvent.rawPointerPress = currentOverGo; + pointerEvent.pointerClick = newClick; + + pointerEvent.clickTime = time; + + // Save the drag handler as well + pointerEvent.pointerDrag = ExecuteEvents.GetEventHandler(currentOverGo); + + if (pointerEvent.pointerDrag != null) + ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.initializePotentialDrag); + } + + // PointerUp notification + if (released) + { + // Debug.Log("Executing pressup on: " + pointer.pointerPress); + ExecuteEvents.Execute(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerUpHandler); + // Debug.Log("KeyCode: " + pointer.eventData.keyCode); + + // see if we mouse up on the same element that we clicked on... + var pointerClickHandler = ExecuteEvents.GetEventHandler(currentOverGo); + + // PointerClick and Drop events + if (pointerEvent.pointerClick == pointerClickHandler && pointerEvent.eligibleForClick) + { + bool shouldHandleInWx = currentOverGo != null && currentOverGo.GetComponentInParent() != null; + if (!shouldHandleInWx) + { + ExecuteEvents.Execute(pointerEvent.pointerClick, pointerEvent, ExecuteEvents.pointerClickHandler); + } + } + + if (pointerEvent.pointerDrag != null && pointerEvent.dragging) + { + ExecuteEvents.ExecuteHierarchy(currentOverGo, pointerEvent, ExecuteEvents.dropHandler); + } + + pointerEvent.eligibleForClick = false; + pointerEvent.pointerPress = null; + pointerEvent.rawPointerPress = null; + pointerEvent.pointerClick = null; + + if (pointerEvent.pointerDrag != null && pointerEvent.dragging) + ExecuteEvents.Execute(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.endDragHandler); + + pointerEvent.dragging = false; + pointerEvent.pointerDrag = null; + + // send exit events as we need to simulate this on touch up on touch device + ExecuteEvents.ExecuteHierarchy(pointerEvent.pointerEnter, pointerEvent, ExecuteEvents.pointerExitHandler); + pointerEvent.pointerEnter = null; + } + + //m_InputPointerEvent = pointerEvent; + } +} +#endif \ No newline at end of file diff --git a/Runtime/WXTouchInputModule.cs.meta b/Runtime/WXTouchInputModule.cs.meta new file mode 100644 index 000000000..ffc1c36c7 --- /dev/null +++ b/Runtime/WXTouchInputModule.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6226ce8c6cf3dd24d95cfa430c9755d3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/WXTouchInputOverride.cs b/Runtime/WXTouchInputOverride.cs index 82a963b51..831f7a540 100644 --- a/Runtime/WXTouchInputOverride.cs +++ b/Runtime/WXTouchInputOverride.cs @@ -21,17 +21,17 @@ internal class TouchData * 所以需要使用WX的触控接口重新覆盖Unity的BaseInput关于触控方面的接口 * 通过设置StandaloneInputModule.inputOverride的方式来实现 */ -[RequireComponent(typeof(StandaloneInputModule))] +[RequireComponent(typeof(WXTouchInputModule))] public class WXTouchInputOverride : BaseInput { private bool _isInitWechatSDK; private readonly List _touches = new List(); - private StandaloneInputModule _standaloneInputModule = null; + private WXTouchInputModule _standaloneInputModule = null; protected override void Awake() { base.Awake(); - _standaloneInputModule = GetComponent(); + _standaloneInputModule = GetComponent(); } protected override void OnEnable() @@ -138,11 +138,16 @@ public class WXTouchInputOverride : BaseInput Button button = selectedObject.GetComponent