Auto-publish.

This commit is contained in:
nebulaliu 2025-07-30 16:21:25 +08:00
parent c0f72c902b
commit 764289f9c7
266 changed files with 11497 additions and 1171 deletions

8
Editor/BuildProfile.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: DytLvSj8UC9CKob0XUy9Y3usKDmX8US1YgxYmBxa1iAZ/I8JbM5wZwE=
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: XSwesi78AS28ymfR2HEhHpEBAC2DHupI1hIKP7HApjHRaZgGw+DTwWI=
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c113acfee35db6b5c61fd4a76596cfd3
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,43 @@
mergeInto(LibraryManager.library, {
// 定义供 C/C++ 调用的 JS 函数
js_batchRender_malloc: function(data, size, isSync) {
// 直接从 WASM 内存创建视图(零拷贝)
const binaryData = new Uint8Array(Module.HEAPU8.buffer, data, size);
// 转换为标准 ArrayBuffer如果需要复制
const targetBuffer =
binaryData.buffer.slice(binaryData.byteOffset, binaryData.byteOffset + binaryData.byteLength);
//console.log("processBinaryData invoke");
const extBuffer = new ArrayBuffer(1);
const headerBuffer = new ArrayBuffer(8);
const headerBufferView = new DataView(headerBuffer);
headerBufferView.setUint32(0, 0xDEC0DE, true);
headerBufferView.setUint32(4, mtl.ctx.__uid(), true);
const merged = new Uint8Array(headerBuffer.byteLength + targetBuffer.byteLength);
merged.set(new Uint8Array(headerBuffer), 0);
merged.set(new Uint8Array(targetBuffer), headerBuffer.byteLength);
if(!isSync){
mtl.batchRenderAsync(merged.buffer, extBuffer);
return null;
}
const result = mtl.batchRender(merged.buffer, extBuffer).buffer;
if(result.byteLength == 0){
return null;;
}
// 申请内存空间,后续在cpp wasm部分使用记得释放
const ptr = Module._malloc(result.byteLength);
// 将数据拷贝到WASM内存
Module.HEAPU8.set(new Uint8Array(result), ptr);
// 返回结构化的数据信息(指针和长度)
const ret = new DataView(new ArrayBuffer(8));
ret.setUint32(0, ptr, true); // 指针地址4字节
ret.setUint32(4, result.byteLength, true); // 数据长度4字节
// 返回合并后的8字节缓冲区指针记得也要在cpp部分释放
const retPtr = Module._malloc(8);
Module.HEAPU8.set(new Uint8Array(ret.buffer), retPtr);
return retPtr;
},
js_swapWindow: function(){
mtl.swapWindow();
}
});

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: dda1926f3454e003333e8085a4f2c0fd
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,82 @@
fileFormatVersion: 2
guid: be799b1631d688242995c11c94a5b318
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 1
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
Exclude WindowsStoreApps: 1
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
CPU: x86_64
DefaultValueInitialized: true
OS: Windows
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: x86_64
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
DontProcess: false
PlaceholderPath:
SDK: AnySDK
ScriptingBackend: AnyScriptingBackend
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: a3d25085461954ccf96b870bbabd2d51 guid: 5c4133172957c4ff58904dc589712f66
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 72db98ce23892438085944429a2f0f1e guid: 688f385fb02274584bc0da25fc717541
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
userData: userData:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 0786375919a5f4b39a2842d398bab691 guid: 7f21f78b4cc234191b76cd464483218a
TextScriptImporter: TextScriptImporter:
externalObjects: {} externalObjects: {}
userData: userData:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: e49d6d9d90710412390e04f36c283269 guid: e2d1865a2511c490fade16ba4a1cb98d
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: a687be9fecc0c4635a0198f4c84c5a7a guid: 87afef55b8ecb4102a02702ac98a8c08
TextScriptImporter: TextScriptImporter:
externalObjects: {} externalObjects: {}
userData: userData:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 59195b600f5474a34ab0de959545786a guid: 15b1d1d2687c240e79f3326305a8e34d
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
userData: userData:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 945d329c042b5422590297f9a668573b guid: f2f9e284d496f4f0da239b534fc0962e
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
userData: userData:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 5c728f27cb29c4a7ab957bec87aee79b guid: c36b18db4fca44e7999111a49563794c
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
userData: userData:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: e116238b593ee4f118e080fc2e1be1d0 guid: 18049f8d0a7b340e089d8f6a56329852
TextScriptImporter: TextScriptImporter:
externalObjects: {} externalObjects: {}
userData: userData:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 95f171f78f3854726ba37852e7da8ace guid: 717be45d5d44c471e96a22dbcd2aaddd
TextScriptImporter: TextScriptImporter:
externalObjects: {} externalObjects: {}
userData: userData:

8
Editor/Playable.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b9ade20e13f604b10b5328d9cbdeafbe
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,138 @@
using System;
using System.IO;
using UnityEditor;
using UnityEngine;
namespace WeChatWASM
{
public class WXPlayableConvertCore
{
static WXPlayableConvertCore() { }
public static WXPlayableEditorScriptObject config => UnityUtil.GetPlayableEditorConf();
public static WXConvertCore.WXExportError DoExport(bool buildWebGL = true)
{
WXConvertCore.isPlayableBuild = true;
// var preCheckResult = WXConvertCore.PreCheck();
// if (preCheckResult != WXConvertCore.WXExportError.SUCCEED)
// {
// WXConvertCore.isPlayableBuild = false;
// return preCheckResult;
// }
// WXConvertCore.PreInit();
var exportResult = WXConvertCore.DoExport();
WXConvertCore.isPlayableBuild = false;
return exportResult;
}
public static WXEditorScriptObject GetFakeScriptObject()
{
return SetDefaultProperties(ConvertPlayableConfigToCommon(config));
}
public static WXEditorScriptObject ConvertPlayableConfigToCommon(
WXPlayableEditorScriptObject source,
WXEditorScriptObject target = null)
{
// 创建或使用现有的目标实例
var newTarget = target ?? ScriptableObject.CreateInstance<WXEditorScriptObject>();
// 使用序列化方式深度拷贝公共字段
var so = new SerializedObject(newTarget);
// 遍历源对象的所有字段
var sourceType = source.GetType();
foreach (var sourceField in sourceType.GetFields(
System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance |
System.Reflection.BindingFlags.NonPublic))
{
// 跳过readonly字段
if (sourceField.IsInitOnly) continue;
// 查找目标对象中的对应字段
var targetField = typeof(WXEditorScriptObject).GetField(
sourceField.Name,
System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance |
System.Reflection.BindingFlags.NonPublic);
// if (targetField != null && !targetField.FieldType.IsValueType && !targetField.FieldType.IsEnum)
// {
// // // 复制字段值
// // var value = sourceField.GetValue(source);
// // targetField.SetValue(newTarget, value);
// // 递归复制子对象属性
// var subObj = targetField.GetValue(newTarget) ?? Activator.CreateInstance(targetField.FieldType);
// CopySubObjectProperties(value, subObj);
// targetField.SetValue(newTarget, subObj);
// }
// if (targetField != null &&
// (targetField.FieldType.IsAssignableFrom(sourceField.FieldType) ||
// (targetField.FieldType.IsValueType && sourceField.FieldType.IsValueType &&
// targetField.FieldType == sourceField.FieldType)))
// {
// 复制字段值
var value = sourceField.GetValue(source);
// 特殊处理嵌套对象类型的字段
if (value != null && !targetField.FieldType.IsValueType && !targetField.FieldType.IsEnum)
{
// 递归复制子对象属性
var subObj = targetField.GetValue(newTarget) ?? Activator.CreateInstance(targetField.FieldType);
CopySubObjectProperties(value, subObj);
targetField.SetValue(newTarget, subObj);
}
else
{
targetField.SetValue(newTarget, value);
}
// }
}
// 应用修改到序列化对象
so.ApplyModifiedProperties();
return newTarget;
}
private static void CopySubObjectProperties(object source, object target)
{
var sourceType = source.GetType();
var targetType = target.GetType();
foreach (var sourceField in sourceType.GetFields(
System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance |
System.Reflection.BindingFlags.NonPublic))
{
if (sourceField.IsInitOnly) continue;
var targetField = targetType.GetField(
sourceField.Name,
System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance |
System.Reflection.BindingFlags.NonPublic);
if (targetField != null &&
(targetField.FieldType.IsAssignableFrom(sourceField.FieldType) ||
(targetField.FieldType.IsValueType && sourceField.FieldType.IsValueType &&
targetField.FieldType == sourceField.FieldType)))
{
var value = sourceField.GetValue(source);
targetField.SetValue(target, value);
}
}
}
public static WXEditorScriptObject SetDefaultProperties(WXEditorScriptObject target)
{
target.ProjectConf.CDN = "";
target.ProjectConf.assetLoadType = 1;
target.ProjectConf.compressDataPackage = true;
target.CompileOptions.showMonitorSuggestModal = false;
return target;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ad34d0bbab40b445689701c63f86cf16
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,359 @@
using System;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
namespace WeChatWASM
{
[InitializeOnLoad]
public class WXPlayableSettingsHelperInterface
{
public static WXPlayableSettingsHelper helper = new WXPlayableSettingsHelper();
}
public class WXPlayableSettingsHelper
{
public static string projectRootPath;
private static WXPlayableEditorScriptObject config;
private static bool m_EnablePerfTool = false;
public static bool UseIL2CPP
{
get
{
#if TUANJIE_2022_3_OR_NEWER
return PlayerSettings.GetScriptingBackend(BuildTargetGroup.WeixinMiniGame) == ScriptingImplementation.IL2CPP;
#else
return true;
#endif
}
}
public WXPlayableSettingsHelper()
{
projectRootPath = System.IO.Path.GetFullPath(Application.dataPath + "/../");
}
public void OnFocus()
{
loadData();
}
public void OnLostFocus()
{
saveData();
}
public void OnDisable()
{
EditorUtility.SetDirty(config);
}
private Vector2 scrollRoot;
private bool foldBaseInfo = true;
private bool foldDebugOptions = true;
public void OnSettingsGUI(EditorWindow window)
{
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));
this.formInput("appid", "小游戏试玩AppID");
this.formInput("projectName", "小游戏试玩项目名");
this.formIntPopup("orientation", "游戏方向", new[] { "Portrait", "Landscape" }, 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();
EditorGUILayout.EndVertical();
}
foldDebugOptions = EditorGUILayout.Foldout(foldDebugOptions, "调试编译选项");
if (foldDebugOptions)
{
EditorGUILayout.BeginVertical("frameBox", GUILayout.ExpandWidth(true));
this.formCheckbox("developBuild", "Development Build", "", false, null, OnDevelopmentBuildToggleChanged);
this.formCheckbox("il2CppOptimizeSize", "Il2Cpp Optimize Size(?)", "对应于Il2CppCodeGeneration选项勾选时使用OptimizeSize(默认推荐)生成代码小15%左右取消勾选则使用OptimizeSpeed。游戏中大量泛型集合的高频访问建议OptimizeSpeed在使用HybridCLR等第三方组件时只能用OptimizeSpeed。(Dotnet Runtime模式下该选项无效)", !UseIL2CPP);
this.formCheckbox("profilingFuncs", "Profiling Funcs");
this.formCheckbox("webgl2", "WebGL2.0(beta)");
EditorGUILayout.EndVertical();
}
EditorGUILayout.EndScrollView();
}
public void OnBuildButtonGUI(EditorWindow window)
{
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;
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(string.Empty, GUILayout.MinWidth(10));
if (GUILayout.Button(new GUIContent("生成并转换"), GUILayout.Width(100), GUILayout.Height(25)))
{
this.saveData();
if (WXPlayableConvertCore.DoExport() == WXConvertCore.WXExportError.SUCCEED)
{
window.ShowNotification(new GUIContent("转换完成"));
}
GUIUtility.ExitGUI();
}
EditorGUILayout.EndHorizontal();
}
private void OnDevelopmentBuildToggleChanged(bool InNewValue)
{
// 针对non-dev build取消性能分析工具的集成
if (!InNewValue)
{
this.setData("enablePerfAnalysis", false);
}
}
private string SDKFilePath;
private void loadData()
{
SDKFilePath = Path.Combine(UnityUtil.GetWxSDKRootPath(), "Runtime", "wechat-playable-default", "unity-sdk", "index.js");
config = UnityUtil.GetPlayableEditorConf();
this.setData("projectName", config.ProjectConf.projectName);
this.setData("appid", config.ProjectConf.Appid);
this.setData("orientation", (int)config.ProjectConf.Orientation);
this.setData("dst", config.ProjectConf.relativeDST);
this.setData("developBuild", config.CompileOptions.DevelopBuild);
this.setData("il2CppOptimizeSize", config.CompileOptions.Il2CppOptimizeSize);
this.setData("profilingFuncs", config.CompileOptions.profilingFuncs);
this.setData("webgl2", config.CompileOptions.Webgl2);
this.setData("customNodePath", config.CompileOptions.CustomNodePath);
this.setData("memorySize", config.ProjectConf.MemorySize.ToString());
}
private void saveData()
{
config.ProjectConf.projectName = this.getDataInput("projectName");
config.ProjectConf.Appid = this.getDataInput("appid");
config.ProjectConf.Orientation = (WXScreenOritation)this.getDataPop("orientation");
config.ProjectConf.relativeDST = this.getDataInput("dst");
config.ProjectConf.DST = GetAbsolutePath(config.ProjectConf.relativeDST);
config.CompileOptions.DevelopBuild = this.getDataCheckbox("developBuild");
config.CompileOptions.Il2CppOptimizeSize = this.getDataCheckbox("il2CppOptimizeSize");
config.CompileOptions.profilingFuncs = this.getDataCheckbox("profilingFuncs");
config.CompileOptions.CustomNodePath = this.getDataInput("customNodePath");
config.CompileOptions.Webgl2 = this.getDataCheckbox("webgl2");
config.ProjectConf.MemorySize = int.Parse(this.getDataInput("memorySize"));
}
private Dictionary<string, string> formInputData = new Dictionary<string, string>();
private Dictionary<string, int> formIntPopupData = new Dictionary<string, int>();
private Dictionary<string, bool> formCheckboxData = new Dictionary<string, bool>();
private string getDataInput(string target)
{
if (this.formInputData.ContainsKey(target))
return this.formInputData[target];
return "";
}
private int getDataPop(string target)
{
if (this.formIntPopupData.ContainsKey(target))
return this.formIntPopupData[target];
return 0;
}
private bool getDataCheckbox(string target)
{
if (this.formCheckboxData.ContainsKey(target))
return this.formCheckboxData[target];
return false;
}
private void formCheckbox(string target, string label, string help = null, bool disable = false, Action<bool> setting = null, Action<bool> onValueChanged = 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);
// Toggle the checkbox value based on the disable condition
bool newValue = EditorGUILayout.Toggle(disable ? false : formCheckboxData[target]);
// Update the checkbox data if the value has changed and invoke the onValueChanged action
if (newValue != formCheckboxData[target])
{
formCheckboxData[target] = newValue;
onValueChanged?.Invoke(newValue);
}
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 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 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;
}
return Path.Combine(projectRootPath, path);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1cc549c674e5b4efe964933831f56e80
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,46 @@
using UnityEngine;
using UnityEditor;
using static WeChatWASM.WXConvertCore;
namespace WeChatWASM
{
public class WXPlayableWin : EditorWindow
{
[MenuItem("微信小游戏 / 转换小游戏试玩", false, 2)]
public static void Open()
{
var win = GetWindow(typeof(WXPlayableWin), false, "微信小游戏试玩转换工具面板");
win.minSize = new Vector2(350, 400);
win.position = new Rect(200, 200, 600, 300);
win.Show();
}
// 向前兼容,请使用 WXConvertCore.cs
public static WXExportError DoExport(bool buildWebGL = true)
{
return WXPlayableConvertCore.DoExport(buildWebGL);
}
public void OnFocus()
{
WXPlayableSettingsHelperInterface.helper.OnFocus();
}
public void OnLostFocus()
{
WXPlayableSettingsHelperInterface.helper.OnLostFocus();
}
public void OnDisable()
{
WXPlayableSettingsHelperInterface.helper.OnDisable();
}
public void OnGUI()
{
WXPlayableSettingsHelperInterface.helper.OnSettingsGUI(this);
WXPlayableSettingsHelperInterface.helper.OnBuildButtonGUI(this);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f37c59ed5d1a64bf59ac4657b5fd2cd8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -71,7 +71,9 @@ namespace WeChatWASM
BUILD_WEBGL_FAILED = 2, BUILD_WEBGL_FAILED = 2,
} }
public static WXEditorScriptObject config => UnityUtil.GetEditorConf(); public static WXEditorScriptObject config => isPlayableBuild ? WXPlayableConvertCore.GetFakeScriptObject() : UnityUtil.GetEditorConf();
public static string defaultTemplateDir => isPlayableBuild ? "playable-default" : "wechat-default";
public static string webglDir = "webgl"; // 导出的webgl目录 public static string webglDir = "webgl"; // 导出的webgl目录
public static string miniGameDir = "minigame"; // 生成小游戏的目录 public static string miniGameDir = "minigame"; // 生成小游戏的目录
public static string audioDir = "Assets"; // 音频资源目录 public static string audioDir = "Assets"; // 音频资源目录
@ -80,6 +82,10 @@ namespace WeChatWASM
public static string codeMd5 = string.Empty; public static string codeMd5 = string.Empty;
public static string dataMd5 = string.Empty; public static string dataMd5 = string.Empty;
public static string defaultImgSrc = "Assets/WX-WASM-SDK-V2/Runtime/wechat-default/images/background.jpg"; public static string defaultImgSrc = "Assets/WX-WASM-SDK-V2/Runtime/wechat-default/images/background.jpg";
/// <summary>
/// 是否在构建试玩,构建开始前修改值,构建结束后恢复值
/// </summary>
public static bool isPlayableBuild = false;
private static bool lastBrotliType = false; private static bool lastBrotliType = false;
public static bool UseIL2CPP public static bool UseIL2CPP
@ -93,37 +99,77 @@ namespace WeChatWASM
#endif #endif
} }
} }
// 可以调用这个来集成 // 是否使用 iOS Metal 渲染
public static WXExportError DoExport(bool buildWebGL = true) public static bool UseiOSMetal
{ {
LifeCycleEvent.Init(); get
Emit(LifeCycle.beforeExport);
if (!CheckSDK())
{ {
Debug.LogError("若游戏曾使用旧版本微信SDK需删除 Assets/WX-WASM-SDK 文件夹后再导入最新工具包。"); return config.CompileOptions.enableiOSMetal;
return WXExportError.BUILD_WEBGL_FAILED;
} }
if (!CheckBuildTemplate()) }
{ // public static void SetPlayableEnabled(bool enabled)
Debug.LogError("因构建模板检查失败终止导出。"); // {
return WXExportError.BUILD_WEBGL_FAILED; // isPlayableBuild = enabled;
} // }
if (CheckInvalidPerfIntegration()) /// <summary>
{ /// 导出前的初始配置
Debug.LogError("性能分析工具只能用于Development Build, 终止导出! "); /// 小游戏模式和试玩模式都会使用这个函数,如果要在这个函数加新方法,建议都以不兼容试玩模式看待
return WXExportError.BUILD_WEBGL_FAILED; /// </summary>
} public static void PreInit()
{
CheckBuildTarget(); CheckBuildTarget();
Init(); Init();
ProcessWxPerfBinaries(); // 可能有顺序要求?如果没要求,可挪到此函数外
if (!isPlayableBuild)
{
ProcessWxPerfBinaries();
}
// iOS metal 的相关特性
ProcessWxiOSMetalBinaries();
MakeEnvForLuaAdaptor(); MakeEnvForLuaAdaptor();
// JSLib // JSLib
SettingWXTextureMinJSLib(); SettingWXTextureMinJSLib();
UpdateGraphicAPI(); UpdateGraphicAPI();
EditorUtility.SetDirty(config); EditorUtility.SetDirty(config);
AssetDatabase.SaveAssets(); AssetDatabase.SaveAssets();
}
public static WXExportError PreCheck()
{
if (!CheckSDK())
{
Debug.LogError("若游戏曾使用旧版本微信SDK需删除 Assets/WX-WASM-SDK 文件夹后再导入最新工具包。");
return WXExportError.BUILD_WEBGL_FAILED;
}
if (!isPlayableBuild && !CheckBuildTemplate())
{
Debug.LogError("因构建模板检查失败终止导出。");
return WXExportError.BUILD_WEBGL_FAILED;
}
if (!isPlayableBuild && CheckInvalidPerfIntegration())
{
Debug.LogError("性能分析工具只能用于Development Build, 终止导出!");
return WXExportError.BUILD_WEBGL_FAILED;
}
dynamic config = isPlayableBuild ? UnityUtil.GetPlayableEditorConf() : UnityUtil.GetEditorConf();
if (config.ProjectConf.relativeDST == string.Empty)
{
Debug.LogError("请先配置游戏导出路径");
return WXExportError.BUILD_WEBGL_FAILED;
}
return WXExportError.SUCCEED;
}
// 可以调用这个来集成
public static WXExportError DoExport(bool buildWebGL = true)
{
LifeCycleEvent.Init();
Emit(LifeCycle.beforeExport);
var preCheckResult = PreCheck();
if (preCheckResult != WXExportError.SUCCEED)
{
return preCheckResult;
}
PreInit();
// 记录上次导出的brotliType // 记录上次导出的brotliType
{ {
@ -141,12 +187,6 @@ namespace WeChatWASM
} }
} }
if (config.ProjectConf.DST == string.Empty)
{
Debug.LogError("请先配置游戏导出路径");
return WXExportError.BUILD_WEBGL_FAILED;
}
else
{ {
// 仅删除StreamingAssets目录 // 仅删除StreamingAssets目录
if (config.CompileOptions.DeleteStreamingAssets) if (config.CompileOptions.DeleteStreamingAssets)
@ -371,6 +411,41 @@ namespace WeChatWASM
return true; return true;
} }
private static void ProcessWxiOSMetalBinaries()
{
string[] glLibs;
string DS = WXAssetsTextTools.DS;
if (UnityUtil.GetSDKMode() == UnityUtil.SDKMode.Package)
{
glLibs = new string[]
{
$"Packages{DS}com.qq.weixin.minigame{DS}Editor{DS}BuildProfile{DS}lib{DS}libwx-metal-cpp.bc",
$"Packages{DS}com.qq.weixin.minigame{DS}Editor{DS}BuildProfile{DS}lib{DS}mtl_library.jslib",
};
}
else
{
string glLibRootDir = $"Assets{DS}WX-WASM-SDK-V2{DS}Editor{DS}BuildProfile{DS}lib{DS}";
glLibs = new string[]
{
$"{glLibRootDir}libwx-metal-cpp.bc",
$"{glLibRootDir}mtl_library.jslib",
};
}
for (int i = 0; i < glLibs.Length; i++)
{
var importer = AssetImporter.GetAtPath(glLibs[i]) as PluginImporter;
#if PLATFORM_WEIXINMINIGAME
importer.SetCompatibleWithPlatform(BuildTarget.WeixinMiniGame, config.CompileOptions.enableiOSMetal);
#else
importer.SetCompatibleWithPlatform(BuildTarget.WebGL, config.CompileOptions.enableiOSMetal);
#endif
// importer.SaveAndReimport();
SetPluginCompatibilityByModifyingMetadataFile(glLibs[i], config.CompileOptions.enableiOSMetal);
}
AssetDatabase.Refresh();
}
private static string GetLuaAdaptorPath(string filename) private static string GetLuaAdaptorPath(string filename)
{ {
string DS = WXAssetsTextTools.DS; string DS = WXAssetsTextTools.DS;
@ -494,13 +569,28 @@ namespace WeChatWASM
GraphicsDeviceType[] targets = new GraphicsDeviceType[] { }; GraphicsDeviceType[] targets = new GraphicsDeviceType[] { };
#if PLATFORM_WEIXINMINIGAME #if PLATFORM_WEIXINMINIGAME
PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.WeixinMiniGame, false); PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.WeixinMiniGame, false);
if (config.CompileOptions.Webgl2) // 启用 iOS Metal 渲染
if (UseiOSMetal)
{ {
PlayerSettings.SetGraphicsAPIs(BuildTarget.WeixinMiniGame, new GraphicsDeviceType[] { GraphicsDeviceType.OpenGLES3 }); if (config.CompileOptions.Webgl2)
{
PlayerSettings.SetGraphicsAPIs(BuildTarget.WeixinMiniGame, new GraphicsDeviceType[] { GraphicsDeviceType.Metal, GraphicsDeviceType.OpenGLES3 });
}
else
{
PlayerSettings.SetGraphicsAPIs(BuildTarget.WeixinMiniGame, new GraphicsDeviceType[] { GraphicsDeviceType.Metal, GraphicsDeviceType.OpenGLES2 });
}
} }
else else
{ {
PlayerSettings.SetGraphicsAPIs(BuildTarget.WeixinMiniGame, new GraphicsDeviceType[] { GraphicsDeviceType.OpenGLES2 }); if (config.CompileOptions.Webgl2)
{
PlayerSettings.SetGraphicsAPIs(BuildTarget.WeixinMiniGame, new GraphicsDeviceType[] { GraphicsDeviceType.OpenGLES3 });
}
else
{
PlayerSettings.SetGraphicsAPIs(BuildTarget.WeixinMiniGame, new GraphicsDeviceType[] { GraphicsDeviceType.OpenGLES2 });
}
} }
#else #else
PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.WebGL, false); PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.WebGL, false);
@ -566,7 +656,7 @@ namespace WeChatWASM
private static bool CheckBuildTemplate() private static bool CheckBuildTemplate()
{ {
string[] res = BuildTemplate.CheckCustomCoverBaseConflict( string[] res = BuildTemplate.CheckCustomCoverBaseConflict(
Path.Combine(UnityUtil.GetWxSDKRootPath(), "Runtime", "wechat-default"), Path.Combine(UnityUtil.GetWxSDKRootPath(), "Runtime", defaultTemplateDir),
Path.Combine(Application.dataPath, "WX-WASM-SDK-V2", "Editor", "template"), Path.Combine(Application.dataPath, "WX-WASM-SDK-V2", "Editor", "template"),
new string[] { @"\.(js|ts|json)$" } new string[] { @"\.(js|ts|json)$" }
); );
@ -801,7 +891,12 @@ namespace WeChatWASM
PlayerSettings.WeixinMiniGame.emscriptenArgs = string.Empty; PlayerSettings.WeixinMiniGame.emscriptenArgs = string.Empty;
if (WXExtEnvDef.GETDEF("UNITY_2021_2_OR_NEWER")) if (WXExtEnvDef.GETDEF("UNITY_2021_2_OR_NEWER"))
{ {
PlayerSettings.WeixinMiniGame.emscriptenArgs += " -s EXPORTED_FUNCTIONS=_main,_sbrk,_emscripten_stack_get_base,_emscripten_stack_get_end -s ERROR_ON_UNDEFINED_SYMBOLS=0"; PlayerSettings.WeixinMiniGame.emscriptenArgs += " -s EXPORTED_FUNCTIONS=_main,_sbrk,_emscripten_stack_get_base,_emscripten_stack_get_end";
if (config.CompileOptions.enablePerfAnalysis)
{
PlayerSettings.WeixinMiniGame.emscriptenArgs += ",_WxPerfFrameIntervalCallback";
}
PlayerSettings.WeixinMiniGame.emscriptenArgs += " -s ERROR_ON_UNDEFINED_SYMBOLS=0";
} }
#else #else
@ -809,6 +904,10 @@ namespace WeChatWASM
if (WXExtEnvDef.GETDEF("UNITY_2021_2_OR_NEWER")) if (WXExtEnvDef.GETDEF("UNITY_2021_2_OR_NEWER"))
{ {
PlayerSettings.WebGL.emscriptenArgs += " -s EXPORTED_FUNCTIONS=_sbrk,_emscripten_stack_get_base,_emscripten_stack_get_end"; PlayerSettings.WebGL.emscriptenArgs += " -s EXPORTED_FUNCTIONS=_sbrk,_emscripten_stack_get_base,_emscripten_stack_get_end";
if (config.CompileOptions.enablePerfAnalysis)
{
PlayerSettings.WebGL.emscriptenArgs += ",_WxPerfFrameIntervalCallback";
}
#if UNITY_2021_2_5 #if UNITY_2021_2_5
PlayerSettings.WebGL.emscriptenArgs += ",_main"; PlayerSettings.WebGL.emscriptenArgs += ",_main";
#endif #endif
@ -1156,7 +1255,10 @@ namespace WeChatWASM
public static void convertDataPackageJS() public static void convertDataPackageJS()
{ {
checkNeedRmovePackageParallelPreload(); if (!isPlayableBuild)
{
checkNeedRmovePackageParallelPreload();
}
var loadDataFromCdn = config.ProjectConf.assetLoadType == 0; var loadDataFromCdn = config.ProjectConf.assetLoadType == 0;
Rule[] rules = Rule[] rules =
@ -1275,7 +1377,7 @@ namespace WeChatWASM
RemoveOldAssetPackage(Path.Combine(config.ProjectConf.DST, webglDir)); RemoveOldAssetPackage(Path.Combine(config.ProjectConf.DST, webglDir));
RemoveOldAssetPackage(Path.Combine(config.ProjectConf.DST, webglDir + "-min")); RemoveOldAssetPackage(Path.Combine(config.ProjectConf.DST, webglDir + "-min"));
var buildTemplate = new BuildTemplate( var buildTemplate = new BuildTemplate(
Path.Combine(UnityUtil.GetWxSDKRootPath(), "Runtime", "wechat-default"), Path.Combine(UnityUtil.GetWxSDKRootPath(), "Runtime", defaultTemplateDir),
Path.Combine(Application.dataPath, "WX-WASM-SDK-V2", "Editor", "template"), Path.Combine(Application.dataPath, "WX-WASM-SDK-V2", "Editor", "template"),
Path.Combine(config.ProjectConf.DST, miniGameDir) Path.Combine(config.ProjectConf.DST, miniGameDir)
); );
@ -1416,7 +1518,7 @@ namespace WeChatWASM
var shortFilename = filename.Substring(filename.IndexOf('.') + 1); var shortFilename = filename.Substring(filename.IndexOf('.') + 1);
// 如果code没有发生过变化且压缩方式不变则不再进行br压缩 // 如果code没有发生过变化且压缩方式不变则不再进行br压缩
if (File.Exists(cachePath) && lastBrotliType == config.CompileOptions.brotliMT) if (cachePath.Contains("wasm.code") && File.Exists(cachePath) && lastBrotliType == config.CompileOptions.brotliMT)
{ {
File.Copy(cachePath, targetPath, true); File.Copy(cachePath, targetPath, true);
return 0; return 0;
@ -1506,7 +1608,8 @@ namespace WeChatWASM
writer.PrettyPrint = true; writer.PrettyPrint = true;
// 将 game.json 里面关系链相关的配置删除 // 将 game.json 里面关系链相关的配置删除
if (!config.SDKOptions.UseFriendRelation) // 试玩 game.json 中不含其他配置
if (!config.SDKOptions.UseFriendRelation && gameJson.ContainsKey("openDataContext") && gameJson.ContainsKey("plugins"))
{ {
gameJson.Remove("openDataContext"); gameJson.Remove("openDataContext");
gameJson["plugins"].Remove("Layout"); gameJson["plugins"].Remove("Layout");
@ -1517,7 +1620,7 @@ namespace WeChatWASM
Directory.Delete(openDataDir, true); Directory.Delete(openDataDir, true);
} }
if (!config.SDKOptions.UseMiniGameChat) if (!config.SDKOptions.UseMiniGameChat && gameJson.ContainsKey("plugins"))
{ {
gameJson["plugins"].Remove("MiniGameChat"); gameJson["plugins"].Remove("MiniGameChat");
UnityEngine.Debug.Log(gameJson["plugins"]); UnityEngine.Debug.Log(gameJson["plugins"]);
@ -1604,17 +1707,20 @@ namespace WeChatWASM
{ {
dst = Path.Combine(config.ProjectConf.DST, miniGameDir); dst = Path.Combine(config.ProjectConf.DST, miniGameDir);
} }
string content = File.ReadAllText(Path.Combine(UnityUtil.GetWxSDKRootPath(), "Runtime", "wechat-default", "unity-sdk", "index.js"), Encoding.UTF8); string content = File.ReadAllText(Path.Combine(UnityUtil.GetWxSDKRootPath(), "Runtime", defaultTemplateDir, "unity-sdk", "index.js"), Encoding.UTF8);
content = content.Replace("$unityVersion$", Application.unityVersion); content = content.Replace("$unityVersion$", Application.unityVersion);
File.WriteAllText(Path.Combine(dst, "unity-sdk", "index.js"), content, Encoding.UTF8); File.WriteAllText(Path.Combine(dst, "unity-sdk", "index.js"), content, Encoding.UTF8);
// content = File.ReadAllText(Path.Combine(Application.dataPath, "WX-WASM-SDK-V2", "Runtime", "wechat-default", "unity-sdk", "storage.js"), Encoding.UTF8); // content = File.ReadAllText(Path.Combine(Application.dataPath, "WX-WASM-SDK-V2", "Runtime", "wechat-default", "unity-sdk", "storage.js"), Encoding.UTF8);
content = File.ReadAllText(Path.Combine(UnityUtil.GetWxSDKRootPath(), "Runtime", "wechat-default", "unity-sdk", "storage.js"), Encoding.UTF8); if (!isPlayableBuild)
var PreLoadKeys = config.PlayerPrefsKeys.Count > 0 ? JsonMapper.ToJson(config.PlayerPrefsKeys) : "[]"; {
content = content.Replace("'$PreLoadKeys'", PreLoadKeys); content = File.ReadAllText(Path.Combine(UnityUtil.GetWxSDKRootPath(), "Runtime", defaultTemplateDir, "unity-sdk", "storage.js"), Encoding.UTF8);
File.WriteAllText(Path.Combine(dst, "unity-sdk", "storage.js"), content, Encoding.UTF8); var PreLoadKeys = config.PlayerPrefsKeys.Count > 0 ? JsonMapper.ToJson(config.PlayerPrefsKeys) : "[]";
content = content.Replace("'$PreLoadKeys'", PreLoadKeys);
File.WriteAllText(Path.Combine(dst, "unity-sdk", "storage.js"), content, Encoding.UTF8);
}
// 修改纹理dxt // 修改纹理dxt
// content = File.ReadAllText(Path.Combine(Application.dataPath, "WX-WASM-SDK-V2", "Runtime", "wechat-default", "unity-sdk", "texture.js"), Encoding.UTF8); // content = File.ReadAllText(Path.Combine(Application.dataPath, "WX-WASM-SDK-V2", "Runtime", "wechat-default", "unity-sdk", "texture.js"), Encoding.UTF8);
content = File.ReadAllText(Path.Combine(UnityUtil.GetWxSDKRootPath(), "Runtime", "wechat-default", "unity-sdk", "texture.js"), Encoding.UTF8); content = File.ReadAllText(Path.Combine(UnityUtil.GetWxSDKRootPath(), "Runtime", defaultTemplateDir, "unity-sdk", "texture.js"), Encoding.UTF8);
File.WriteAllText(Path.Combine(dst, "unity-sdk", "texture.js"), content, Encoding.UTF8); File.WriteAllText(Path.Combine(dst, "unity-sdk", "texture.js"), content, Encoding.UTF8);
} }
@ -1831,14 +1937,15 @@ namespace WeChatWASM
UnityEngine.Debug.LogFormat("[Converter] Starting to modify configs"); UnityEngine.Debug.LogFormat("[Converter] Starting to modify configs");
var PRELOAD_LIST = GetPreloadList(config.ProjectConf.preloadFiles); var PRELOAD_LIST = GetPreloadList(config.ProjectConf.preloadFiles);
var imgSrc = HandleLoadingImage(); // 试玩不存在封面图
var imgSrc = isPlayableBuild ? "" : HandleLoadingImage();
var bundlePathIdentifierStr = GetArrayString(config.ProjectConf.bundlePathIdentifier); var bundlePathIdentifierStr = GetArrayString(config.ProjectConf.bundlePathIdentifier);
var excludeFileExtensionsStr = GetArrayString(config.ProjectConf.bundleExcludeExtensions); var excludeFileExtensionsStr = GetArrayString(config.ProjectConf.bundleExcludeExtensions);
var screenOrientation = new List<string>() { "portrait", "landscape", "landscapeLeft", "landscapeRight" }[(int)config.ProjectConf.Orientation]; var screenOrientation = new List<string>() { "portrait", "landscape", "landscapeLeft", "landscapeRight" }[(int)config.ProjectConf.Orientation];
// 试玩不支持系统字体
var customUnicodeRange = GetCustomUnicodeRange(config.FontOptions.CustomUnicode); var customUnicodeRange = isPlayableBuild ? "[]" : GetCustomUnicodeRange(config.FontOptions.CustomUnicode);
Debug.Log("[Converter] customUnicodeRange: " + customUnicodeRange); Debug.Log("[Converter] customUnicodeRange: " + customUnicodeRange);
var boolConfigInfo = GenerateBootInfo(); var boolConfigInfo = GenerateBootInfo();
@ -1859,7 +1966,7 @@ namespace WeChatWASM
config.ProjectConf.bundleHashLength.ToString(), config.ProjectConf.bundleHashLength.ToString(),
bundlePathIdentifierStr, bundlePathIdentifierStr,
excludeFileExtensionsStr, excludeFileExtensionsStr,
config.CompileOptions.Webgl2 ? "2" : "1", config.CompileOptions.enableiOSMetal ? "5" : (config.CompileOptions.Webgl2 ? "2" : "1"),
Application.unityVersion, Application.unityVersion,
WXExtEnvDef.pluginVersion, WXExtEnvDef.pluginVersion,
config.ProjectConf.dataFileSubPrefix, config.ProjectConf.dataFileSubPrefix,
@ -1907,10 +2014,16 @@ namespace WeChatWASM
config.CompileOptions.enablePerfAnalysis ? "true" : "false", config.CompileOptions.enablePerfAnalysis ? "true" : "false",
config.ProjectConf.MemorySize.ToString(), config.ProjectConf.MemorySize.ToString(),
config.SDKOptions.disableMultiTouch ? "true" : "false", config.SDKOptions.disableMultiTouch ? "true" : "false",
// Perfstream暂时设为false
"false"
}); });
List<Rule> replaceList = new List<Rule>(replaceArrayList); List<Rule> replaceList = new List<Rule>(replaceArrayList);
List<string> files = new List<string> { "game.js", "game.json", "project.config.json", "unity-namespace.js", "check-version.js", "unity-sdk/font/index.js" }; List<string> files = new List<string> { "game.js", "game.json", "project.config.json", "unity-namespace.js", "check-version.js", "unity-sdk/font/index.js" };
if (isPlayableBuild)
{
files = new List<string> { "game.js", "game.json", "project.config.json", "unity-namespace.js", "check-version.js" };
}
if (WXRuntimeExtEnvDef.IsPreviewing) if (WXRuntimeExtEnvDef.IsPreviewing)
{ {

View File

@ -54,15 +54,11 @@ namespace WeChatWASM
foldInstantGame = WXConvertCore.IsInstantGameAutoStreaming(); foldInstantGame = WXConvertCore.IsInstantGameAutoStreaming();
projectRootPath = System.IO.Path.GetFullPath(Application.dataPath + "/../"); projectRootPath = System.IO.Path.GetFullPath(Application.dataPath + "/../");
_dstCache = "";
} }
private static WXEditorScriptObject config; private static WXEditorScriptObject config;
private static bool m_EnablePerfTool = false; private static bool m_EnablePerfTool = false;
private static string _dstCache;
public void OnFocus() public void OnFocus()
{ {
loadData(); loadData();
@ -189,6 +185,7 @@ namespace WeChatWASM
this.formCheckbox("profilingMemory", "Profiling Memory"); this.formCheckbox("profilingMemory", "Profiling Memory");
this.formCheckbox("webgl2", "WebGL2.0(beta)"); this.formCheckbox("webgl2", "WebGL2.0(beta)");
this.formCheckbox("iOSPerformancePlus", "iOSPerformancePlus(?)", "是否使用iOS高性能+渲染方案有助于提升渲染兼容性、降低WebContent进程内存"); this.formCheckbox("iOSPerformancePlus", "iOSPerformancePlus(?)", "是否使用iOS高性能+渲染方案有助于提升渲染兼容性、降低WebContent进程内存");
// this.formCheckbox("iOSMetal", "iOSMetal(?)", "是否使用iOSMetal渲染方案需要开启iOS高性能+模式有助于提升运行性能降低iOS功耗");
this.formCheckbox("deleteStreamingAssets", "Clear Streaming Assets"); this.formCheckbox("deleteStreamingAssets", "Clear Streaming Assets");
this.formCheckbox("cleanBuild", "Clean WebGL Build"); this.formCheckbox("cleanBuild", "Clean WebGL Build");
// this.formCheckbox("cleanCloudDev", "Clean Cloud Dev"); // this.formCheckbox("cleanCloudDev", "Clean Cloud Dev");
@ -394,7 +391,6 @@ namespace WeChatWASM
// SDKFilePath = Path.Combine(Application.dataPath, "WX-WASM-SDK-V2", "Runtime", "wechat-default", "unity-sdk", "index.js"); // SDKFilePath = Path.Combine(Application.dataPath, "WX-WASM-SDK-V2", "Runtime", "wechat-default", "unity-sdk", "index.js");
SDKFilePath = Path.Combine(UnityUtil.GetWxSDKRootPath(), "Runtime", "wechat-default", "unity-sdk", "index.js"); SDKFilePath = Path.Combine(UnityUtil.GetWxSDKRootPath(), "Runtime", "wechat-default", "unity-sdk", "index.js");
config = UnityUtil.GetEditorConf(); config = UnityUtil.GetEditorConf();
_dstCache = config.ProjectConf.DST;
// Instant Game // Instant Game
if (WXConvertCore.IsInstantGameAutoStreaming()) if (WXConvertCore.IsInstantGameAutoStreaming())
@ -436,7 +432,7 @@ namespace WeChatWASM
this.setData("compressDataPackage", config.ProjectConf.compressDataPackage); this.setData("compressDataPackage", config.ProjectConf.compressDataPackage);
this.setData("videoUrl", config.ProjectConf.VideoUrl); this.setData("videoUrl", config.ProjectConf.VideoUrl);
this.setData("orientation", (int)config.ProjectConf.Orientation); this.setData("orientation", (int)config.ProjectConf.Orientation);
this.setData("dst", _dstCache); this.setData("dst", config.ProjectConf.relativeDST);
this.setData("bundleHashLength", config.ProjectConf.bundleHashLength.ToString()); this.setData("bundleHashLength", config.ProjectConf.bundleHashLength.ToString());
this.setData("bundlePathIdentifier", config.ProjectConf.bundlePathIdentifier); this.setData("bundlePathIdentifier", config.ProjectConf.bundlePathIdentifier);
this.setData("bundleExcludeExtensions", config.ProjectConf.bundleExcludeExtensions); this.setData("bundleExcludeExtensions", config.ProjectConf.bundleExcludeExtensions);
@ -452,6 +448,7 @@ namespace WeChatWASM
this.setData("customNodePath", config.CompileOptions.CustomNodePath); this.setData("customNodePath", config.CompileOptions.CustomNodePath);
this.setData("webgl2", config.CompileOptions.Webgl2); this.setData("webgl2", config.CompileOptions.Webgl2);
this.setData("iOSPerformancePlus", config.CompileOptions.enableIOSPerformancePlus); this.setData("iOSPerformancePlus", config.CompileOptions.enableIOSPerformancePlus);
this.setData("iOSMetal", config.CompileOptions.enableiOSMetal);
this.setData("fbslim", config.CompileOptions.fbslim); this.setData("fbslim", config.CompileOptions.fbslim);
this.setData("useFriendRelation", config.SDKOptions.UseFriendRelation); this.setData("useFriendRelation", config.SDKOptions.UseFriendRelation);
this.setData("useMiniGameChat", config.SDKOptions.UseMiniGameChat); this.setData("useMiniGameChat", config.SDKOptions.UseMiniGameChat);
@ -513,8 +510,8 @@ namespace WeChatWASM
config.ProjectConf.compressDataPackage = this.getDataCheckbox("compressDataPackage"); config.ProjectConf.compressDataPackage = this.getDataCheckbox("compressDataPackage");
config.ProjectConf.VideoUrl = this.getDataInput("videoUrl"); config.ProjectConf.VideoUrl = this.getDataInput("videoUrl");
config.ProjectConf.Orientation = (WXScreenOritation)this.getDataPop("orientation"); config.ProjectConf.Orientation = (WXScreenOritation)this.getDataPop("orientation");
_dstCache = this.getDataInput("dst"); config.ProjectConf.relativeDST = this.getDataInput("dst");
config.ProjectConf.DST = GetAbsolutePath(_dstCache); config.ProjectConf.DST = GetAbsolutePath(config.ProjectConf.relativeDST);
config.ProjectConf.bundleHashLength = int.Parse(this.getDataInput("bundleHashLength")); config.ProjectConf.bundleHashLength = int.Parse(this.getDataInput("bundleHashLength"));
config.ProjectConf.bundlePathIdentifier = this.getDataInput("bundlePathIdentifier"); config.ProjectConf.bundlePathIdentifier = this.getDataInput("bundlePathIdentifier");
config.ProjectConf.bundleExcludeExtensions = this.getDataInput("bundleExcludeExtensions"); config.ProjectConf.bundleExcludeExtensions = this.getDataInput("bundleExcludeExtensions");
@ -530,6 +527,7 @@ namespace WeChatWASM
config.CompileOptions.CustomNodePath = this.getDataInput("customNodePath"); config.CompileOptions.CustomNodePath = this.getDataInput("customNodePath");
config.CompileOptions.Webgl2 = this.getDataCheckbox("webgl2"); config.CompileOptions.Webgl2 = this.getDataCheckbox("webgl2");
config.CompileOptions.enableIOSPerformancePlus = this.getDataCheckbox("iOSPerformancePlus"); config.CompileOptions.enableIOSPerformancePlus = this.getDataCheckbox("iOSPerformancePlus");
config.CompileOptions.enableiOSMetal = this.getDataCheckbox("iOSMetal");
config.CompileOptions.fbslim = this.getDataCheckbox("fbslim"); config.CompileOptions.fbslim = this.getDataCheckbox("fbslim");
config.SDKOptions.UseFriendRelation = this.getDataCheckbox("useFriendRelation"); config.SDKOptions.UseFriendRelation = this.getDataCheckbox("useFriendRelation");
config.SDKOptions.UseMiniGameChat = this.getDataCheckbox("useMiniGameChat"); config.SDKOptions.UseMiniGameChat = this.getDataCheckbox("useMiniGameChat");

View File

@ -125,6 +125,10 @@ namespace WeChatWASM
{ {
return WXConvertCore.UseIL2CPP; return WXConvertCore.UseIL2CPP;
}); });
WXExtEnvDef.RegisterAction("WXConvertCore.UseiOSMetal", (args) =>
{
return WXConvertCore.UseiOSMetal;
});
WXExtEnvDef.RegisterAction("UnityUtil.GetWxSDKRootPath", (args) => WXExtEnvDef.RegisterAction("UnityUtil.GetWxSDKRootPath", (args) =>
{ {
#if UNITY_2018 #if UNITY_2018

View File

@ -2,7 +2,7 @@ namespace WeChatWASM
{ {
public class WXPluginVersion public class WXPluginVersion
{ {
public static string pluginVersion = "202505150937"; // 这一行不要改他,导出的时候会自动替换 public static string pluginVersion = "202507300820"; // 这一行不要改他,导出的时候会自动替换
} }
public class WXPluginConf public class WXPluginConf

Binary file not shown.

View File

@ -9,12 +9,17 @@
构建模板工具类 构建模板工具类
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.BuildTemplate.ignoreUserTemplate">
<summary>
是否忽略用户自定义模板
</summary>
</member>
<member name="F:WeChatWASM.BuildTemplate.IgnoreRules"> <member name="F:WeChatWASM.BuildTemplate.IgnoreRules">
<summary> <summary>
复制覆盖时不参与覆盖的正则表达式,可在 beforeCoverTemplate前动态修改 复制覆盖时不参与覆盖的正则表达式,可在 beforeCoverTemplate前动态修改
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.BuildTemplate.CheckCustomCoverBaseConflict(System.String,System.String,System.String[])"> <member name="M:WeChatWASM.BuildTemplate.CheckCustomCoverBaseConflict(System.String,System.String,System.String[],System.Boolean)">
<summary> <summary>
防止自定义模板对覆盖基础模板有覆盖在新版本更新后有代码冲突需要做此检查 防止自定义模板对覆盖基础模板有覆盖在新版本更新后有代码冲突需要做此检查
</summary> </summary>
@ -289,7 +294,7 @@
<member name="T:WeChatWASM.UnityUtil"> <member name="T:WeChatWASM.UnityUtil">
工具函数 工具函数
</member> </member>
<member name="M:WeChatWASM.UnityUtil.WxSDKEnvInit"> <member name="M:WeChatWASM.UnityUtil.WxSDKEnvInit(System.Boolean)">
<summary> <summary>
微信SDK环境初始化 微信SDK环境初始化
</summary> </summary>
@ -376,6 +381,11 @@
视频url 视频url
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.WXProjectConf.relativeDST">
<summary>
导出路径(相对路径)
</summary>
</member>
<member name="F:WeChatWASM.WXProjectConf.DST"> <member name="F:WeChatWASM.WXProjectConf.DST">
<summary> <summary>
导出路径(绝对路径) 导出路径(绝对路径)
@ -638,6 +648,11 @@
是否使用iOS高性能Plus 是否使用iOS高性能Plus
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.CompileOptions.enableiOSMetal">
<summary>
是否使用iOS metal指令流
</summary>
</member>
<member name="F:WeChatWASM.CompileOptions.brotliMT"> <member name="F:WeChatWASM.CompileOptions.brotliMT">
<summary> <summary>
是否使用brotli多线程压缩 是否使用brotli多线程压缩
@ -758,5 +773,66 @@
字体配置 字体配置
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.WXPlayableProjectConf.projectName">
<summary>
试玩项目名
</summary>
</member>
<member name="F:WeChatWASM.WXPlayableProjectConf.Appid">
<summary>
试玩 appid
</summary>
</member>
<member name="F:WeChatWASM.WXPlayableProjectConf.relativeDST">
<summary>
导出路径(相对路径)
</summary>
</member>
<member name="F:WeChatWASM.WXPlayableProjectConf.DST">
<summary>
导出路径(绝对路径)
</summary>
</member>
<member name="F:WeChatWASM.WXPlayableProjectConf.MemorySize">
<summary>
游戏内存大小(MB)
</summary>
</member>
<member name="F:WeChatWASM.WXPlayableProjectConf.Orientation">
<summary>
游戏方向
</summary>
</member>
<member name="F:WeChatWASM.WXPlayableProjectConf.IOSDevicePixelRatio">
<summary>
IOS限制固定的分辨率以减少内存但是会降低游戏画面品质
注意不要随意修改默认值为00表示不限制
</summary>
</member>
<member name="F:WeChatWASM.PlayableCompileOptions.DevelopBuild">
<summary>
Development Build
</summary>
</member>
<member name="F:WeChatWASM.PlayableCompileOptions.Il2CppOptimizeSize">
<summary>
Il2CppCodeGeneration.OptimizeSize
</summary>
</member>
<member name="F:WeChatWASM.PlayableCompileOptions.profilingFuncs">
<summary>
Profiling Funcs
</summary>
</member>
<member name="F:WeChatWASM.PlayableCompileOptions.Webgl2">
<summary>
WebGL2.0
</summary>
</member>
<member name="F:WeChatWASM.PlayableCompileOptions.CustomNodePath">
<summary>
CustomNodePath
</summary>
</member>
</members> </members>
</doc> </doc>

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 5c69c398d8373f0e6dbde148c75cbbb7 guid: 1b94c242fc37a08a874cb51e273085a1
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
userData: userData:

View File

@ -416,11 +416,11 @@ mergeInto(LibraryManager.library, {
WXVideoPlay: function(id) { WXVideoPlay: function(id) {
window.WXWASMSDK.WXVideoPlay(_WXPointer_stringify_adaptor(id)); window.WXWASMSDK.WXVideoPlay(_WXPointer_stringify_adaptor(id));
}, },
WXVideoAddListener: function(id,key) { WXVideoAddListener: function(id, key) {
window.WXWASMSDK.WXVideoAddListener(_WXPointer_stringify_adaptor(id), _WXPointer_stringify_adaptor(key)); window.WXWASMSDK.WXVideoAddListener(_WXPointer_stringify_adaptor(id), _WXPointer_stringify_adaptor(key));
}, },
WXVideoDestroy: function(id) { WXVideoDestroy: function(id, isLast) {
window.WXWASMSDK.WXVideoDestroy(_WXPointer_stringify_adaptor(id)); window.WXWASMSDK.WXVideoDestroy(_WXPointer_stringify_adaptor(id), isLast);
}, },
WXVideoExitFullScreen: function(id) { WXVideoExitFullScreen: function(id) {
window.WXWASMSDK.WXVideoExitFullScreen(_WXPointer_stringify_adaptor(id)); window.WXWASMSDK.WXVideoExitFullScreen(_WXPointer_stringify_adaptor(id));

View File

@ -115,8 +115,8 @@ WX_SyncFunction_tnn: function(functionName, returnType, param1, param2){
stringToUTF8((res || ''), buffer, bufferSize); stringToUTF8((res || ''), buffer, bufferSize);
return buffer; return buffer;
}, },
WX_ClassOneWayFunction:function(functionName, returnType, successType, failType, completeType, conf) { WX_ClassConstructor:function(functionName, returnType, successType, failType, completeType, conf) {
var res = window.WXWASMSDK.WX_ClassOneWayFunction(_WXPointer_stringify_adaptor(functionName), _WXPointer_stringify_adaptor(returnType), _WXPointer_stringify_adaptor(successType), _WXPointer_stringify_adaptor(failType), _WXPointer_stringify_adaptor(completeType), _WXPointer_stringify_adaptor(conf)); var res = window.WXWASMSDK.WX_ClassConstructor(_WXPointer_stringify_adaptor(functionName), _WXPointer_stringify_adaptor(returnType), _WXPointer_stringify_adaptor(successType), _WXPointer_stringify_adaptor(failType), _WXPointer_stringify_adaptor(completeType), _WXPointer_stringify_adaptor(conf));
var bufferSize = lengthBytesUTF8(res || '') + 1; var bufferSize = lengthBytesUTF8(res || '') + 1;
var buffer = _malloc(bufferSize); var buffer = _malloc(bufferSize);
stringToUTF8((res || ''), buffer, bufferSize); stringToUTF8((res || ''), buffer, bufferSize);
@ -156,5 +156,7 @@ WX_ClassOneWayNoFunction_vt: function(className, functionName, id, param1) {
}, },
WX_ClassOneWayNoFunction_vn: function(className, functionName, id, param1) { WX_ClassOneWayNoFunction_vn: function(className, functionName, id, param1) {
window.WXWASMSDK.WX_ClassOneWayNoFunction_vs(_WXPointer_stringify_adaptor(className), _WXPointer_stringify_adaptor(functionName), _WXPointer_stringify_adaptor(id), param1); window.WXWASMSDK.WX_ClassOneWayNoFunction_vs(_WXPointer_stringify_adaptor(className), _WXPointer_stringify_adaptor(functionName), _WXPointer_stringify_adaptor(id), param1);
},WX_ClassOneWayFunction: function(className, id, functionName, successType, failType, completeType, conf, callbackId, usePromise) {
window.WXWASMSDK.WX_ClassOneWayFunction(_WXPointer_stringify_adaptor(className), _WXPointer_stringify_adaptor(id), _WXPointer_stringify_adaptor(functionName), _WXPointer_stringify_adaptor(successType), _WXPointer_stringify_adaptor(failType), _WXPointer_stringify_adaptor(completeType), _WXPointer_stringify_adaptor(conf), _WXPointer_stringify_adaptor(callbackId), usePromise);
}, },
}) })

View File

@ -0,0 +1,55 @@
mergeInto(LibraryManager.library, {
JSStartGameDataMonitor: function() {
console.log("call JSStartGameDataMonitor \n");
if (typeof GameGlobal.manager.getGameDataMonitor === 'function')
{
GameGlobal.manager.getGameDataMonitor().start();
}
else
{
console.log("GameGlobal.manager.getGameDataMonitor is not a function \n");
}
},
JSReportUnityProfileData: function(
targetFrameRate, // fps.
monoHeapReserved, monoHeapUsed, nativeReserved, nativeUnused, nativeAllocated, // profiler.
setPassCalls, drawCalls, vertices, trianglesCount // render.
) {
console.log("call JSReportUnityProfileData \n");
let report_data = {
timestamp: new Date().getTime(),
fps: {
targetFrameRate: targetFrameRate,
avgEXFrameTime: _WXGetEXFrameTime(),
},
profiler: {
monoHeapReserved: monoHeapReserved,
monoHeapUsed: monoHeapUsed,
nativeReserved: nativeReserved,
nativeUnused: nativeUnused,
nativeAllocated: nativeAllocated,
},
render: {
setPassCalls: setPassCalls,
drawCalls: drawCalls,
vertices: vertices,
trianglesCount: trianglesCount,
},
webassembly: {
totalHeapMemory: _WXGetTotalMemorySize(),
dynamicMemory: _WXGetDynamicMemorySize(),
usedHeapMemory: _WXGetUsedMemorySize(),
unAllocatedMemory: _WXGetUnAllocatedMemorySize(),
},
assetbundle: {
numberInMemory: _WXGetBundleNumberInMemory(),
numberOnDisk: _WXGetBundleNumberOnDisk(),
sizeInMemory: _WXGetBundleSizeInMemory(),
sizeOnDisk: _WXGetBundleSizeOnDisk(),
}
}
GameGlobal.manager.getGameDataMonitor().reportUnityProfileData(report_data)
},
});

View File

@ -0,0 +1,79 @@
fileFormatVersion: 2
guid: 63a9d4fa9c3846e3704029822b94973f
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Editor: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude WeixinMiniGame: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Facebook: WebGL
second:
enabled: 0
settings: {}
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: x86_64
- first:
WebGL: WebGL
second:
enabled: 1
settings: {}
- first:
WeixinMiniGame: WeixinMiniGame
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -28,6 +28,22 @@ mergeInto(LibraryManager.library, {
GameGlobal.unityNamespace.ProfileWebgl.stopRecord(); GameGlobal.unityNamespace.ProfileWebgl.stopRecord();
} }
}, },
JSProfilerUploadBinary: function(dataPtr, bufSize, namePtr, dirPtr, id, inStartFrameIdx, inEndFrameIdx) {
//if (GameGlobal && GameGlobal.manager && GameGlobal.manager.profiler) {
const name = UTF8ToString(namePtr);
const dir = UTF8ToString(dirPtr);
const content = HEAPU8.slice(dataPtr, dataPtr+bufSize);
GameGlobal.manager.profiler.uploadBinary({
'data': content,
'len': bufSize,
'fileName': name,
'uploadDir': dir,
'id': id,
'startFrameIndex': inStartFrameIdx,
'endFrameIndex': inEndFrameIdx
});
//}
},
JSProfilerUploadString: function(dataPtr, bufSize, namePtr, dirPtr, id, inStartFrameIdx, inEndFrameIdx) { JSProfilerUploadString: function(dataPtr, bufSize, namePtr, dirPtr, id, inStartFrameIdx, inEndFrameIdx) {
//if (GameGlobal && GameGlobal.manager && GameGlobal.manager.profiler) { //if (GameGlobal && GameGlobal.manager && GameGlobal.manager.profiler) {
const name = UTF8ToString(namePtr); const name = UTF8ToString(namePtr);
@ -106,5 +122,12 @@ mergeInto(LibraryManager.library, {
stringToUTF8(GameGlobal.unityNamespace.convertPluginVersion, stringOnWasmHeap, lengthBytes); stringToUTF8(GameGlobal.unityNamespace.convertPluginVersion, stringOnWasmHeap, lengthBytes);
return stringOnWasmHeap; return stringOnWasmHeap;
},
JSProfilerCanvasToFilepathSync: function(savePath) {
if (GameGlobal && GameGlobal.unityNamespace && GameGlobal.unityNamespace.ProfileWebgl && GameGlobal.unityNamespace.ProfileWebgl.stopRecord) {
const savePathJSStr = UTF8ToString(savePath);
GameGlobal.manager.profiler.canvasToFilepathSync(savePathJSStr);
}
} }
}); });

Binary file not shown.

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: f0cbdcf50f6d52cea758f1ea825443c0 guid: ffcf22f69c45d4919a04626e60e86c20
PluginImporter: PluginImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
@ -7,68 +7,21 @@ PluginImporter:
executionOrder: {} executionOrder: {}
defineConstraints: [] defineConstraints: []
isPreloaded: 0 isPreloaded: 0
isOverridable: 1 isOverridable: 0
isExplicitlyReferenced: 0 isExplicitlyReferenced: 0
validateReferences: 1 validateReferences: 1
platformData: platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Editor: 0
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude WebGL: 0
Exclude Win: 1
Exclude Win64: 1
- first: - first:
Any: Any:
second: second:
enabled: 0 enabled: 1
settings: {} settings: {}
- first: - first:
Editor: Editor Editor: Editor
second: second:
enabled: 1 enabled: 0
settings: settings:
CPU: AnyCPU
DefaultValueInitialized: true DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: None
- first:
WebGL: WebGL
second:
enabled: 1
settings: {}
- first:
WeixinMiniGame: WeixinMiniGame
second:
enabled: 1
settings: {}
- first: - first:
Windows Store Apps: WindowsStoreApps Windows Store Apps: WindowsStoreApps
second: second:

View File

@ -1,7 +1,7 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 8ea3a597042b1e09596b698c5fcfd06b guid: 94249136b4b39434dbb3ae3f5b41f47b
DefaultImporter: TextScriptImporter:
externalObjects: {} externalObjects: {}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:

View File

@ -1699,26 +1699,6 @@
如果返回的是字符串,则数据在这个字段 如果返回的是字符串,则数据在这个字段
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.WXStatInfo.mode">
<summary>
文件的类型和存取的权限,对应 POSIX stat.st_mode
</summary>
</member>
<member name="F:WeChatWASM.WXStatInfo.size">
<summary>
文件大小单位B对应 POSIX stat.st_size
</summary>
</member>
<member name="F:WeChatWASM.WXStatInfo.lastAccessedTime">
<summary>
文件最近一次被存取或被执行的时间UNIX 时间戳,对应 POSIX stat.st_atime
</summary>
</member>
<member name="F:WeChatWASM.WXStatInfo.lastModifiedTime">
<summary>
文件最后一次被修改的时间UNIX 时间戳,对应 POSIX stat.st_mtime
</summary>
</member>
<member name="F:WeChatWASM.WXStat.path"> <member name="F:WeChatWASM.WXStat.path">
<summary> <summary>
文件的路径 文件的路径
@ -1769,116 +1749,126 @@
视频的总时长,单位为秒 视频的总时长,单位为秒
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.WXCreateVideoParam.x"> <member name="F:WeChatWASM.CreateVideoOption.src">
<summary>
视频的左上角横坐标
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.y">
<summary>
视频的左上角纵坐标
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.width">
<summary>
视频的宽度
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.height">
<summary>
视频的高度
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.src">
<summary> <summary>
视频的资源地址 视频的资源地址
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.WXCreateVideoParam.poster"> <member name="F:WeChatWASM.CreateVideoOption.autoplay">
<summary>
视频的封面
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.initialTime">
<summary>
视频的初始播放位置,单位为 s 秒
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.playbackRate">
<summary>
视频的播放速率,有效值有 0.5、0.8、1.0、1.25、1.5
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.live">
<summary>
视频是否为直播
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.objectFit">
<summary>
视频的缩放模式
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.controls">
<summary>
视频是否显示控件
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.showProgress">
<summary>
是否显示视频底部进度条
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.showProgressInControlMode">
<summary>
是否显示控制栏的进度条
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.backgroundColor">
<summary>
视频背景颜色
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.autoplay">
<summary> <summary>
视频是否自动播放 视频是否自动播放
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.WXCreateVideoParam.loop"> <member name="F:WeChatWASM.CreateVideoOption.backgroundColor">
<summary> <summary>
视频是否是否循环播放 视频背景颜色
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.WXCreateVideoParam.muted"> <member name="F:WeChatWASM.CreateVideoOption.controls">
<summary> <summary>
视频是否禁音播放 视频是否显示控件
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.WXCreateVideoParam.obeyMuteSwitch"> <member name="F:WeChatWASM.CreateVideoOption.enablePlayGesture">
<summary>
视频是否遵循系统静音开关设置仅iOS
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.enableProgressGesture">
<summary>
是否启用手势控制播放进度
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.enablePlayGesture">
<summary> <summary>
是否开启双击播放的手势 是否开启双击播放的手势
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.WXCreateVideoParam.showCenterPlayBtn"> <member name="F:WeChatWASM.CreateVideoOption.enableProgressGesture">
<summary>
是否启用手势控制播放进度
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.height">
<summary>
视频的高度
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.initialTime">
<summary>
视频的初始播放位置,单位为 s 秒
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.live">
<summary>
视频是否为直播
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.loop">
<summary>
视频是否是否循环播放
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.muted">
<summary>
视频是否禁音播放
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.obeyMuteSwitch">
<summary>
视频是否遵循系统静音开关设置仅iOS
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.objectFit">
<summary>
视频的缩放模式
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.playbackRate">
<summary>
视频的播放速率,有效值有 0.5、0.8、1.0、1.25、1.5
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.poster">
<summary>
视频的封面
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.showCenterPlayBtn">
<summary> <summary>
是否显示视频中央的播放按钮 是否显示视频中央的播放按钮
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.WXCreateVideoParam.underGameView"> <member name="F:WeChatWASM.CreateVideoOption.showProgress">
<summary>
是否显示视频底部进度条
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.showProgressInControlMode">
<summary>
是否显示控制栏的进度条
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.width">
<summary>
视频的宽度
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.x">
<summary>
视频的左上角横坐标
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.y">
<summary>
视频的左上角纵坐标
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.underGameView">
<summary> <summary>
视频是否显示在游戏画布之下 视频是否显示在游戏画布之下
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.CreateVideoOption.autoPauseIfNavigate">
<summary>
视频跳转后自动暂停播放
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.autoPauseIfOpenNative">
<summary>
视频跳转原生页后自动暂停播放
</summary>
</member>
<member name="F:WeChatWASM.EnvVersion.develop"> <member name="F:WeChatWASM.EnvVersion.develop">
<summary> <summary>
开发版 开发版
@ -3124,6 +3114,125 @@
是否成功 是否成功
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.NotifyMiniProgramPlayableStatusOption.isEnd">
<summary>
 是否结束
</summary>
</member>
<member name="F:WeChatWASM.LoadOption.openlink">
<summary>
从不同渠道获得的OPENLINK字符串
</summary>
</member>
<member name="F:WeChatWASM.LoadOption.query">
<summary>
选填部分活动、功能允许接收自定义query参数请参阅渠道说明默认可不填
</summary>
</member>
<member name="F:WeChatWASM.ShowOption.openlink">
<summary>
从不同渠道获得的OPENLINK字符串
</summary>
</member>
<member name="F:WeChatWASM.ShowOption.query">
<summary>
选填部分活动、功能允许接收自定义query参数请参阅渠道说明默认可不填
</summary>
</member>
<member name="F:WeChatWASM.VirtualPaymentError.errMsg">
错误信息
| 错误码 | 错误信息 | 说明 |
| - | - | - |
| 1001 | | 参数错误 |
| -1 | | 支付失败 |
| -2 | | 支付取消 |
| -4 | | 风控拦截 |
| -5 | | 开通签约结果未知 |
| -15001 | | 参数错误,具体原因见err_msg |
| -15002 | | outTradeNo重复使用,请换新单号重试 |
| -15003 | | 系统错误 |
| -15004 | | currencyType错误,目前只能填CNY |
| -15005 | | 用户态签名signature错误 |
| -15006 | | 支付签名paySig错误 |
| -15007 | | session_key过期 |
| -15008 | | 二级商户进件未完成 |
| -15009 | | 代币未发布 |
| -15010 | | 道具productId未发布 |
| -15011 | | 现网版本的env只能是0,不能填1(沙盒环境) |
| -15012 | | 调用米大师失败导致关单,请换新单号重试 |
| -15013 | | goodsPrice道具价格错误 |
| -15014 | | 道具/代币发布未生效禁止下单大概10分钟后生效 |
| -15016 | | signData格式有问题 |
| -15017 | | 此商家涉嫌违规,收款功能已被限制,暂无法支付。商家可以登录微信商户平台/微信支付商家助手小程序查看原因和解决方案 |
| -15018 | | 代币或者道具productId审核不通过 |
| -15019 | | 调微信报商户受限,商家可以登录微信商户平台/微信支付商家助手小程序查看原因和解决方案 |
| -15020 | | 操作过快,请稍候再试 |
| -15021 | | 小程序被限频交易 |
</member>
<member name="F:WeChatWASM.VirtualPaymentError.errCode">
错误码
| 错误码 | 错误信息 | 说明 |
| - | - | - |
| 1001 | | 参数错误 |
| -1 | | 支付失败 |
| -2 | | 支付取消 |
| -4 | | 风控拦截 |
| -5 | | 开通签约结果未知 |
| -15001 | | 参数错误,具体原因见err_msg |
| -15002 | | outTradeNo重复使用,请换新单号重试 |
| -15003 | | 系统错误 |
| -15004 | | currencyType错误,目前只能填CNY |
| -15005 | | 用户态签名signature错误 |
| -15006 | | 支付签名paySig错误 |
| -15007 | | session_key过期 |
| -15008 | | 二级商户进件未完成 |
| -15009 | | 代币未发布 |
| -15010 | | 道具productId未发布 |
| -15011 | | 现网版本的env只能是0,不能填1(沙盒环境) |
| -15012 | | 调用米大师失败导致关单,请换新单号重试 |
| -15013 | | goodsPrice道具价格错误 |
| -15014 | | 道具/代币发布未生效禁止下单大概10分钟后生效 |
| -15016 | | signData格式有问题 |
| -15017 | | 此商家涉嫌违规,收款功能已被限制,暂无法支付。商家可以登录微信商户平台/微信支付商家助手小程序查看原因和解决方案 |
| -15018 | | 代币或者道具productId审核不通过 |
| -15019 | | 调微信报商户受限,商家可以登录微信商户平台/微信支付商家助手小程序查看原因和解决方案 |
| -15020 | | 操作过快,请稍候再试 |
| -15021 | | 小程序被限频交易 |
</member>
<member name="F:WeChatWASM.RequestVirtualPaymentFailCallbackErr.errCode">
错误码
</member>
<member name="F:WeChatWASM.RequestVirtualPaymentFailCallbackErr.errMsg">
错误信息
</member>
<member name="F:WeChatWASM.RequestCommonPaymentSuccessCallbackResult.errMsg">
调用成功信息
</member>
<member name="F:WeChatWASM.RequestVirtualPaymentOption.mode">
<summary>
支付的类型, 不同的支付类型有各自额外要传的附加参数
可选值:
- 'short_series_goods': 道具直购;
- 'short_series_coin': 代币充值;
</summary>
</member>
<member name="F:WeChatWASM.RequestVirtualPaymentOption.paySig">
<summary>
支付签名, 详见[《签名详解》](https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/virtual-payment.html)
</summary>
</member>
<member name="F:WeChatWASM.RequestVirtualPaymentOption.signData">
<summary>
具体支付参数见signData, 该参数需以string形式传递, 例如signData: '{"offerId":"123","buyQuantity":1,"env":0,"currencyType":"CNY","productId":"testproductId","goodsPrice":10,"outTradeNo":"xxxxxx","attach":"testdata"}'
</summary>
</member>
<member name="F:WeChatWASM.RequestVirtualPaymentOption.signature">
<summary>
用户态签名, 详见[《签名详解》](https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/virtual-payment.html)
</summary>
</member>
<member name="F:WeChatWASM.Gamepad.axes"> <member name="F:WeChatWASM.Gamepad.axes">
<summary> <summary>
一个表示控制器设备上存在的坐标轴的数组 (比如控制器摇杆)。 一个表示控制器设备上存在的坐标轴的数组 (比如控制器摇杆)。
@ -4118,26 +4227,6 @@
取值为0/1取值为0表示会把 `App`、`Page` 的生命周期函数和 `wx` 命名空间下的函数调用写入日志取值为1则不会。默认值是 0 取值为0/1取值为0表示会把 `App`、`Page` 的生命周期函数和 `wx` 命名空间下的函数调用写入日志取值为1则不会。默认值是 0
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.LoadOption.openlink">
<summary>
从不同渠道获得的OPENLINK字符串
</summary>
</member>
<member name="F:WeChatWASM.LoadOption.query">
<summary>
选填部分活动、功能允许接收自定义query参数请参阅渠道说明默认可不填
</summary>
</member>
<member name="F:WeChatWASM.ShowOption.openlink">
<summary>
从不同渠道获得的OPENLINK字符串
</summary>
</member>
<member name="F:WeChatWASM.ShowOption.query">
<summary>
选填部分活动、功能允许接收自定义query参数请参阅渠道说明默认可不填
</summary>
</member>
<member name="F:WeChatWASM.OnCheckForUpdateListenerResult.hasUpdate"> <member name="F:WeChatWASM.OnCheckForUpdateListenerResult.hasUpdate">
<summary> <summary>
是否有新版本 是否有新版本
@ -8524,22 +8613,44 @@
显示用户信息按钮 显示用户信息按钮
</summary> </summary>
</member> </member>
<member name="T:WeChatWASM.WXVideo">
<summary>
微信小游戏视频组件
</summary>
</member>
<member name="F:WeChatWASM.WXVideo._Dict">
<summary>
视频实例字典 (内部使用,请不要访问)
</summary>
</member>
<member name="F:WeChatWASM.WXVideo.instanceId">
<summary>
视频实例ID
</summary>
</member>
<member name="F:WeChatWASM.WXVideo.param">
<summary>
视频创建参数
</summary>
</member>
<member name="M:WeChatWASM.WXVideo.#ctor(System.String,WeChatWASM.CreateVideoOption)">
<summary>
创建视频实例
</summary>
<param name="id">实例ID</param>
<param name="param">创建参数</param>
</member>
<member name="M:WeChatWASM.WXVideo.InitializeProperties">
<summary>
初始化属性
</summary>
</member>
<member name="M:WeChatWASM.WXVideo._HandleCallBack(WeChatWASM.WXVideoCallback)"> <member name="M:WeChatWASM.WXVideo._HandleCallBack(WeChatWASM.WXVideoCallback)">
<summary> <summary>
内部函数,请不要调用 内部函数,请不要调用
</summary> </summary>
<param name="key"></param> <param name="key"></param>
</member> </member>
<member name="P:WeChatWASM.WXVideo.src">
<summary>
视频的资源地址
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.poster">
<summary>
视频的封面
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.x"> <member name="P:WeChatWASM.WXVideo.x">
<summary> <summary>
视频的左上角横坐标 视频的左上角横坐标
@ -8560,9 +8671,69 @@
视频的高度 视频的高度
</summary> </summary>
</member> </member>
<member name="P:WeChatWASM.WXVideo.isPlaying"> <member name="P:WeChatWASM.WXVideo.src">
<summary> <summary>
Gets a value indicating whether 是否正在播放 视频的资源地址
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.poster">
<summary>
视频的封面
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.live">
<summary>
是否为直播
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.objectFit">
<summary>
当视频大小与 video 容器大小不一致时,视频的表现形式
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.controls">
<summary>
是否显示默认播放控件(播放/暂停按钮、播放进度、时间)
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.showProgress">
<summary>
是否显示播放进度
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.showProgressInControlMode">
<summary>
在非全屏模式下,是否开启亮度和音量调节手势
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.backgroundColor">
<summary>
视频的背景色
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.obeyMuteSwitch">
<summary>
是否遵循系统静音开关
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.enableProgressGesture">
<summary>
是否开启控制进度的手势
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.enablePlayGesture">
<summary>
是否开启播放手势
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.showCenterPlayBtn">
<summary>
是否显示视频中间的播放按钮
</summary>
</member>
<member name="M:WeChatWASM.WXVideo.Destroy">
<summary>
销毁当前实例
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.Play"> <member name="M:WeChatWASM.WXVideo.Play">
@ -8570,44 +8741,31 @@
播放视频 播放视频
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.OnPlay(System.Action)"> <member name="M:WeChatWASM.WXVideo.Pause">
<summary> <summary>
监听视频播放事件 暂停
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.OffPlay(System.Action)"> <member name="M:WeChatWASM.WXVideo.Stop">
<summary> <summary>
取消监听视频播放事件,action 为空表示移除全部事件监听 停止视频
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.OnEnded(System.Action)"> <member name="M:WeChatWASM.WXVideo.Seek(System.Int32)">
<summary> <summary>
监听视频播放到末尾事件 视频跳转
</summary> </summary>
<param name="time">视频跳转到指定位置,单位为 s 秒</param>
</member> </member>
<member name="M:WeChatWASM.WXVideo.OffEnded(System.Action)"> <member name="M:WeChatWASM.WXVideo.RequestFullScreen(System.Int32)">
<summary> <summary>
取消监听视频播放到末尾事件 视频全屏
</summary> </summary>
<param name="direction">设置全屏时视频的方向 0: 正常竖向, 90: 屏幕逆时针90度 . -90: 屏幕顺时针90度</param>
</member> </member>
<member name="M:WeChatWASM.WXVideo.OnError(System.Action)"> <member name="M:WeChatWASM.WXVideo.ExitFullScreen">
<summary> <summary>
监听视频错误事件 视频退出全屏
</summary>
</member>
<member name="M:WeChatWASM.WXVideo.OffError(System.Action)">
<summary>
取消监听视频错误事件,action 为空表示移除全部事件监听
</summary>
</member>
<member name="M:WeChatWASM.WXVideo.OnPause(System.Action)">
<summary>
监听视频暂停事件
</summary>
</member>
<member name="M:WeChatWASM.WXVideo.OffPause(System.Action)">
<summary>
取消监听视频暂停事件,action 为空表示移除全部事件监听
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.OnWaiting(System.Action)"> <member name="M:WeChatWASM.WXVideo.OnWaiting(System.Action)">
@ -8620,36 +8778,45 @@
取消监听视频由于需要缓冲下一帧而停止时触发,action 为空表示移除全部事件监听 取消监听视频由于需要缓冲下一帧而停止时触发,action 为空表示移除全部事件监听
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.Destroy"> <member name="M:WeChatWASM.WXVideo.OnProgress(System.Action{WeChatWASM.WXVideoProgress})">
<summary> <summary>
销毁当前实例 监听视频下载(缓冲)事件
</summary>
<param name="action"></param>
</member>
<member name="M:WeChatWASM.WXVideo.OffProgress(System.Action{WeChatWASM.WXVideoProgress})">
<summary>
取消监听视频下载(缓冲)事件 ,action 为空表示移除全部事件监听
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.ExitFullScreen"> <member name="M:WeChatWASM.WXVideo.OnPlay(System.Action)">
<summary> <summary>
视频退出全屏 监听视频播放事件
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.Pause"> <member name="M:WeChatWASM.WXVideo.OffPlay(System.Action)">
<summary> <summary>
暂停 取消监听视频播放事件,action 为空表示移除全部事件监听
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.RequestFullScreen(System.Int32)"> <member name="M:WeChatWASM.WXVideo.OnPause(System.Action)">
<summary> <summary>
视频全屏 监听视频暂停事件
</summary> </summary>
<param name="direction">设置全屏时视频的方向 0: 正常竖向, 90: 屏幕逆时针90度 . -90: 屏幕顺时针90度</param>
</member> </member>
<member name="M:WeChatWASM.WXVideo.Seek(System.Int32)"> <member name="M:WeChatWASM.WXVideo.OffPause(System.Action)">
<summary> <summary>
视频跳转 取消监听视频暂停事件,action 为空表示移除全部事件监听
</summary> </summary>
<param name="time">视频跳转到指定位置,单位为 s 秒</param>
</member> </member>
<member name="M:WeChatWASM.WXVideo.Stop"> <member name="M:WeChatWASM.WXVideo.OnEnded(System.Action)">
<summary> <summary>
停止视频 监听视频播放到末尾事件
</summary>
</member>
<member name="M:WeChatWASM.WXVideo.OffEnded(System.Action)">
<summary>
取消监听视频播放到末尾事件
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.OnTimeUpdate(System.Action{WeChatWASM.WXVideoTimeUpdate})"> <member name="M:WeChatWASM.WXVideo.OnTimeUpdate(System.Action{WeChatWASM.WXVideoTimeUpdate})">
@ -8663,15 +8830,14 @@
取消监听视频播放进度更新事件,action 为空表示移除全部事件监听 取消监听视频播放进度更新事件,action 为空表示移除全部事件监听
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.OnProgress(System.Action{WeChatWASM.WXVideoProgress})"> <member name="M:WeChatWASM.WXVideo.OnError(System.Action{WeChatWASM.WXVideoError})">
<summary> <summary>
监听视频下载(缓冲)事件 监听视频错误事件
</summary> </summary>
<param name="action"></param>
</member> </member>
<member name="M:WeChatWASM.WXVideo.OffProgress(System.Action{WeChatWASM.WXVideoProgress})"> <member name="M:WeChatWASM.WXVideo.OffError(System.Action{WeChatWASM.WXVideoError})">
<summary> <summary>
取消监听视频下载(缓冲)事件 ,action 为空表示移除全部事件监听 取消监听视频错误事件,action 为空表示移除全部事件监听
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideoDecoder.GetFrameData"> <member name="M:WeChatWASM.WXVideoDecoder.GetFrameData">

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 3858caedcbc1a4f44f11b304f5ea093e guid: 882bc04407b4d8217e597652f26bfb81
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
userData: userData:

Binary file not shown.

View File

@ -1705,26 +1705,6 @@
如果返回的是字符串,则数据在这个字段 如果返回的是字符串,则数据在这个字段
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.WXStatInfo.mode">
<summary>
文件的类型和存取的权限,对应 POSIX stat.st_mode
</summary>
</member>
<member name="F:WeChatWASM.WXStatInfo.size">
<summary>
文件大小单位B对应 POSIX stat.st_size
</summary>
</member>
<member name="F:WeChatWASM.WXStatInfo.lastAccessedTime">
<summary>
文件最近一次被存取或被执行的时间UNIX 时间戳,对应 POSIX stat.st_atime
</summary>
</member>
<member name="F:WeChatWASM.WXStatInfo.lastModifiedTime">
<summary>
文件最后一次被修改的时间UNIX 时间戳,对应 POSIX stat.st_mtime
</summary>
</member>
<member name="F:WeChatWASM.WXStat.path"> <member name="F:WeChatWASM.WXStat.path">
<summary> <summary>
文件的路径 文件的路径
@ -1775,116 +1755,126 @@
视频的总时长,单位为秒 视频的总时长,单位为秒
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.WXCreateVideoParam.x"> <member name="F:WeChatWASM.CreateVideoOption.src">
<summary>
视频的左上角横坐标
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.y">
<summary>
视频的左上角纵坐标
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.width">
<summary>
视频的宽度
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.height">
<summary>
视频的高度
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.src">
<summary> <summary>
视频的资源地址 视频的资源地址
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.WXCreateVideoParam.poster"> <member name="F:WeChatWASM.CreateVideoOption.autoplay">
<summary>
视频的封面
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.initialTime">
<summary>
视频的初始播放位置,单位为 s 秒
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.playbackRate">
<summary>
视频的播放速率,有效值有 0.5、0.8、1.0、1.25、1.5
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.live">
<summary>
视频是否为直播
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.objectFit">
<summary>
视频的缩放模式
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.controls">
<summary>
视频是否显示控件
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.showProgress">
<summary>
是否显示视频底部进度条
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.showProgressInControlMode">
<summary>
是否显示控制栏的进度条
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.backgroundColor">
<summary>
视频背景颜色
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.autoplay">
<summary> <summary>
视频是否自动播放 视频是否自动播放
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.WXCreateVideoParam.loop"> <member name="F:WeChatWASM.CreateVideoOption.backgroundColor">
<summary> <summary>
视频是否是否循环播放 视频背景颜色
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.WXCreateVideoParam.muted"> <member name="F:WeChatWASM.CreateVideoOption.controls">
<summary> <summary>
视频是否禁音播放 视频是否显示控件
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.WXCreateVideoParam.obeyMuteSwitch"> <member name="F:WeChatWASM.CreateVideoOption.enablePlayGesture">
<summary>
视频是否遵循系统静音开关设置仅iOS
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.enableProgressGesture">
<summary>
是否启用手势控制播放进度
</summary>
</member>
<member name="F:WeChatWASM.WXCreateVideoParam.enablePlayGesture">
<summary> <summary>
是否开启双击播放的手势 是否开启双击播放的手势
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.WXCreateVideoParam.showCenterPlayBtn"> <member name="F:WeChatWASM.CreateVideoOption.enableProgressGesture">
<summary>
是否启用手势控制播放进度
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.height">
<summary>
视频的高度
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.initialTime">
<summary>
视频的初始播放位置,单位为 s 秒
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.live">
<summary>
视频是否为直播
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.loop">
<summary>
视频是否是否循环播放
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.muted">
<summary>
视频是否禁音播放
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.obeyMuteSwitch">
<summary>
视频是否遵循系统静音开关设置仅iOS
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.objectFit">
<summary>
视频的缩放模式
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.playbackRate">
<summary>
视频的播放速率,有效值有 0.5、0.8、1.0、1.25、1.5
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.poster">
<summary>
视频的封面
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.showCenterPlayBtn">
<summary> <summary>
是否显示视频中央的播放按钮 是否显示视频中央的播放按钮
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.WXCreateVideoParam.underGameView"> <member name="F:WeChatWASM.CreateVideoOption.showProgress">
<summary>
是否显示视频底部进度条
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.showProgressInControlMode">
<summary>
是否显示控制栏的进度条
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.width">
<summary>
视频的宽度
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.x">
<summary>
视频的左上角横坐标
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.y">
<summary>
视频的左上角纵坐标
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.underGameView">
<summary> <summary>
视频是否显示在游戏画布之下 视频是否显示在游戏画布之下
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.CreateVideoOption.autoPauseIfNavigate">
<summary>
视频跳转后自动暂停播放
</summary>
</member>
<member name="F:WeChatWASM.CreateVideoOption.autoPauseIfOpenNative">
<summary>
视频跳转原生页后自动暂停播放
</summary>
</member>
<member name="F:WeChatWASM.EnvVersion.develop"> <member name="F:WeChatWASM.EnvVersion.develop">
<summary> <summary>
开发版 开发版
@ -3130,6 +3120,125 @@
是否成功 是否成功
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.NotifyMiniProgramPlayableStatusOption.isEnd">
<summary>
 是否结束
</summary>
</member>
<member name="F:WeChatWASM.LoadOption.openlink">
<summary>
从不同渠道获得的OPENLINK字符串
</summary>
</member>
<member name="F:WeChatWASM.LoadOption.query">
<summary>
选填部分活动、功能允许接收自定义query参数请参阅渠道说明默认可不填
</summary>
</member>
<member name="F:WeChatWASM.ShowOption.openlink">
<summary>
从不同渠道获得的OPENLINK字符串
</summary>
</member>
<member name="F:WeChatWASM.ShowOption.query">
<summary>
选填部分活动、功能允许接收自定义query参数请参阅渠道说明默认可不填
</summary>
</member>
<member name="F:WeChatWASM.VirtualPaymentError.errMsg">
错误信息
| 错误码 | 错误信息 | 说明 |
| - | - | - |
| 1001 | | 参数错误 |
| -1 | | 支付失败 |
| -2 | | 支付取消 |
| -4 | | 风控拦截 |
| -5 | | 开通签约结果未知 |
| -15001 | | 参数错误,具体原因见err_msg |
| -15002 | | outTradeNo重复使用,请换新单号重试 |
| -15003 | | 系统错误 |
| -15004 | | currencyType错误,目前只能填CNY |
| -15005 | | 用户态签名signature错误 |
| -15006 | | 支付签名paySig错误 |
| -15007 | | session_key过期 |
| -15008 | | 二级商户进件未完成 |
| -15009 | | 代币未发布 |
| -15010 | | 道具productId未发布 |
| -15011 | | 现网版本的env只能是0,不能填1(沙盒环境) |
| -15012 | | 调用米大师失败导致关单,请换新单号重试 |
| -15013 | | goodsPrice道具价格错误 |
| -15014 | | 道具/代币发布未生效禁止下单大概10分钟后生效 |
| -15016 | | signData格式有问题 |
| -15017 | | 此商家涉嫌违规,收款功能已被限制,暂无法支付。商家可以登录微信商户平台/微信支付商家助手小程序查看原因和解决方案 |
| -15018 | | 代币或者道具productId审核不通过 |
| -15019 | | 调微信报商户受限,商家可以登录微信商户平台/微信支付商家助手小程序查看原因和解决方案 |
| -15020 | | 操作过快,请稍候再试 |
| -15021 | | 小程序被限频交易 |
</member>
<member name="F:WeChatWASM.VirtualPaymentError.errCode">
错误码
| 错误码 | 错误信息 | 说明 |
| - | - | - |
| 1001 | | 参数错误 |
| -1 | | 支付失败 |
| -2 | | 支付取消 |
| -4 | | 风控拦截 |
| -5 | | 开通签约结果未知 |
| -15001 | | 参数错误,具体原因见err_msg |
| -15002 | | outTradeNo重复使用,请换新单号重试 |
| -15003 | | 系统错误 |
| -15004 | | currencyType错误,目前只能填CNY |
| -15005 | | 用户态签名signature错误 |
| -15006 | | 支付签名paySig错误 |
| -15007 | | session_key过期 |
| -15008 | | 二级商户进件未完成 |
| -15009 | | 代币未发布 |
| -15010 | | 道具productId未发布 |
| -15011 | | 现网版本的env只能是0,不能填1(沙盒环境) |
| -15012 | | 调用米大师失败导致关单,请换新单号重试 |
| -15013 | | goodsPrice道具价格错误 |
| -15014 | | 道具/代币发布未生效禁止下单大概10分钟后生效 |
| -15016 | | signData格式有问题 |
| -15017 | | 此商家涉嫌违规,收款功能已被限制,暂无法支付。商家可以登录微信商户平台/微信支付商家助手小程序查看原因和解决方案 |
| -15018 | | 代币或者道具productId审核不通过 |
| -15019 | | 调微信报商户受限,商家可以登录微信商户平台/微信支付商家助手小程序查看原因和解决方案 |
| -15020 | | 操作过快,请稍候再试 |
| -15021 | | 小程序被限频交易 |
</member>
<member name="F:WeChatWASM.RequestVirtualPaymentFailCallbackErr.errCode">
错误码
</member>
<member name="F:WeChatWASM.RequestVirtualPaymentFailCallbackErr.errMsg">
错误信息
</member>
<member name="F:WeChatWASM.RequestCommonPaymentSuccessCallbackResult.errMsg">
调用成功信息
</member>
<member name="F:WeChatWASM.RequestVirtualPaymentOption.mode">
<summary>
支付的类型, 不同的支付类型有各自额外要传的附加参数
可选值:
- 'short_series_goods': 道具直购;
- 'short_series_coin': 代币充值;
</summary>
</member>
<member name="F:WeChatWASM.RequestVirtualPaymentOption.paySig">
<summary>
支付签名, 详见[《签名详解》](https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/virtual-payment.html)
</summary>
</member>
<member name="F:WeChatWASM.RequestVirtualPaymentOption.signData">
<summary>
具体支付参数见signData, 该参数需以string形式传递, 例如signData: '{"offerId":"123","buyQuantity":1,"env":0,"currencyType":"CNY","productId":"testproductId","goodsPrice":10,"outTradeNo":"xxxxxx","attach":"testdata"}'
</summary>
</member>
<member name="F:WeChatWASM.RequestVirtualPaymentOption.signature">
<summary>
用户态签名, 详见[《签名详解》](https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/virtual-payment.html)
</summary>
</member>
<member name="F:WeChatWASM.Gamepad.axes"> <member name="F:WeChatWASM.Gamepad.axes">
<summary> <summary>
一个表示控制器设备上存在的坐标轴的数组 (比如控制器摇杆)。 一个表示控制器设备上存在的坐标轴的数组 (比如控制器摇杆)。
@ -4124,26 +4233,6 @@
取值为0/1取值为0表示会把 `App`、`Page` 的生命周期函数和 `wx` 命名空间下的函数调用写入日志取值为1则不会。默认值是 0 取值为0/1取值为0表示会把 `App`、`Page` 的生命周期函数和 `wx` 命名空间下的函数调用写入日志取值为1则不会。默认值是 0
</summary> </summary>
</member> </member>
<member name="F:WeChatWASM.LoadOption.openlink">
<summary>
从不同渠道获得的OPENLINK字符串
</summary>
</member>
<member name="F:WeChatWASM.LoadOption.query">
<summary>
选填部分活动、功能允许接收自定义query参数请参阅渠道说明默认可不填
</summary>
</member>
<member name="F:WeChatWASM.ShowOption.openlink">
<summary>
从不同渠道获得的OPENLINK字符串
</summary>
</member>
<member name="F:WeChatWASM.ShowOption.query">
<summary>
选填部分活动、功能允许接收自定义query参数请参阅渠道说明默认可不填
</summary>
</member>
<member name="F:WeChatWASM.OnCheckForUpdateListenerResult.hasUpdate"> <member name="F:WeChatWASM.OnCheckForUpdateListenerResult.hasUpdate">
<summary> <summary>
是否有新版本 是否有新版本
@ -8530,22 +8619,44 @@
显示用户信息按钮 显示用户信息按钮
</summary> </summary>
</member> </member>
<member name="T:WeChatWASM.WXVideo">
<summary>
微信小游戏视频组件
</summary>
</member>
<member name="F:WeChatWASM.WXVideo._Dict">
<summary>
视频实例字典 (内部使用,请不要访问)
</summary>
</member>
<member name="F:WeChatWASM.WXVideo.instanceId">
<summary>
视频实例ID
</summary>
</member>
<member name="F:WeChatWASM.WXVideo.param">
<summary>
视频创建参数
</summary>
</member>
<member name="M:WeChatWASM.WXVideo.#ctor(System.String,WeChatWASM.CreateVideoOption)">
<summary>
创建视频实例
</summary>
<param name="id">实例ID</param>
<param name="param">创建参数</param>
</member>
<member name="M:WeChatWASM.WXVideo.InitializeProperties">
<summary>
初始化属性
</summary>
</member>
<member name="M:WeChatWASM.WXVideo._HandleCallBack(WeChatWASM.WXVideoCallback)"> <member name="M:WeChatWASM.WXVideo._HandleCallBack(WeChatWASM.WXVideoCallback)">
<summary> <summary>
内部函数,请不要调用 内部函数,请不要调用
</summary> </summary>
<param name="key"></param> <param name="key"></param>
</member> </member>
<member name="P:WeChatWASM.WXVideo.src">
<summary>
视频的资源地址
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.poster">
<summary>
视频的封面
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.x"> <member name="P:WeChatWASM.WXVideo.x">
<summary> <summary>
视频的左上角横坐标 视频的左上角横坐标
@ -8566,9 +8677,69 @@
视频的高度 视频的高度
</summary> </summary>
</member> </member>
<member name="P:WeChatWASM.WXVideo.isPlaying"> <member name="P:WeChatWASM.WXVideo.src">
<summary> <summary>
Gets a value indicating whether 是否正在播放 视频的资源地址
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.poster">
<summary>
视频的封面
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.live">
<summary>
是否为直播
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.objectFit">
<summary>
当视频大小与 video 容器大小不一致时,视频的表现形式
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.controls">
<summary>
是否显示默认播放控件(播放/暂停按钮、播放进度、时间)
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.showProgress">
<summary>
是否显示播放进度
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.showProgressInControlMode">
<summary>
在非全屏模式下,是否开启亮度和音量调节手势
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.backgroundColor">
<summary>
视频的背景色
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.obeyMuteSwitch">
<summary>
是否遵循系统静音开关
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.enableProgressGesture">
<summary>
是否开启控制进度的手势
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.enablePlayGesture">
<summary>
是否开启播放手势
</summary>
</member>
<member name="P:WeChatWASM.WXVideo.showCenterPlayBtn">
<summary>
是否显示视频中间的播放按钮
</summary>
</member>
<member name="M:WeChatWASM.WXVideo.Destroy">
<summary>
销毁当前实例
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.Play"> <member name="M:WeChatWASM.WXVideo.Play">
@ -8576,44 +8747,31 @@
播放视频 播放视频
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.OnPlay(System.Action)"> <member name="M:WeChatWASM.WXVideo.Pause">
<summary> <summary>
监听视频播放事件 暂停
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.OffPlay(System.Action)"> <member name="M:WeChatWASM.WXVideo.Stop">
<summary> <summary>
取消监听视频播放事件,action 为空表示移除全部事件监听 停止视频
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.OnEnded(System.Action)"> <member name="M:WeChatWASM.WXVideo.Seek(System.Int32)">
<summary> <summary>
监听视频播放到末尾事件 视频跳转
</summary> </summary>
<param name="time">视频跳转到指定位置,单位为 s 秒</param>
</member> </member>
<member name="M:WeChatWASM.WXVideo.OffEnded(System.Action)"> <member name="M:WeChatWASM.WXVideo.RequestFullScreen(System.Int32)">
<summary> <summary>
取消监听视频播放到末尾事件 视频全屏
</summary> </summary>
<param name="direction">设置全屏时视频的方向 0: 正常竖向, 90: 屏幕逆时针90度 . -90: 屏幕顺时针90度</param>
</member> </member>
<member name="M:WeChatWASM.WXVideo.OnError(System.Action)"> <member name="M:WeChatWASM.WXVideo.ExitFullScreen">
<summary> <summary>
监听视频错误事件 视频退出全屏
</summary>
</member>
<member name="M:WeChatWASM.WXVideo.OffError(System.Action)">
<summary>
取消监听视频错误事件,action 为空表示移除全部事件监听
</summary>
</member>
<member name="M:WeChatWASM.WXVideo.OnPause(System.Action)">
<summary>
监听视频暂停事件
</summary>
</member>
<member name="M:WeChatWASM.WXVideo.OffPause(System.Action)">
<summary>
取消监听视频暂停事件,action 为空表示移除全部事件监听
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.OnWaiting(System.Action)"> <member name="M:WeChatWASM.WXVideo.OnWaiting(System.Action)">
@ -8626,36 +8784,45 @@
取消监听视频由于需要缓冲下一帧而停止时触发,action 为空表示移除全部事件监听 取消监听视频由于需要缓冲下一帧而停止时触发,action 为空表示移除全部事件监听
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.Destroy"> <member name="M:WeChatWASM.WXVideo.OnProgress(System.Action{WeChatWASM.WXVideoProgress})">
<summary> <summary>
销毁当前实例 监听视频下载(缓冲)事件
</summary>
<param name="action"></param>
</member>
<member name="M:WeChatWASM.WXVideo.OffProgress(System.Action{WeChatWASM.WXVideoProgress})">
<summary>
取消监听视频下载(缓冲)事件 ,action 为空表示移除全部事件监听
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.ExitFullScreen"> <member name="M:WeChatWASM.WXVideo.OnPlay(System.Action)">
<summary> <summary>
视频退出全屏 监听视频播放事件
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.Pause"> <member name="M:WeChatWASM.WXVideo.OffPlay(System.Action)">
<summary> <summary>
暂停 取消监听视频播放事件,action 为空表示移除全部事件监听
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.RequestFullScreen(System.Int32)"> <member name="M:WeChatWASM.WXVideo.OnPause(System.Action)">
<summary> <summary>
视频全屏 监听视频暂停事件
</summary> </summary>
<param name="direction">设置全屏时视频的方向 0: 正常竖向, 90: 屏幕逆时针90度 . -90: 屏幕顺时针90度</param>
</member> </member>
<member name="M:WeChatWASM.WXVideo.Seek(System.Int32)"> <member name="M:WeChatWASM.WXVideo.OffPause(System.Action)">
<summary> <summary>
视频跳转 取消监听视频暂停事件,action 为空表示移除全部事件监听
</summary> </summary>
<param name="time">视频跳转到指定位置,单位为 s 秒</param>
</member> </member>
<member name="M:WeChatWASM.WXVideo.Stop"> <member name="M:WeChatWASM.WXVideo.OnEnded(System.Action)">
<summary> <summary>
停止视频 监听视频播放到末尾事件
</summary>
</member>
<member name="M:WeChatWASM.WXVideo.OffEnded(System.Action)">
<summary>
取消监听视频播放到末尾事件
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.OnTimeUpdate(System.Action{WeChatWASM.WXVideoTimeUpdate})"> <member name="M:WeChatWASM.WXVideo.OnTimeUpdate(System.Action{WeChatWASM.WXVideoTimeUpdate})">
@ -8669,15 +8836,14 @@
取消监听视频播放进度更新事件,action 为空表示移除全部事件监听 取消监听视频播放进度更新事件,action 为空表示移除全部事件监听
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideo.OnProgress(System.Action{WeChatWASM.WXVideoProgress})"> <member name="M:WeChatWASM.WXVideo.OnError(System.Action{WeChatWASM.WXVideoError})">
<summary> <summary>
监听视频下载(缓冲)事件 监听视频错误事件
</summary> </summary>
<param name="action"></param>
</member> </member>
<member name="M:WeChatWASM.WXVideo.OffProgress(System.Action{WeChatWASM.WXVideoProgress})"> <member name="M:WeChatWASM.WXVideo.OffError(System.Action{WeChatWASM.WXVideoError})">
<summary> <summary>
取消监听视频下载(缓冲)事件 ,action 为空表示移除全部事件监听 取消监听视频错误事件,action 为空表示移除全部事件监听
</summary> </summary>
</member> </member>
<member name="M:WeChatWASM.WXVideoDecoder.GetFrameData"> <member name="M:WeChatWASM.WXVideoDecoder.GetFrameData">

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 50ff4b8f462c1b5747fef46a41c31874 guid: 1adef893b0fe955b2dbd96ac1c601d6e
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
userData: userData:

Binary file not shown.

Binary file not shown.

View File

@ -4036,32 +4036,6 @@ namespace WeChatWASM
return WXSDKManagerHandler.Instance.GetLogManager(option); return WXSDKManagerHandler.Instance.GetLogManager(option);
} }
/// <summary>
/// [[PageManager](https://developers.weixin.qq.com/minigame/dev/api/open-api/openlink/PageManager.html) wx.createPageManager()](https://developers.weixin.qq.com/minigame/dev/api/open-api/openlink/wx.createPageManager.html)
/// 需要基础库: `3.6.7`
/// 小游戏开放页面管理器用于启动微信内置的各种小游戏活动、功能页面。具体OPENLINK值由不同的能力渠道获得。
/// **示例代码**
/// ```js
/// const pageManager = wx.createPageManager();
/// pageManager.load({
/// openlink: 'xxxxxxx-xxxxxx', // 由不同渠道获得的OPENLINK值
/// }).then((res) => {
/// // 加载成功res 可能携带不同活动、功能返回的特殊回包信息(具体请参阅渠道说明)
/// console.log(res);
/// // 加载成功后按需显示
/// pageManager.show();
/// }).catch((err) => {
/// // 加载失败,请查阅 err 给出的错误信息
/// console.error(err);
/// })
/// ```
/// </summary>
/// <returns></returns>
public static WXPageManager CreatePageManager()
{
return WXSDKManagerHandler.Instance.CreatePageManager();
}
/// <summary> /// <summary>
/// [[RealtimeLogManager](https://developers.weixin.qq.com/minigame/dev/api/base/debug/RealtimeLogManager.html) wx.getRealtimeLogManager()](https://developers.weixin.qq.com/minigame/dev/api/base/debug/wx.getRealtimeLogManager.html) /// [[RealtimeLogManager](https://developers.weixin.qq.com/minigame/dev/api/base/debug/RealtimeLogManager.html) wx.getRealtimeLogManager()](https://developers.weixin.qq.com/minigame/dev/api/base/debug/wx.getRealtimeLogManager.html)
/// 需要基础库: `2.14.4` /// 需要基础库: `2.14.4`

View File

@ -535,7 +535,7 @@ namespace WeChatWASM
/// </summary> /// </summary>
/// <param name="param"></param> /// <param name="param"></param>
/// <returns></returns> /// <returns></returns>
public static WXVideo CreateVideo(WXCreateVideoParam param) public static WXVideo CreateVideo(CreateVideoOption param)
{ {
return WXSDKManagerHandler.Instance.CreateVideo(param); return WXSDKManagerHandler.Instance.CreateVideo(param);
} }
@ -1117,6 +1117,51 @@ namespace WeChatWASM
{ {
WXSDKManagerHandler.Instance.ReserveChannelsLive(option); WXSDKManagerHandler.Instance.ReserveChannelsLive(option);
} }
#region
/// <summary>
/// 通知试玩结束
/// </summary>
/// <param name="option"></param>
public static void NotifyMiniProgramPlayableStatus(NotifyMiniProgramPlayableStatusOption option)
{
WXSDKManagerHandler.Instance.NotifyMiniProgramPlayableStatus(option);
}
#endregion
#region
/// <summary>
/// 请求虚拟支付
/// </summary>
public static void RequestVirtualPayment(RequestVirtualPaymentOption option)
{
WXSDKManagerHandler.Instance.RequestVirtualPayment(option);
}
#endregion
/// <summary>
/// [[PageManager](https://developers.weixin.qq.com/minigame/dev/api/open-api/openlink/PageManager.html) wx.createPageManager()](https://developers.weixin.qq.com/minigame/dev/api/open-api/openlink/wx.createPageManager.html)
/// 需要基础库: `3.6.7`
/// 小游戏开放页面管理器用于启动微信内置的各种小游戏活动、功能页面。具体OPENLINK值由不同的能力渠道获得。
/// **示例代码**
/// ```js
/// const pageManager = wx.createPageManager();
/// pageManager.load({
/// openlink: 'xxxxxxx-xxxxxx', // 由不同渠道获得的OPENLINK值
/// }).then((res) => {
/// // 加载成功res 可能携带不同活动、功能返回的特殊回包信息(具体请参阅渠道说明)
/// console.log(res);
/// // 加载成功后按需显示
/// pageManager.show();
/// }).catch((err) => {
/// // 加载失败,请查阅 err 给出的错误信息
/// console.error(err);
/// })
/// ```
/// </summary>
/// <returns></returns>
public static WXPageManager CreatePageManager()
{
return WXSDKManagerHandler.Instance.CreatePageManager();
}
} }
} }
#endif #endif

View File

@ -8,6 +8,10 @@ using UnityEngine;
using UnityEngine.Scripting; using UnityEngine.Scripting;
using System.IO; using System.IO;
using Unity.Profiling;
using UnityEngine.Profiling;
using Debug = UnityEngine.Debug;
#if PLATFORM_WEIXINMINIGAME || PLATFORM_WEBGL || UNITY_EDITOR #if PLATFORM_WEIXINMINIGAME || PLATFORM_WEBGL || UNITY_EDITOR
@ -20,17 +24,17 @@ namespace WXSDKPerf
public class WXPerfEngine public class WXPerfEngine
{ {
#if !UNITY_EDITOR #if !UNITY_EDITOR
static WXPerfEngine_Implementation m_PerfEngineImplementation = null; static WXPerfEngine_Implementation m_PerfEngineImplementation = null;
#endif #endif
[RuntimeInitializeOnLoadMethod] [RuntimeInitializeOnLoadMethod]
public static void StartWXPerfEngine() public static void StartWXPerfEngine()
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
return; return;
#else #else
m_PerfEngineImplementation = new WXPerfEngine_Implementation(); m_PerfEngineImplementation = new WXPerfEngine_Implementation();
m_PerfEngineImplementation.StartPerfEngine(); m_PerfEngineImplementation.StartPerfEngine();
#endif #endif
} }
@ -45,7 +49,7 @@ namespace WXSDKPerf
public static void Annotation(string InAnnotationString) public static void Annotation(string InAnnotationString)
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
return; return;
#else #else
// Don't record annotation if we are not recording. // Don't record annotation if we are not recording.
if (!IsRecording()) if (!IsRecording())
@ -68,7 +72,7 @@ namespace WXSDKPerf
#endif #endif
} }
/// <summary> /// <summary>
/// 检查是否正在录制性能数据 /// 检查是否正在录制性能数据
/// </summary> /// </summary>
@ -89,14 +93,14 @@ namespace WXSDKPerf
#else #else
DateTime timestamp = DateTime.Now; DateTime timestamp = DateTime.Now;
var dateString = timestamp.ToLocalTime().ToString("yyyy-MM-dd_HH-mm-ss", System.Globalization.CultureInfo.InvariantCulture); var dateString = timestamp.ToLocalTime().ToString("yyyy-MM-dd_HH-mm-ss", System.Globalization.CultureInfo.InvariantCulture);
var snapshotFileName = $"{dateString}.snap"; var snapshotFileName = $"{dateString}.snap";
#if UNITY_2018_3_OR_NEWER && !UNITY_2022_2_OR_NEWER #if UNITY_2018_3_OR_NEWER && !UNITY_2022_2_OR_NEWER
UnityEngine.Profiling.Memory.Experimental.MemoryProfiler.TakeSnapshot(Path.Combine(Application.persistentDataPath, snapshotFileName), UnityEngine.Profiling.Memory.Experimental.MemoryProfiler.TakeSnapshot(Path.Combine(Application.persistentDataPath, snapshotFileName),
WXPerfEngine_Implementation.CaptureSnapshotCallback, (UnityEngine.Profiling.Memory.Experimental.CaptureFlags)31); WXPerfEngine_Implementation.CaptureSnapshotCallback, (UnityEngine.Profiling.Memory.Experimental.CaptureFlags)31);
#elif UNITY_2022_2_OR_NEWER #elif UNITY_2022_2_OR_NEWER
Unity.Profiling.Memory.MemoryProfiler.TakeSnapshot(Path.Combine(Application.persistentDataPath, snapshotFileName), Unity.Profiling.Memory.MemoryProfiler.TakeSnapshot(Path.Combine(Application.persistentDataPath, snapshotFileName),
WXPerfEngine_Implementation.CaptureSnapshotCallback, (Unity.Profiling.Memory.CaptureFlags)31); WXPerfEngine_Implementation.CaptureSnapshotCallback, (Unity.Profiling.Memory.CaptureFlags)31);
#endif #endif
#endif #endif
@ -109,7 +113,7 @@ namespace WXSDKPerf
public static void SetLuaState(IntPtr L) public static void SetLuaState(IntPtr L)
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
return; return;
#else #else
if (m_PerfEngineImplementation == null) if (m_PerfEngineImplementation == null)
{ {
@ -120,7 +124,7 @@ namespace WXSDKPerf
m_PerfEngineImplementation.SetLuaState(L); m_PerfEngineImplementation.SetLuaState(L);
#endif #endif
} }
/// <summary> /// <summary>
/// 声明自定义性能指标 /// 声明自定义性能指标
/// </summary> /// </summary>
@ -130,7 +134,7 @@ namespace WXSDKPerf
public static void DeclareCustomStatInfo(string inStatName, string inStatCategory, int inStatInterpType = 1) public static void DeclareCustomStatInfo(string inStatName, string inStatCategory, int inStatInterpType = 1)
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
return; return;
#else #else
if (m_PerfEngineImplementation == null) if (m_PerfEngineImplementation == null)
{ {
@ -151,7 +155,7 @@ namespace WXSDKPerf
public static void SetCustomStatValue(string inStatName, float inValue) public static void SetCustomStatValue(string inStatName, float inValue)
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
return; return;
#else #else
if (m_PerfEngineImplementation == null) if (m_PerfEngineImplementation == null)
{ {
@ -171,7 +175,7 @@ namespace WXSDKPerf
public static void AddCustomStatInfoBy(string inStatName, float inValue) public static void AddCustomStatInfoBy(string inStatName, float inValue)
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
return; return;
#else #else
if (m_PerfEngineImplementation == null) if (m_PerfEngineImplementation == null)
{ {
@ -179,9 +183,9 @@ namespace WXSDKPerf
return; return;
} }
m_PerfEngineImplementation.AddCustomStatInfoBy(inStatName, inValue); m_PerfEngineImplementation.AddCustomStatInfoBy(inStatName, inValue);
#endif #endif
} }
@ -195,11 +199,11 @@ namespace WXSDKPerf
/// <param name="inEnableCaptureResource">是否启用资源捕获</param> /// <param name="inEnableCaptureResource">是否启用资源捕获</param>
/// <param name="inEnableLuaMemoryMonitor">是否启用Lua内存监控</param> /// <param name="inEnableLuaMemoryMonitor">是否启用Lua内存监控</param>
/// <param name="inEnableLuaFunctionMemoryTracking">是否启用Lua函数内存跟踪</param> /// <param name="inEnableLuaFunctionMemoryTracking">是否启用Lua函数内存跟踪</param>
public static void StartRecordManually(bool inEnableStackTrace, bool inEnableStatInfo, bool inFrequentScreenShot, bool inEnablebRenderInst, public static void StartRecordManually(bool inEnableStackTrace, bool inEnableStatInfo, bool inFrequentScreenShot, bool inEnablebRenderInst,
bool inEnableCaptureResource, bool inEnableLuaMemoryMonitor, bool inEnableLuaFunctionMemoryTracking) bool inEnableCaptureResource, bool inEnableLuaMemoryMonitor, bool inEnableLuaFunctionMemoryTracking)
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
return; return;
#else #else
if (m_PerfEngineImplementation == null) if (m_PerfEngineImplementation == null)
{ {
@ -207,7 +211,7 @@ namespace WXSDKPerf
return; return;
} }
m_PerfEngineImplementation.StartRecordManually(inEnableStackTrace, inEnableStatInfo, inFrequentScreenShot, inEnablebRenderInst, m_PerfEngineImplementation.StartRecordManually(inEnableStackTrace, inEnableStatInfo, inFrequentScreenShot, inEnablebRenderInst,
inEnableCaptureResource, inEnableLuaMemoryMonitor, inEnableLuaFunctionMemoryTracking); inEnableCaptureResource, inEnableLuaMemoryMonitor, inEnableLuaFunctionMemoryTracking);
#endif #endif
} }
@ -218,7 +222,7 @@ namespace WXSDKPerf
public static void StopRecordManually() public static void StopRecordManually()
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
return; return;
#else #else
if (m_PerfEngineImplementation == null) if (m_PerfEngineImplementation == null)
{ {

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 260b24feb18b7455485a7bd2ed1d0a07
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,164 @@
/* eslint-disable no-multi-assign */
/* eslint-disable @typescript-eslint/naming-convention */
const { version, SDKVersion } = wx.getAppBaseInfo ? wx.getAppBaseInfo() : wx.getSystemInfoSync();
const { platform, system } = wx.getDeviceInfo ? wx.getDeviceInfo() : wx.getSystemInfoSync();
const accountInfo = wx.getAccountInfoSync();
const envVersion = accountInfo?.miniProgram?.envVersion;
function compareVersion(v1, v2) {
if (!v1 || !v2) {
return false;
}
return (v1
.split('.')
.map(v => v.padStart(2, '0'))
.join('')
>= v2
.split('.')
.map(v => v.padStart(2, '0'))
.join(''));
}
export const isDebug = false;
export const isPc = platform === 'windows' || platform === 'mac';
export const isIOS = platform === 'ios';
export const isAndroid = platform === 'android';
export const isDevtools = platform === 'devtools';
export const isMobile = !isPc && !isDevtools;
export const isDevelop = envVersion === 'develop';
// 是否禁止**开通了高性能模式**的小游戏在不支持的iOS设备上回退成普通模式回退可能导致无法正常体验游戏
// @ts-ignore
const disableHighPerformanceFallback = $DISABLE_HIGHPERFORMANCE_FALLBACK && isIOS;
// 是否iOS高性能模式
export const isH5Renderer = GameGlobal.isIOSHighPerformanceMode;
// 操作系统版本号
const systemVersionArr = system ? system.split(' ') : [];
const systemVersion = systemVersionArr.length ? systemVersionArr[systemVersionArr.length - 1] : '';
// pc微信版本号不一致需要>=3.3
const isPcWeChatVersionValid = compareVersion(version, '3.3');
// 支持unity小游戏需要试玩基础库>=2.0.10
const isLibVersionValid = compareVersion(SDKVersion, '2.0.10');
// 如果是iOS高性能模式基础库需要>=2.0.10
const isH5LibVersionValid = compareVersion(SDKVersion, '2.0.10');
// 压缩纹理需要iOS系统版本>=14.0,检测到不支持压缩纹理时会提示升级系统
const isIOSH5SystemVersionValid = compareVersion(systemVersion, '14.0');
// iOS系统版本>=15支持webgl2高性能模式+无此系统要求
const isIOSWebgl2SystemVersionValid = compareVersion(systemVersion, '15.0') || GameGlobal.isIOSHighPerformanceModePlus;
// Android客户端版本>=8.0.19支持webgl2
const isAndroidWebGL2ClientVersionValid = compareVersion(version, '8.0.19');
// 是否用了webgl2
const isWebgl2 = () => GameGlobal.managerConfig.contextConfig.contextType === 2;
// 是否支持BufferURL
export const isSupportBufferURL = !isPc
&& (isH5Renderer
? compareVersion(SDKVersion, '2.0.10') && compareVersion(version, '8.0.30')
: typeof wx.createBufferURL === 'function');
// 安卓innerAudio支持playbackRate
export const isSupportPlayBackRate = !isAndroid || compareVersion(version, '8.0.23');
// IOS innerAudio支持复用时再次触发onCanplay
export const isSupportCacheAudio = !isIOS || compareVersion(version, '8.0.31');
// // 安卓旧客户端版本innerAudio偶现会导致闪退大于等于8.0.38才使用innerAudio减少内存
export const isSupportInnerAudio = compareVersion(version, '8.0.38');
// 检查是否支持brotli压缩pc基础库>=2.29.2,真机基础库>=2.21.1
// @ts-ignore
const isPcBrotliInvalid = isPc && !compareVersion(SDKVersion, $LOAD_DATA_FROM_SUBPACKAGE ? '2.29.2' : '2.32.3');
const isMobileBrotliInvalid = isMobile && !compareVersion(SDKVersion, '2.0.10');
// @ts-ignore
const isBrotliInvalid = $COMPRESS_DATA_PACKAGE && (isPcBrotliInvalid || isMobileBrotliInvalid);
// iOS系统版本>=17.5时,小游戏退后台会导致异常
export const isIOS175 = compareVersion(systemVersion, '17.5') && isH5Renderer;
// 试玩无开放数据域
export const isSupportSharedCanvasMode = false;
// 是否能以iOS高性能模式运行
// 请勿修改GameGlobal.canUseH5Renderer赋值
GameGlobal.canUseH5Renderer = isH5Renderer && isH5LibVersionValid;
// iOS高性能模式定期GC
GameGlobal.canUseiOSAutoGC = false;
// pc微信版本不满足要求
const isPcInvalid = isPc && !isPcWeChatVersionValid;
// 移动设备基础库版本或客户端版本不支持运行unity小游戏
const isMobileInvalid = isMobile && !isLibVersionValid;
// 基础库/客户端不支持iOS高性能模式
const isIOSH5Invalid = (isH5Renderer && !isH5LibVersionValid) || (!isH5Renderer && disableHighPerformanceFallback);
// 是否支持VideoPlayer组件注意开发者工具需要1.06.2310312以上版本
export const isSupportVideoPlayer = false;
// 视情况添加,没用到对应能力就不需要判断
// 是否支持webgl2
const isWebgl2SystemVersionInvalid = () => isWebgl2() && ((!isIOSWebgl2SystemVersionValid && isIOS) || (isAndroid && !isAndroidWebGL2ClientVersionValid));
// IOS高性能模式2.25.3以上基础库需要手动启动webAudio
export const webAudioNeedResume = false;
// 满足iOS高性能条件但未开通高性能模式
const needToastEnableHpMode = isDevelop && isIOS && isH5LibVersionValid && isIOSH5SystemVersionValid && !isH5Renderer;
/**
* 判断环境是否可使用coverview
* coverview实际需要基础库版本>=2.16.1但因为移动端要>=2.17.0才能运行所以移动端基本都支持coverview
*
* @export
* @returns
*/
export function canUseCoverview() {
return isMobile || isDevtools;
}
if (needToastEnableHpMode) {
console.error('此AppID未开通高性能模式\n请前往mp后台-能力地图-开发提效包-高性能模式开通\n可大幅提升游戏运行性能');
// setTimeout(() => {
// wx.showModal({
// title: '[开发版提示]建议',
// content: '此AppID未开通高性能模式\n请前往mp后台-能力地图-开发提效包-高性能模式开通\n可大幅提升游戏运行性能',
// showCancel: false,
// })
// }, 10000);
}
// @ts-ignore
if (isIOS && typeof $IOS_DEVICE_PIXEL_RATIO === 'number' && $IOS_DEVICE_PIXEL_RATIO > 0) {
// @ts-ignore
window.devicePixelRatio = $IOS_DEVICE_PIXEL_RATIO;
}
else if (isPc) {
try {
if (window.devicePixelRatio < 2) {
window.devicePixelRatio = 2;
}
}
catch (e) {
console.warn(e);
}
}
export default () => new Promise((resolve) => {
if (!isDevtools) {
if (isPcInvalid
|| isMobileInvalid
|| isIOSH5Invalid
|| isWebgl2SystemVersionInvalid()
|| isBrotliInvalid) {
let updateWechat = true;
let content = '当前微信版本过低\n请更新微信后进行游戏';
if (isIOS) {
if (!isIOSH5SystemVersionValid || (isWebgl2SystemVersionInvalid() && isIOS)) {
content = '当前操作系统版本过低\n请更新iOS系统后进行游戏';
updateWechat = false;
}
}
console.error('提示: ', content);
wx.showModal({
title: '提示',
content,
showCancel: false,
confirmText: updateWechat ? '更新微信' : '确定',
success(res) {
if (res.confirm) {
const showUpdateWechat = updateWechat && typeof wx.createBufferURL === 'function';
if (showUpdateWechat) {
wx.updateWeChatApp();
}
else {
wx.exitMiniProgram({
success: () => { },
});
}
}
},
});
return resolve(false);
}
}
return resolve(true);
});

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 75ef85528de9cf32347c924331a4b281
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c233f641f99d4f78c505a46b3e10268a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9c8d7e78ba8ed93f81612e8cf4157812
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,58 @@
const events = [];
const EventsManager = {
/**
* 注册一个事件并持续监听
* @param eventName 事件名称
* @param callback 事件的触发函数
*/
on(eventName, callback) {
events.push({
eventName,
callback,
once: false,
});
},
/**
* 注册一个事件并最多只触发一次
* @param eventName 事件名称
* @param callback 事件的触发函数
*/
once(eventName, callback) {
events.push({
eventName,
callback,
once: true,
});
},
/**
* 卸载一个事件
* @param eventName 事件名称
* @param callback 事件句柄若缺省将卸载所有同名事件
*/
off(eventName, callback) {
events.forEach((item, index) => {
if (item.eventName === eventName) {
if (!callback || item.callback === callback) {
events.splice(index, 1);
}
}
});
},
emit(eventName, ...args) {
const res = [];
const indexs = [];
events.forEach((item, index) => {
if (item.eventName === eventName) {
res.push(item.callback(...args));
if (item.once) {
indexs.unshift(index);
}
}
});
indexs.forEach((value) => {
events.splice(value, 1);
});
return res;
},
};
GameGlobal.events = EventsManager;

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6381bef0b1cb25ca0814ee9ec3c33584
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,187 @@
// @ts-nocheck
import './playable-fix';
import './weapp-adapter';
import './events';
import './texture-config';
import unityNamespace from './unity-namespace';
import '.$DOTNET_RUNTIME_FOLD/$GAME_NAME.wasm.framework.unityweb';
import './unity-sdk/index';
import checkVersion from './check-version';
import { launchEventType, scaleMode } from './plugin-config';
import UnityManager from './unity-playable-plugin/index';
const managerConfig = {
DATA_FILE_MD5: '$DATA_MD5',
CODE_FILE_MD5: '$CODE_MD5',
GAME_NAME: '$GAME_NAME',
APPID: '$APP_ID',
DATA_FILE_SIZE: '$DATA_FILE_SIZE',
OPT_DATA_FILE_SIZE: '$OPT_DATA_FILE_SIZE',
DATA_CDN: '$DEPLOY_URL',
// 资源包是否作为小游戏分包加载
loadDataPackageFromSubpackage: $LOAD_DATA_FROM_SUBPACKAGE,
// 资源包放小游戏分包加载时是否br压缩
compressDataPackage: $COMPRESS_DATA_PACKAGE,
// 需要在网络空闲时预加载的资源,支持如下形式的路径
preloadDataList: [
// 'DATA_CDN/StreamingAssets/WebGL/textures_8d265a9dfd6cb7669cdb8b726f0afb1e',
// '/WebGL/sounds_97cd953f8494c3375312e75a29c34fc2'
'$PRELOAD_LIST',
],
contextConfig: {
contextType: $WEBGL_VERSION, // 1: webgl1 2: webgl2
},
PROFILER_UPLOAD_URL: '',
};
GameGlobal.managerConfig = managerConfig;
// 版本检查
checkVersion().then((enable) => {
if (enable) {
// eslint-disable-next-line @typescript-eslint/naming-convention
// let UnityManager;
// try {
// // @ts-ignore
// UnityManager = requirePlugin('UnityPlugin', {
// enableRequireHostModule: true,
// customEnv: {
// wx,
// unityNamespace,
// document,
// canvas,
// events: GameGlobal.events,
// WXWASMSDK: GameGlobal.WXWASMSDK,
// },
// }).default;
// } catch (error) {
// GameGlobal.realtimeLogManager.error(error);
// // logManager不支持自动处理错误对象
// GameGlobal.logmanager.warn(error.stack);
// console.error('requirePlugin:', error);
// if (error.message.indexOf('not defined') !== -1) {
// console.error('!!!插件需要申请才可使用\n请勿使用测试AppID并登录 https://mp.weixin.qq.com/ 并前往:能力地图-开发提效包-快适配 开通\n阅读文档获取详情:https://github.com/wechat-miniprogram/minigame-unity-webgl-transform/blob/main/Design/Transform.md');
// }
// }
// JS堆栈能显示更完整
Error.stackTraceLimit = Infinity;
Object.assign(managerConfig, {
// callmain结束后立即隐藏封面视频
hideAfterCallmain: $HIDE_AFTER_CALLMAIN,
loadingPageConfig: {
// 以下是默认值
totalLaunchTime: 7000,
animationDuration: 100,
/**
* !!注意修改设计宽高和缩放模式后需要修改文字和进度条样式默认设计尺寸为667*375
*/
designWidth: 0,
designHeight: 0,
scaleMode: scaleMode.default,
// 以下配置的样式,尺寸相对设计宽高
textConfig: {
firstStartText: '首次加载请耐心等待',
downloadingText: ['正在加载资源'],
compilingText: '编译中',
initText: '初始化中',
completeText: '开始游戏',
textDuration: 1500,
// 文字样式
style: {
bottom: 64,
height: 24,
width: 240,
lineHeight: 24,
color: '#ffffff',
fontSize: 12,
},
},
// 进度条样式
barConfig: {
style: {
width: 240,
height: 24,
padding: 2,
bottom: 64,
backgroundColor: '#07C160',
},
},
// 一般不修改控制icon样式
iconConfig: {
visible: true,
style: {
width: 64,
height: 23,
bottom: 20,
},
},
// 加载页的素材配置
materialConfig: {
// 背景图或背景视频,两者都填时,先展示背景图,视频可播放后,播放视频
backgroundImage: '$BACKGROUND_IMAGE',
backgroundVideo: '$LOADING_VIDEO_URL',
iconImage: 'images/unity_logo.png', // icon图片一般不更换
},
},
});
GameGlobal.managerConfig = managerConfig;
// 显示启动封面
const gameManager = new UnityManager(managerConfig);
gameManager.onLaunchProgress((e) => {
// interface LaunchEvent {
// type: LaunchEventType;
// data: {
// costTimeMs: number; // 阶段耗时
// runTimeMs: number; // 总耗时
// loadDataPackageFromSubpackage: boolean; // 首包资源是否通过小游戏分包加载
// isVisible: boolean; // 当前是否处于前台onShow/onHide
// useCodeSplit: boolean; // 是否使用代码分包
// isHighPerformance: boolean; // 是否iOS高性能模式
// needDownloadDataPackage: boolean; // 本次启动是否需要下载资源包
// };
// }
if (e.type === launchEventType.launchPlugin) {
}
if (e.type === launchEventType.loadWasm) {
}
if (e.type === launchEventType.compileWasm) {
}
if (e.type === launchEventType.loadAssets) {
}
if (e.type === launchEventType.readAssets) {
}
if (e.type === launchEventType.prepareGame) {
}
});
gameManager.onModulePrepared(() => {
// eslint-disable-next-line no-restricted-syntax
for (const key in unityNamespace) {
// 动态修改DATA_CDN后同步修改全局对象
if (!GameGlobal.hasOwnProperty(key) || key === 'DATA_CDN') {
GameGlobal[key] = unityNamespace[key];
}
else {
}
}
managerConfig.DATA_CDN = GameGlobal.DATA_CDN;
gameManager.assetPath = `${(managerConfig.DATA_CDN || '').replace(/\/$/, '')}/Assets`;
});
// 插件捕获到引擎错误后,会通过此事件抛给游戏
gameManager.onLogError = function (err) {
GameGlobal.realtimeLogManager.error(err);
const isErrorObj = err && err.stack;
GameGlobal.logmanager.warn(isErrorObj ? err.stack : err);
};
// iOS高性能模式定期GC
if (GameGlobal.canUseiOSAutoGC && unityNamespace.iOSAutoGCInterval !== 0) {
setInterval(() => {
wx.triggerGC();
}, unityNamespace.iOSAutoGCInterval);
}
// 开始执行游戏启动流程
gameManager.startGame();
GameGlobal.manager = gameManager;
GameGlobal.events.on('launchOperaPushMsgToWasm', (callback, args) => GameGlobal.WXWASMSDK.WXLaunchOperaBridgeToC(callback, args));
// eslint-disable-next-line @typescript-eslint/no-unused-vars
GameGlobal.events.on('createWorker', (worker) => {
// worker created
});
}
});

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3a706d427ddc6f17a686d00164596b21
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
{
"deviceOrientation": "$ORIENTATION",
"engine": {
"name": "unity"
},
"features": [
"api.fs.readCompressedFile"
]
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3b7afa312f37129c5f0da72ca5085ed2
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,42 @@
/* eslint-disable */
delete wx.getWindowInfo;
delete wx.getDeviceInfo;
delete wx.getAppBaseInfo;
wx.getPerformance = function () {
return {
now: function () {
return Date.now() * 1000;
},
};
};
wx.getRealtimeLogManager = function () {
return {
info: function (...args) {
console.log.apply(console, args);
},
warn: function (...args) {
console.warn.apply(console, args);
},
error: function (...args) {
console.error.apply(console, args);
},
setFilterMsg: function () { },
addFilterMsg: function () { },
};
};
wx.getLogManager = function () {
return {
info: function (...args) {
console.log.apply(console, args);
},
warn: function (...args) {
console.warn.apply(console, args);
},
log: function (...args) {
console.log.apply(console, args);
},
debug: function (...args) {
console.log.apply(console, args);
},
};
};

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 38ef877315e858a891e38a8504d14444
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,19 @@
export const launchEventType = {
launchPlugin: 0,
loadWasm: 1,
compileWasm: 2,
loadAssets: 3,
readAssets: 5,
prepareGame: 6, // 初始化引擎
};
// https://docs.egret.com/engine/docs/screenAdaptation/zoomMode
export const scaleMode = {
default: '',
noBorder: 'NO_BORDER',
exactFit: 'EXACT_FIT',
fixedHeight: 'FIXED_HEIGHT',
fixedWidth: 'FIXED_WIDTH',
showAll: 'SHOW_ALL',
fixedNarrow: 'FIXED_NARROW',
fixedWide: 'FIXED_WIDE',
};

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: db19f71416cd53e87a23c48b14b8558e
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 844e9fbfa7180d47a44d3655a47bfa6a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,23 @@
function checkUpdate() {
const updateManager = wx.getUpdateManager();
updateManager.onCheckForUpdate(() => {
// 请求完新版本信息的回调
// console.log(res.hasUpdate)
});
updateManager.onUpdateReady(() => {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success(res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate();
}
},
});
});
updateManager.onUpdateFailed(() => {
// 新版本下载失败
});
}
checkUpdate();

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7bd7e7175cbf02cf19c630e5dde4919c
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
wx.onWindowResize((res) => {
window.innerWidth = res.windowWidth;
window.innerHeight = res.windowHeight;
});
wx.onDeviceOrientationChange(() => {
const info = wx.getWindowInfo ? wx.getWindowInfo() : wx.getSystemInfoSync();
window.innerWidth = info.screenWidth;
window.innerHeight = info.screenHeight;
});

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 89a34b810a1a142d563099e15e414093
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,75 @@
{
"description": "项目配置文件",
"setting": {
"urlCheck": false,
"es6": true,
"enhance": true,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": true,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"useMultiFrameRuntime": true,
"useApiHook": false,
"disableUseStrict": false,
"babelSetting": {
"ignore": ["$GAME_NAME.wasm.framework.unityweb.js"],
"disablePlugins": [],
"outputPath": ""
},
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": []
},
"compileType": "game",
"libVersion": "3.5.1",
"appid": "$APP_ID",
"projectname": "$PROJECT_NAME",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"packOptions": {
"ignore": [
{
"type": "folder",
"value": ".plugincache"
},
{
"type": "suffix",
"value": ".symbols.unityweb"
},
{
"type": "suffix",
"value": ".symbols.unityweb.br"
}
]
},
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"miniprogram": {
"current": -1,
"list": []
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 306d6397d3c633cd3388633bf4d36a76
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,3 @@
GameGlobal.USED_TEXTURE_COMPRESSION = false;
GameGlobal.TEXTURE_PARALLEL_BUNDLE = false;
GameGlobal.TEXTURE_BUNDLES = '';

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fafe80396291e3992588aa528e0e92a1
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,194 @@
// @ts-nocheck
const unityNamespace = {
canvas: GameGlobal.canvas,
// cache width
canvas_width: GameGlobal.canvas.width,
// cache height
canvas_height: GameGlobal.canvas.height,
navigator: GameGlobal.navigator,
XMLHttpRequest: GameGlobal.XMLHttpRequest,
// 是否显示耗时的弹框,默认开发版时显示弹出耗时弹框
hideTimeLogModal: true,
// 是否打印详细日志
enableDebugLog: false,
// 自定义bundle中的hash长度
bundleHashLength: $BUNDLE_HASH_LENGTH,
// 单位Bytes, 1MB = 1024 KB = 1024*1024Bytes
releaseMemorySize: $DEFAULT_RELEASE_SIZE,
unityVersion: '$UNITY_VERSION',
// Color Space: Gamma、Linear、Uninitialized(未初始化的颜色空间)
unityColorSpace: '$UNITY_COLORSPACE',
convertPluginVersion: '$PLUGIN_VERSION',
// 拼在StreamingAssets前面的pathDATA_CDN + streamingUrlPrefixPath + StreamingAssets
streamingUrlPrefixPath: '',
// DATA_CDN + dataFileSubPrefix + datafilename
dataFileSubPrefix: '$DATA_FILE_SUB_PREFIX',
// 当前appid扩容后通过本字段告知插件本地存储最大容量单位MB
maxStorage: $MAX_STORAGE_SIZE,
// 纹理中的hash长度
texturesHashLength: $TEXTURE_HASH_LENGTH,
// 纹理存放路径
texturesPath: '$TEXTURES_PATH',
// 是否需要缓存纹理,
needCacheTextures: $NEED_CACHE_TEXTURES,
// AssetBundle在内存中的存活时间
ttlAssetBundle: 5,
// 是否显示性能面板
enableProfileStats: $ENABLE_PROFILE_STATS,
// 是否预载微信系统字体
preloadWXFont: $PRELOAD_WXFONT,
// iOS高性能模式定期GC间隔
iOSAutoGCInterval: $IOS_AUTO_GC_INTERVAL,
// 是否使用微信压缩纹理
usedTextureCompression: GameGlobal.USED_TEXTURE_COMPRESSION,
// 是否使用autostreaming
usedAutoStreaming: $USED_AUTO_STREAMING,
// 是否显示渲染日志(dev only)
enableRenderAnalysisLog: $ENABLE_RENDER_ANALYSIS_LOG,
// 是否dotnet runtime
useDotnetRuntime: $USE_DOTNET_RUNTIME,
// 是否用了多线程brotli压缩
useBrotliMT: $USE_BROTLI_MT,
// Boot config配置包含例如wait-for-native-debugger、player-connection-ip等信息
bootConfig: '$BOOT_CONFIG_INFO',
// 是否以Development Build构建
isDevelopmentBuild: $Is_Development_Build,
// 是否以Profiling Build导出
isProfilingBuild: $Is_Profiling_Build,
// 预留的堆内存
unityHeapReservedMemory: $UnityHeapReservedMemory,
};
// 最佳实践检测配置
unityNamespace.monitorConfig = {
// 显示优化建议弹框
showSuggestModal: $SHOW_SUGGEST_MODAL,
// 是否开启检测(只影响开发版/体验版,线上版本不会检测)
enableMonitor: true,
// 帧率低于此值的帧会被记录,用于分析长耗时帧,做了限帧的游戏应该适当调低
fps: 10,
// 是否一直检测到游戏可交互完成
showResultAfterLaunch: true,
// 仅当showResultAfterLaunch=false时有效, 在引擎初始化完成(即callmain)后多长时间停止检测
monitorDuration: 30000,
};
// 判断是否需要自动缓存的文件返回true自动缓存false不自动缓存
unityNamespace.isCacheableFile = function (path) {
// 判定为下载bundle的路径标识符此路径下的下载会自动缓存
const cacheableFileIdentifier = [$BUNDLE_PATH_IDENTIFIER];
// 命中路径标识符的情况下,并不是所有文件都有必要缓存,过滤下不需要缓存的文件
const excludeFileIdentifier = [$EXCLUDE_FILE_EXTENSIONS];
if (cacheableFileIdentifier.some(identifier => path.includes(identifier)
&& excludeFileIdentifier.every(excludeIdentifier => !path.includes(excludeIdentifier)))) {
return true;
}
return false;
};
// 是否上报此条网络异常, 返回true则上报, 返回false则忽略
unityNamespace.isReportableHttpError = function (_info) {
// const { url, error } = _info;
return true;
};
// 判断是否是AssetBundle
unityNamespace.isWXAssetBundle = function (path) {
return unityNamespace.WXAssetBundles.has(unityNamespace.PathInFileOS(path));
};
unityNamespace.PathInFileOS = function (path) {
return path.replace(`${wx.env.USER_DATA_PATH}/__GAME_FILE_CACHE`, '');
};
unityNamespace.WXAssetBundles = new Map();
// 清理缓存时是否可被自动清理返回true可自动清理返回false不可自动清理
unityNamespace.isErasableFile = function (info) {
// 用于特定AssetBundle的缓存保持
if (unityNamespace.WXAssetBundles.has(info.path)) {
return false;
}
// 达到缓存上限时,不会被自动清理的文件
const inErasableIdentifier = [];
if (inErasableIdentifier.some(identifier => info.path.includes(identifier))) {
return false;
}
return true;
};
GameGlobal.WebAssembly = GameGlobal.WXWebAssembly;
GameGlobal.unityNamespace = GameGlobal.unityNamespace || unityNamespace;
GameGlobal.realtimeLogManager = wx.getRealtimeLogManager();
GameGlobal.logmanager = wx.getLogManager({ level: 0 });
// 提前监听错误并打日志
function bindGloblException() {
// 默认上报小游戏实时日志与用户反馈日志(所有error日志+小程序框架异常)
wx.onError((result) => {
// 若manager已初始化则直接用manager打日志即可
if (GameGlobal.manager) {
GameGlobal.manager.printErr(result.message);
}
else {
GameGlobal.realtimeLogManager.error(result);
const isErrorObj = result && result.stack;
GameGlobal.logmanager.warn(isErrorObj ? result.stack : result);
console.error('onError:', result);
}
});
wx.onUnhandledRejection((result) => {
GameGlobal.realtimeLogManager.error(result);
const isErrorObj = result && result.reason && result.reason.stack;
GameGlobal.logmanager.warn(isErrorObj ? result.reason.stack : result.reason);
console.error('unhandledRejection:', result.reason);
});
// 上报初始信息
function printSystemInfo(appBaseInfo, deviceInfo) {
// eslint-disable-next-line @typescript-eslint/naming-convention
const { version, SDKVersion } = appBaseInfo;
const { platform, system } = deviceInfo;
unityNamespace.version = version;
unityNamespace.SDKVersion = SDKVersion;
unityNamespace.platform = platform;
unityNamespace.system = system;
unityNamespace.isPc = platform === 'windows' || platform === 'mac';
unityNamespace.isDevtools = platform === 'devtools';
unityNamespace.isMobile = !unityNamespace.isPc && !unityNamespace.isDevtools;
unityNamespace.isH5Renderer = GameGlobal.isIOSHighPerformanceMode;
unityNamespace.isIOS = platform === 'ios';
unityNamespace.isAndroid = platform === 'android';
const bootinfo = {
renderer: GameGlobal.isIOSHighPerformanceMode ? 'h5' : '',
isH5Plus: GameGlobal.isIOSHighPerformanceModePlus || false,
abi: deviceInfo.abi || '',
brand: deviceInfo.brand,
model: deviceInfo.model,
platform: deviceInfo.platform,
system: deviceInfo.system,
version: appBaseInfo.version,
SDKVersion: appBaseInfo.SDKVersion,
benchmarkLevel: deviceInfo.benchmarkLevel,
};
GameGlobal.realtimeLogManager.info('game starting', bootinfo);
GameGlobal.logmanager.info('game starting', bootinfo);
console.info('game starting', bootinfo);
}
const appBaseInfo = wx.getAppBaseInfo ? wx.getAppBaseInfo() : wx.getSystemInfoSync();
const deviceInfo = wx.getDeviceInfo ? wx.getDeviceInfo() : wx.getSystemInfoSync();
printSystemInfo(appBaseInfo, deviceInfo);
}
bindGloblException();
// eslint-disable-next-line no-multi-assign
GameGlobal.onCrash = GameGlobal.unityNamespace.onCrash = function () {
GameGlobal.manager.showAbort();
const windowInfo = wx.getWindowInfo ? wx.getWindowInfo() : wx.getSystemInfoSync();
wx.createFeedbackButton({
type: 'text',
text: '提交反馈',
style: {
left: (windowInfo.screenWidth - 184) / 2,
top: windowInfo.screenHeight / 3 + 140,
width: 184,
height: 40,
lineHeight: 40,
backgroundColor: '#07C160',
color: '#ffffff',
textAlign: 'center',
fontSize: 16,
borderRadius: 4,
},
});
};
export default GameGlobal.unityNamespace;

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 371613b26b33189b2dbc0e63af9c2aa8
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2056d2dadba4cdc21c89b03008d5754a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 02dffa55081d6f775f17621b7aca54de
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2e17b41cccc3aab50c531f3f846777e5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d2d2ffeeb21555008dc418d316063a90
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,71 @@
import { WEBAudio, audios, unityAudioVolume, innerAudioVolume } from './store';
import { resumeWebAudio, mkCacheDir } from './utils';
mkCacheDir();
export default {
WXGetAudioCount() {
return {
innerAudio: Object.keys(audios).length,
webAudio: WEBAudio.bufferSourceNodeLength,
buffer: WEBAudio.audioBufferLength,
};
},
WXSetAudioMute(value) {
if (typeof value !== 'boolean') {
return;
}
if (WEBAudio.isMute === value) {
return;
}
WEBAudio.isMute = value;
for (const channelInstance of Object.keys(WEBAudio.audioInstances)) {
const channel = WEBAudio.audioInstances[+channelInstance];
if (channel.source) {
channel.setVolume?.(value ? 0 : unityAudioVolume.get(channel) ?? 1);
}
}
for (const innerAudio of Object.values(audios)) {
innerAudio.volume = value ? 0 : innerAudioVolume.get(innerAudio) ?? 1;
}
},
};
const HandleInterruption = {
init() {
let INTERRUPT_LIST = {};
wx.onHide(() => {
Object.keys(audios).forEach((key) => {
if (!audios[key].paused !== false) {
INTERRUPT_LIST[key] = true;
}
});
});
wx.onShow(() => {
Object.keys(audios).forEach((key) => {
if (audios[key].paused !== false && INTERRUPT_LIST[key]) {
audios[key].play();
}
});
INTERRUPT_LIST = {};
});
wx.onAudioInterruptionBegin(() => {
Object.keys(audios).forEach((key) => {
if (!audios[key].paused !== false) {
INTERRUPT_LIST[key] = true;
}
});
});
wx.onAudioInterruptionEnd(() => {
Object.keys(audios).forEach((key) => {
if (audios[key].paused !== false && INTERRUPT_LIST[key]) {
audios[key].play();
}
});
INTERRUPT_LIST = {};
resumeWebAudio();
});
},
};
HandleInterruption.init();

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 725da8ab5cb786687eb3672109cd7ad0
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,3 @@
export const INNER_AUDIO_UNDEFINED_MSG = 'InnerAudioContext does not exist!';
export const IGNORE_ERROR_MSG = 'audio is playing, don\'t play again';
export const TEMP_DIR_PATH = `${wx.env.USER_DATA_PATH}/__GAME_FILE_CACHE/audios`;

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 16aea3ab47cc15ca64c9be6db6dfda11
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
import innerAudio from './inner-audio';
import unityAudio from './unity-audio';
import common from './common';
export default {
...innerAudio,
...unityAudio,
...common,
};

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5102a7a140da8b309dc8cfeba79cb238
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,382 @@
/* eslint-disable no-param-reassign */
import moduleHelper from '../module-helper';
import { isSupportPlayBackRate } from '../../check-version';
import { audios, localAudioMap, downloadingAudioMap, innerAudioVolume, WEBAudio } from './store';
import { createInnerAudio, destroyInnerAudio, printErrMsg } from './utils';
import { IGNORE_ERROR_MSG, INNER_AUDIO_UNDEFINED_MSG } from './const';
const funs = {
getFullUrl(v) {
if (!/^https?:\/\//.test(v) && !/^wxfile:\/\//.test(v)) {
const cdnPath = GameGlobal.manager.assetPath;
v = `${cdnPath.replace(/\/$/, '')}/${v.replace(/^\//, '').replace(/^Assets\//, '')}`;
}
return v;
},
downloadAudios(paths) {
const list = paths.split(',');
return Promise.all(list.map((v) => {
const src = funs.getFullUrl(v);
return new Promise((resolve, reject) => {
if (!downloadingAudioMap[src]) {
downloadingAudioMap[src] = [
{
resolve,
reject,
},
];
if (funs.checkLocalFile(src)) {
funs.handleDownloadEnd(src, true);
}
else if (!GameGlobal.unityNamespace.isCacheableFile(src)) {
wx.downloadFile({
url: src,
success(res) {
if (res.statusCode === 200 && res.tempFilePath) {
localAudioMap[src] = res.tempFilePath;
funs.handleDownloadEnd(src, true);
}
else {
funs.handleDownloadEnd(src, false);
}
},
fail(e) {
funs.handleDownloadEnd(src, false);
printErrMsg(e);
},
});
}
else {
const xmlhttp = new GameGlobal.unityNamespace.UnityLoader.UnityCache.XMLHttpRequest();
xmlhttp.open('GET', src, true);
xmlhttp.responseType = 'arraybuffer';
xmlhttp.onsave = () => {
localAudioMap[src] = GameGlobal.manager.getCachePath(src);
funs.handleDownloadEnd(src, true);
};
xmlhttp.onsavefail = () => {
funs.handleDownloadEnd(src, false);
};
xmlhttp.onerror = () => {
funs.handleDownloadEnd(src, false);
};
xmlhttp.send();
}
}
else {
downloadingAudioMap[src].push({
resolve,
reject,
});
}
});
}));
},
handleDownloadEnd(src, succeeded) {
if (!downloadingAudioMap[src]) {
return;
}
while (downloadingAudioMap[src] && downloadingAudioMap[src].length > 0) {
const item = downloadingAudioMap[src].shift();
if (!succeeded) {
item?.reject();
}
else {
item?.resolve('');
}
}
delete downloadingAudioMap[src];
},
// 是否存在本地文件
checkLocalFile(src) {
if (localAudioMap[src]) {
return true;
}
const path = GameGlobal.manager.getCachePath(src);
if (path) {
localAudioMap[src] = path;
return true;
}
return false;
},
// 设置路径
setAudioSrc(audio, getSrc) {
return new Promise((resolve, reject) => {
const src = funs.getFullUrl(getSrc);
// 设置原始路径后面用此路径作为key值
audio.isLoading = src;
if (funs.checkLocalFile(src)) {
audio.src = localAudioMap[src];
delete audio.isLoading;
funs.handleDownloadEnd(src, true);
resolve(localAudioMap[src]);
}
else if (audio.needDownload) {
funs
.downloadAudios(src)
.then(() => {
if (audio) {
audio.src = localAudioMap[src];
delete audio.isLoading;
resolve(localAudioMap[src]);
}
else {
console.warn('资源已被删除:', src);
reject({
errCode: -1,
errMsg: '资源已被删除',
});
}
})
.catch(() => {
console.warn('资源下载失败:', src);
if (audio) {
audio.src = src;
delete audio.isLoading;
}
reject({
errCode: -1,
errMsg: '资源下载失败',
});
});
}
else {
// 不推荐这样处理,建议优先下载再使用,除非是需要立即播放的长音频文件或一次性播放音频
// console.warn('建议优先下载再使用:', src);
audio.src = src;
delete audio.isLoading;
resolve(src);
}
});
},
};
function checkHasAudio(id) {
if (audios[id]) {
return true;
}
console.error(INNER_AUDIO_UNDEFINED_MSG, id);
return false;
}
export default {
// 创建audio对象
WXCreateInnerAudioContext(src, loop, startTime, autoplay, volume, playbackRate, needDownload) {
const { audio: getAudio, id } = createInnerAudio();
getAudio.needDownload = needDownload;
if (src) {
// 设置原始src
funs.setAudioSrc(getAudio, src).catch((e) => {
moduleHelper.send('OnAudioCallback', JSON.stringify({
callbackId: id,
errMsg: 'onError',
result: JSON.stringify(e),
}));
});
}
if (loop) {
getAudio.loop = true;
}
if (autoplay) {
getAudio.autoplay = true;
}
if (typeof startTime === 'undefined') {
startTime = 0;
}
if (startTime > 0) {
getAudio.startTime = +startTime.toFixed(2);
}
let volumeValue;
if (typeof volume === 'undefined') {
volumeValue = 1;
}
else {
volumeValue = +volume.toFixed(2);
}
innerAudioVolume.set(getAudio, volumeValue);
if (WEBAudio.isMute) {
volumeValue = 0;
}
if (volumeValue !== 1) {
getAudio.volume = volumeValue;
}
if (!isSupportPlayBackRate) {
playbackRate = 1;
}
if (typeof playbackRate !== 'undefined' && playbackRate !== 1) {
getAudio.playbackRate = +playbackRate.toFixed(2);
}
return id;
},
WXInnerAudioContextSetBool(id, k, v) {
if (!checkHasAudio(id)) {
return;
}
audios[id][k] = Boolean(+v);
},
WXInnerAudioContextSetString(id, k, v) {
if (!checkHasAudio(id)) {
return;
}
if (k === 'src') {
funs.setAudioSrc(audios[id], v);
}
else if (k === 'needDownload') {
audios[id].needDownload = !!v;
}
else {
audios[id][k] = v;
}
},
WXInnerAudioContextSetFloat(id, k, v) {
if (!checkHasAudio(id)) {
return;
}
let value = +v.toFixed(2);
if (k === 'volume') {
innerAudioVolume.set(audios[id], value);
if (WEBAudio.isMute) {
value = 0;
}
}
audios[id][k] = value;
},
WXInnerAudioContextGetFloat(id, k) {
if (!checkHasAudio(id)) {
return 0;
}
return audios[id][k];
},
WXInnerAudioContextGetBool(id, k) {
if (!checkHasAudio(id)) {
return false;
}
return audios[id][k];
},
WXInnerAudioContextPlay(id) {
if (!checkHasAudio(id)) {
return;
}
const url = audios[id].isLoading;
if (url) {
if (downloadingAudioMap[url]) {
downloadingAudioMap[url].push({
resolve: () => {
if (typeof audios[id] !== 'undefined') {
audios[id].play();
}
},
reject: () => { },
});
}
else {
audios[id].src = url;
audios[id].play();
}
}
else {
audios[id].play();
}
},
WXInnerAudioContextPause(id) {
if (!checkHasAudio(id)) {
return;
}
audios[id].pause();
},
WXInnerAudioContextStop(id) {
if (!checkHasAudio(id)) {
return;
}
audios[id].stop();
},
WXInnerAudioContextDestroy(id) {
if (!checkHasAudio(id)) {
return;
}
destroyInnerAudio(id, false);
},
WXInnerAudioContextSeek(id, position) {
if (!checkHasAudio(id)) {
return;
}
audios[id].seek(+position.toFixed(3));
},
WXInnerAudioContextAddListener(id, key) {
if (!checkHasAudio(id)) {
return;
}
if (key === 'onCanplay') {
audios[id][key](() => {
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { duration, buffered, referrerPolicy, volume } = audios[id];
setTimeout(() => {
moduleHelper.send('OnAudioCallback', JSON.stringify({
callbackId: id,
errMsg: key,
}));
}, 0);
});
}
else if (key === 'onError') {
audios[id][key]((e) => {
if (key === 'onError') {
console.error(e);
if (e.errMsg && e.errMsg.indexOf(IGNORE_ERROR_MSG) > -1) {
return;
}
}
moduleHelper.send('OnAudioCallback', JSON.stringify({
callbackId: id,
errMsg: key,
result: JSON.stringify(e),
}));
});
}
else {
audios[id][key](() => {
moduleHelper.send('OnAudioCallback', JSON.stringify({
callbackId: id,
errMsg: key,
}));
});
}
},
WXInnerAudioContextRemoveListener(id, key) {
if (!checkHasAudio(id)) {
return;
}
audios[id][key]();
},
WXPreDownloadAudios(paths, id) {
funs
.downloadAudios(paths)
.then(() => {
moduleHelper.send('WXPreDownloadAudiosCallback', JSON.stringify({
callbackId: id.toString(),
errMsg: '0',
}));
})
.catch(() => {
moduleHelper.send('WXPreDownloadAudiosCallback', JSON.stringify({
callbackId: id.toString(),
errMsg: '1',
}));
});
},
};

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4d3cd0899ccf7f7a8a7784a8ef0f493e
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,33 @@
export const WEBAudio = {
audioInstanceIdCounter: 0,
audioInstances: {},
audioContext: null,
audioWebEnabled: 0,
audioCache: [],
lOrientation: {
x: 0,
y: 0,
z: 0,
xUp: 0,
yUp: 0,
zUp: 0,
},
lPosition: { x: 0, y: 0, z: 0 },
audio3DSupport: 0,
audioWebSupport: 0,
bufferSourceNodeLength: 0,
audioBufferLength: 0,
isMute: false,
FAKEMOD_SAMPLERATE: 44100,
};
export const audios = {};
export const localAudioMap = {};
export const downloadingAudioMap = {};
export const unityAudioVolume = new WeakMap();
export const innerAudioVolume = new WeakMap();

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fcbd0e472755678cb73ce15c59456b49
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 96fb3e98d187bbbc7a6e54e620eb1183
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,77 @@
import { uid } from '../utils';
import { isSupportCacheAudio } from '../../check-version';
import { WEBAudio, audios } from './store';
import { TEMP_DIR_PATH } from './const';
export const resumeWebAudio = () => {
WEBAudio.audioContext?.resume();
};
export const createInnerAudio = () => {
const id = uid();
const audio = (isSupportCacheAudio && WEBAudio.audioCache.length ? WEBAudio.audioCache.shift() : wx.createInnerAudioContext());
if (audio) {
audios[id] = audio;
}
return {
id,
audio,
};
};
export const destroyInnerAudio = (id, useCache) => {
if (!id) {
return;
}
if (!useCache || !isSupportCacheAudio || WEBAudio.audioCache.length > 32) {
audios[id].destroy();
}
else {
['Play', 'Pause', 'Stop', 'Canplay', 'Error', 'Ended', 'Waiting', 'Seeking', 'Seeked', 'TimeUpdate'].forEach((eventName) => {
audios[id][`off${eventName}`]();
});
const state = {
startTime: 0,
obeyMuteSwitch: true,
volume: 1,
autoplay: false,
loop: false,
referrerPolicy: '',
};
Object.keys(state).forEach((key) => {
try {
// @ts-ignore
audios[id][key] = state[key];
}
catch (e) { }
});
audios[id].stop();
const cacheAudio = audios[id];
setTimeout(() => {
WEBAudio.audioCache.push(cacheAudio);
}, 1000);
}
delete audios[id];
};
export const printErrMsg = (msg) => {
GameGlobal.manager.printErr(msg);
};
export function mkCacheDir() {
const fs = wx.getFileSystemManager();
fs.rmdir({
dirPath: TEMP_DIR_PATH,
recursive: true,
complete: () => {
fs.mkdir({
dirPath: TEMP_DIR_PATH,
});
},
});
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 46d32a16e64018567a02b90541549025
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,16 @@
const callbacks = [];
let isTriggered = false;
export default {
addCreatedListener(callback) {
if (isTriggered) {
callback();
}
else {
callbacks.push(callback);
}
},
_triggerCallback() {
isTriggered = true;
callbacks.forEach(v => v());
},
};

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 917aa8b5c3fa53d8a5d2f345d09f200d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,24 @@
import response from './response';
import moduleHelper from './module-helper';
import { getDefaultData } from './utils';
export default {
WXToTempFilePathSync(conf) {
return canvas.toTempFilePathSync(getDefaultData(canvas, conf));
},
WXToTempFilePath(conf, s, f, c) {
if (conf) {
canvas.toTempFilePath({
...getDefaultData(canvas, conf),
...response.handleText(s, f, c),
success: (res) => {
moduleHelper.send('ToTempFilePathCallback', JSON.stringify({
callbackId: s,
errMsg: res.errMsg,
errCode: res.errCode || 0,
tempFilePath: res.tempFilePath,
}));
},
});
}
},
};

Some files were not shown because too many files have changed in this diff Show More