提交 6d28237f 编写于 作者: U uhu

feat: 增加录屏示例

上级 ab3608a4
此差异已折叠。
fileFormatVersion: 2
guid: 902b36a4306884e4e907d6122b69e6e4
TextScriptImporter:
guid: 7f727aa0bdd0740a8afa2675ed260003
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
......
......@@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 705507994}
m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641275, b: 0.5748172, a: 1}
m_IndirectSpecularColor: {r: 0.44657815, g: 0.49641192, b: 0.57481617, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
......@@ -1157,7 +1157,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SendPointerHoverToParent: 1
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
......@@ -1992,7 +1991,7 @@ RectTransform:
- {fileID: 543787561}
- {fileID: 1768399494}
m_Father: {fileID: 1586432807}
m_RootOrder: 12
m_RootOrder: 13
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
......@@ -2049,6 +2048,140 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: de09d77023c4f44de8c19c3b277a9285, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1433912555
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1433912556}
- component: {fileID: 1433912559}
- component: {fileID: 1433912558}
- component: {fileID: 1433912557}
m_Layer: 5
m_Name: "\u5F55\u5C4Fdemo"
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1433912556
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1433912555}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1539476758}
m_Father: {fileID: 1586432807}
m_RootOrder: 12
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 340, y: -234}
m_SizeDelta: {x: 320, y: 82}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1433912557
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1433912555}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 1433912558}
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1586432809}
m_TargetAssemblyTypeName: Common, Assembly-CSharp
m_MethodName: ChangeScene
m_Mode: 3
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 3
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!114 &1433912558
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1433912555}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &1433912559
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1433912555}
m_CullTransparentMesh: 0
--- !u!1 &1497117442
GameObject:
m_ObjectHideFlags: 0
......@@ -2397,6 +2530,86 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1522841550}
m_CullTransparentMesh: 0
--- !u!1 &1539476757
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1539476758}
- component: {fileID: 1539476760}
- component: {fileID: 1539476759}
m_Layer: 5
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1539476758
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1539476757}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1433912556}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1539476759
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1539476757}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 24
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 1
m_MaxSize: 40
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: GameRecorder Demo
--- !u!222 &1539476760
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1539476757}
m_CullTransparentMesh: 0
--- !u!1 &1571140067
GameObject:
m_ObjectHideFlags: 0
......@@ -2637,6 +2850,7 @@ RectTransform:
- {fileID: 908224560}
- {fileID: 1571140068}
- {fileID: 2020125377}
- {fileID: 1433912556}
- {fileID: 1379490561}
m_Father: {fileID: 0}
m_RootOrder: 2
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using WeChatWASM;
public class GameRecordeManager : MonoBehaviour
{
private WXGameRecorder gameRecorder;
void Start()
{
WX.InitSDK((code) =>
{
// 获取系统信息
var systemInfo = WeChatWASM.WX.GetSystemInfoSync();
// TODO 先判断客户端是安卓,且客户端版本大于等于8.0.28,且基础库版本大于等于2.26.1,再使用该功能
gameRecorder = WX.GetGameRecorder();
gameRecorder.On("timeUpdate", (res) =>
{
Debug.Log(res.currentTime);
});
gameRecorder.On("start", (res) =>
{
Debug.Log("gameRecorder start");
});
gameRecorder.On("stop", (res) =>
{
Debug.Log("gameRecorder stop:" + res.duration);
});
var canvasWith = (int)(systemInfo.screenWidth * systemInfo.pixelRatio);
var shareButtonHeight = (int)(canvasWith / 1080f * 120f);
// 分享接口必须在touchEnd里触发
WX.OnTouchEnd((res) =>
{
// 判断 pageX 和 pageY 的位置是否在分享按钮的位置
if (res.changedTouches[0].pageY < shareButtonHeight)
{
this.ShareRecorder();
}
});
});
}
public void StartRecorder()
{
gameRecorder.Start(new GameRecorderStartOption()
{
hookBgm = false,
});
}
public void StopRecorder()
{
gameRecorder.Stop();
}
public void PauseRecorder()
{
gameRecorder.Pause();
}
public void ResumeRecorder()
{
gameRecorder.Resume();
}
public void ShareRecorder()
{
WX.OperateGameRecorderVideo(new operateGameRecorderOption()
{
title = "游戏标题",
desc = "游戏简介",
timeRange = new int[][] {
new int[] { 0, 2000 },
new int[] { 5000, 8000 },
},
query = "test=123456",
});
}
public void offEvent()
{
gameRecorder.Off("timeUpdate");
gameRecorder.Off("start");
gameRecorder.Off("stop");
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: cdb7ec4606ecd4f9ab6fdbbb0d38988a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -6,20 +6,34 @@ Removed - 删除功能/接口
Fixed - 修复问题
Others - 其他
-->
2022-11-9
### Feature
* Unity Audio压缩纹理,支持小游戏InnerAudio
* 适配插件版本升级到1.1.2
### Fixed
* 修复png资源Windows系统下缓存异常
2022-10-27
### Feature
压缩纹理回退使用png时也支持缓存逻辑
### Fixed
使用node命令时同时查找默认安装路径
修复Win7下使用Unity2021生成symbols时导致的卡死问题
## 2022-10-20
### Added
### Feature
* 高性能模式HTTP网络切换为小游戏接口
* 适配插件版本升级到1.0.97
## 2022-10-12
### Added
### Feature
* 微信压缩纹理工具支持ASTC文件读取,并支持不同的块大小(需Unity2021版本)
* 适配插件版本升级到1.0.95
### Fixed
* 文件缓存清理逻辑优化
## 2022-9-28
### Added
### Feature
* InnerAudio支持持久化文件存储(当音频路径加入到缓存目录时)
* 适配插件版本升级到1.0.94
### Fixed
......@@ -27,14 +41,14 @@ Others - 其他
* 修复WebGL2导出时的胶水层异常
## 2022-9-21
### Added
### Feature
* 增加游戏圈接口openPageOption, getGameClubData
* FileSystemManager增加stat接口
### Fixed
* FileSystemManager异步读取文件,填写encoding时没有返回数据
## 2022-9-13
### Added
### Feature
* 微信压缩纹理工具支持bundle级别修改压缩纹理等级
* Unity2021 IL2CPP默认选项更改为SIZE减少代码包体
......@@ -43,7 +57,7 @@ Others - 其他
* 启动封面拉伸
* pc小游戏下载路径处理
### Added
### Feature
* 增加动态修改DATA_CDN的C#接口`SetDataCDN`,以及js接口`GameGlobal.manager.setDataCDN`
* 增加动态修改预下载列表的C#接口`SetPreloadList`,以及js接口`GameGlobal.manager.setPreloadList`
......@@ -92,7 +106,7 @@ Others - 其他
* 增加重启小游戏的API支持
### Fixed
* 纹理压缩并行下载完成未正常显示
### Added
### Feature
* 设置启动时是否自动检查小游戏版本更新
## 2022-7-14
### Fixed
......@@ -118,7 +132,7 @@ Others - 其他
### Fixed
* 小游戏模板错误
## 2022-6-16
### Added
### Feature
* 支持自定义可缓存文件及可清理文件
* 优化缓存目录统计
......@@ -129,21 +143,21 @@ Others - 其他
* `RemoveFile`参数转字符串
* 8.0.16安卓worker写文件报错
## 2022-6-8
### Added
### Feature
* 提供Loader启动数据
### Fixed
* 修复是否需要下载代码包上报
* 21.3版本Unity webrequest设置请求头;注册进度事件
## 2022-6-7
### Added
### Feature
* 增加MemoryProfiler,开发阶段分析内存
## 2022-6-1
### Added
### Feature
* 使用worker做文件写入临时绕过安卓文件写入多时造成卡顿
## 2022-5-31
### Added
### Feature
* 暴露插件进度事件
## 2022-5-30
### Fixed
......@@ -155,7 +169,7 @@ Others - 其他
### Fixed
* 修复21.3替换规则
## 2022-5-24
### Added
### Feature
* 增加对21.3版本unity支持
* MiniGameConfig.asset增加不常用配置入口
## 2022-4-29
......@@ -166,7 +180,7 @@ Others - 其他
### Fixed
*`dataFileSubPrefix`时iOS首包资源下载bug
### Added
### Feature
* 游戏异常时增加重启游戏按钮
* 检查是否32位微信导致无法进入游戏
* 修正URL中非法路径
......@@ -181,15 +195,15 @@ Others - 其他
更新独立域插件版本`1.0.58`
* 预下载问题路径bug
* 不支持webgl2时提示
### Added
### Feature
* 增加清理指定文件接口`RemoveFile`
* 是否缓存纹理开关
## 2022-4-18
### Added
### Feature
* 修改文件删除接口使用方法`CleanFileCache`,`CleanAllFileCache`
## 2022-4-14
### Added
### Feature
* 增加清除文件缓存接口`CleanFileCache`
## 2022-4-11
......@@ -231,16 +245,16 @@ Others - 其他
* PlayerSettings默认去除"Run In Background"
## 2022-2-14
### Added
### Feature
* 支持PC端DXT5压缩纹理
## 2022-2-11
### Added
### Feature
* 调整部分API
* 支持webgl2.0的压缩纹理
## 2022-1-26
### Added
### Feature
* 新增API
* 修复API中不确定类型的数据可能导致类型转换失败的问题
......@@ -249,11 +263,11 @@ Others - 其他
* 修复Login方法,默认不传timeout,默认超时为1000ms,容易失败的问题
## 2022-1-24
### Added
### Feature
* 兼容浏览器环境,修复部分API问题
## 2022-1-21
### Added
### Feature
* 新增WXCleanAllFileCache接口,用于清理所有文件缓存
### Changed
......@@ -267,7 +281,7 @@ Others - 其他
## 2022-1-20
### Added
### Feature
* 新增API,旧API批量重命名,用法保持不变
## 2022-1-17
......@@ -309,7 +323,7 @@ Others - 其他
## 2021-12-16
### Added
### Feature
* 开发、体验版本增加性能面板
## 2021-12-10
......@@ -319,7 +333,7 @@ Others - 其他
## 2021-12-06
### Added
### Feature
* WebGL2.0 增加适配,该特性处于测试阶段
* 2021增加embedded symbols分离
* 增加error日志回调
......@@ -347,7 +361,7 @@ Others - 其他
* 更新小游戏模板
## 2021-11-18
### Added
### Feature
增加bundle相关导出配置
* 自定义bundle名中hash长度:用于缓存控制,默认32
......@@ -361,12 +375,12 @@ Others - 其他
* 更新小游戏模板
## 2021-10-26
### Added
### Feature
* 增加部分文件操作API
* 压缩纹理替换优化,提升转换速度
## 2021-10-09
### Added
### Feature
* 增加Unity2020、2021版本支持
......@@ -377,35 +391,35 @@ Others - 其他
## 2021-09-22
### Added
### Feature
* 支持短音频的播放API(WX.ShortAudioPlayer),更接近Unity的API调用方式
### Added
### Feature
* 当禁用异常时,程序即将crash之前弹出用户反馈入口,并自动提交用户反馈日志、JS Error与实时日志
### Added
### Feature
* 编译选项增加"Profiling Funcs", 仅调试问题时勾选此选项时,编译代码将含有函数名,代码体积变大
## 2021-09-14
### Added
### Feature
* 支持PlayerPrefs优化,支持配置key
### Fixed
* 修复排行榜内存增长问题
## 2021-09-06
### Added
### Feature
* 支持导出时配置封面图
## 2021-8-20
### Added
### Feature
* 支持创建视频
## 2021-8-12
### Added
### Feature
* 修复IOS下音频被系统打断后的恢复问题
* 支持客服消息
......@@ -417,7 +431,7 @@ Others - 其他
## 2021-08-05
### Added
### Feature
* 音频支持获取播放状态
* 非POT图也支持延迟加载
......@@ -439,18 +453,18 @@ Others - 其他
## 2021-07-31
### Added
### Feature
* 增加预下载并发数控制接口WX.SetConcurrent
### Changed
* 小游戏项目模板变更
## 2021-07-26
### Added
### Feature
* 增加预下载猎豹配置,自动从导出目录webgl/StreamingAssets查找资源并填充到game.js的Preload列表
## 2021-07-26
### Added
### Feature
* 支持文件二进制读写(同步和异步)
* 压缩纹理替换速度优化
......@@ -487,7 +501,7 @@ Others - 其他
* 压缩纹理兼容flare
### Added
### Feature
* 支持游戏恢复到前台后自动播放,默认开启分享
......@@ -497,7 +511,7 @@ Others - 其他
* 云测试设置UI框架导致editor运行错误
### Added
### Feature
* 引入[UnityMarkdownViewer](https://github.com/gwaredd/UnityMarkdownViewer)在inspector面板预览changelog
......
......@@ -13,12 +13,12 @@ MonoBehaviour:
m_Name: MiniGameConfig
m_EditorClassIdentifier:
ProjectConf:
projectName: testapi
Appid: wxf616b60467bcfcaf
CDN: https://www.test.com
projectName: test
Appid: wx7a727ff7d940bb3f
CDN: https://www.test.com/
assetLoadType: 1
VideoUrl:
DST: /Users/nihayashi/Documents/wxgame_unity/wxgame_testapi
DST: /Users/uhu/Projects/Unity/minigame-unity-webgl-transform/Demo/API/Dist
StreamCDN:
bundleHashLength: 32
bundlePathIdentifier: StreamingAssets;
......@@ -38,14 +38,14 @@ MonoBehaviour:
loadingBarWidth: 240
needCheckUpdate: 0
SDKOptions:
UseAudioApi: 1
UseAudioApi: 0
UseFriendRelation: 0
UseCompressedTexture: 0
CompileOptions:
DevelopBuild: 0
AutoProfile: 0
ScriptOnly: 0
profilingFuncs: 1
profilingFuncs: 0
Webgl2: 0
DeleteStreamingAssets: 1
ProfilingMemory: 0
......
......@@ -49,14 +49,14 @@ namespace WeChatWASM.Analysis
{
win = AnalysisWindow.GetCurrentWindow();
if (!initializedRefrenceData)
{
if (!assetRefrenceDatas.ReadFromCache())
{
assetRefrenceDatas.CollectDependenciesInfo();
}
initializedRefrenceData = true;
}
//if (!initializedRefrenceData)
//{
// if (!assetRefrenceDatas.ReadFromCache())
// {
// assetRefrenceDatas.CollectDependenciesInfo();
// }
// initializedRefrenceData = true;
//}
}
public static T GetInstance()
......
......@@ -65,11 +65,17 @@ namespace WeChatWASM.Analysis
var totalCount = textureInfos.Count;
var idx = 0;
var changedTextures = new List<Texture>();
int total = textureInfos.Count;
int current = 0;
foreach (var info in textureInfos)
{
++current;
EditorUtility.DisplayProgressBar($"Optimize Texture,当前:{current},总共:{total}", $"Handling:{info.assetPath}", current * 1.0f / total);
idx++;
TextureImporter textureImporter = AssetImporter.GetAtPath(info.assetPath) as TextureImporter;
TextureImporterPlatformSettings settings = new TextureImporterPlatformSettings();
var settings = textureImporter.GetPlatformTextureSettings("WebGL");
settings.overridden = true;
int maxRect = Math.Max(info.width, info.height) / 2;
var needReImport = false;
......@@ -102,7 +108,7 @@ namespace WeChatWASM.Analysis
needReImport = true;
var formatMap = textureWindow.formatMap;
var list = new List<string>(formatMap.Keys);
var i = textureWindow.textureFormatSelected;
var i = textureWindow.selectedFormat;
TextureImporterFormat format = formatMap[list[i]];
settings.name = "WebGL";
settings.format = format;
......@@ -115,7 +121,6 @@ namespace WeChatWASM.Analysis
EditorUtility.DisplayCancelableProgressBar("Recover", "Reading Cache " + idx, (float)idx / totalCount);
textureImporter.SetPlatformTextureSettings(settings);
textureImporter.SaveAndReimport();
AssetDatabase.ImportAsset(info.assetPath);
}
}
//Undo.RecordObjects(changedTextures.ToArray(), "optimize");
......@@ -212,7 +217,6 @@ namespace WeChatWASM.Analysis
settings.format = info._webglFormat;
textureImporter.SetPlatformTextureSettings(settings);
textureImporter.SaveAndReimport();
AssetDatabase.ImportAsset(path);
}
}
File.Delete(CACHE_PATH);
......
......@@ -44,7 +44,12 @@ namespace WeChatWASM.Analysis
{ "RGBA Compressed DXT5", TextureImporterFormat.DXT5 },
{ "RGB Crunched DXT1", TextureImporterFormat.DXT1Crunched },
{ "RGBA Crunched DXT5", TextureImporterFormat.DXT5Crunched },
{ "R 8", TextureImporterFormat.R8 }
{ "R 8", TextureImporterFormat.R8 },
#if UNITY_2021_2_OR_NEWER
{ "ASTC 8*8", TextureImporterFormat.ASTC_8x8 },
{ "ASTC 5*5", TextureImporterFormat.ASTC_5x5 },
{ "ASTC 4*4", TextureImporterFormat.ASTC_4x4 },
#endif
};
......@@ -252,13 +257,11 @@ namespace WeChatWASM.Analysis
if (selectedTextureInfos.Count > 0)
{
OptimizeTexture.Optimize(selectedTextureInfos);
CollectAssets(false);
}
}
if (GUILayout.Button("还原选中资源", GUILayout.Width(160), GUILayout.Height(40)))
{
OptimizeTexture.Recover(selectedTextureInfos);
CollectAssets(false);
}
GUILayout.Label("修复规则");
disableReadable = EditorGUILayout.ToggleLeft("禁用isReadable", disableReadable);
......
......@@ -25,7 +25,7 @@ namespace WeChatWASM
new Rule()
{
old="self\\[\"performance\"\\]\\[\"now\"\\]",
newStr="wx.getPerformance().now"
newStr="performance.now"
}
,new Rule()
{
......
<?xml version="1.0" encoding="utf-8"?><doc>
<assembly>
<name>System.Buffers</name>
</assembly>
<members>
<member name="T:System.Buffers.ArrayPool`1">
<summary>Provides a resource pool that enables reusing instances of type <see cref="T[]"></see>.</summary>
<typeparam name="T">The type of the objects that are in the resource pool.</typeparam>
</member>
<member name="M:System.Buffers.ArrayPool`1.#ctor">
<summary>Initializes a new instance of the <see cref="T:System.Buffers.ArrayPool`1"></see> class.</summary>
</member>
<member name="M:System.Buffers.ArrayPool`1.Create">
<summary>Creates a new instance of the <see cref="T:System.Buffers.ArrayPool`1"></see> class.</summary>
<returns>A new instance of the <see cref="System.Buffers.ArrayPool`1"></see> class.</returns>
</member>
<member name="M:System.Buffers.ArrayPool`1.Create(System.Int32,System.Int32)">
<summary>Creates a new instance of the <see cref="T:System.Buffers.ArrayPool`1"></see> class using the specifed configuration.</summary>
<param name="maxArrayLength">The maximum length of an array instance that may be stored in the pool.</param>
<param name="maxArraysPerBucket">The maximum number of array instances that may be stored in each bucket in the pool. The pool groups arrays of similar lengths into buckets for faster access.</param>
<returns>A new instance of the <see cref="System.Buffers.ArrayPool`1"></see> class with the specified configuration.</returns>
</member>
<member name="M:System.Buffers.ArrayPool`1.Rent(System.Int32)">
<summary>Retrieves a buffer that is at least the requested length.</summary>
<param name="minimumLength">The minimum length of the array.</param>
<returns>An array of type <see cref="T[]"></see> that is at least <paramref name="minimumLength">minimumLength</paramref> in length.</returns>
</member>
<member name="M:System.Buffers.ArrayPool`1.Return(`0[],System.Boolean)">
<summary>Returns an array to the pool that was previously obtained using the <see cref="M:System.Buffers.ArrayPool`1.Rent(System.Int32)"></see> method on the same <see cref="T:System.Buffers.ArrayPool`1"></see> instance.</summary>
<param name="array">A buffer to return to the pool that was previously obtained using the <see cref="M:System.Buffers.ArrayPool`1.Rent(System.Int32)"></see> method.</param>
<param name="clearArray">Indicates whether the contents of the buffer should be cleared before reuse. If <paramref name="clearArray">clearArray</paramref> is set to true, and if the pool will store the buffer to enable subsequent reuse, the <see cref="M:System.Buffers.ArrayPool`1.Return(`0[],System.Boolean)"></see> method will clear the <paramref name="array">array</paramref> of its contents so that a subsequent caller using the <see cref="M:System.Buffers.ArrayPool`1.Rent(System.Int32)"></see> method will not see the content of the previous caller. If <paramref name="clearArray">clearArray</paramref> is set to false or if the pool will release the buffer, the array&amp;#39;s contents are left unchanged.</param>
</member>
<member name="P:System.Buffers.ArrayPool`1.Shared">
<summary>Gets a shared <see cref="T:System.Buffers.ArrayPool`1"></see> instance.</summary>
<returns>A shared <see cref="System.Buffers.ArrayPool`1"></see> instance.</returns>
</member>
</members>
<?xml version="1.0" encoding="utf-8"?><doc>
<assembly>
<name>System.Buffers</name>
</assembly>
<members>
<member name="T:System.Buffers.ArrayPool`1">
<summary>Provides a resource pool that enables reusing instances of type <see cref="T[]"></see>.</summary>
<typeparam name="T">The type of the objects that are in the resource pool.</typeparam>
</member>
<member name="M:System.Buffers.ArrayPool`1.#ctor">
<summary>Initializes a new instance of the <see cref="T:System.Buffers.ArrayPool`1"></see> class.</summary>
</member>
<member name="M:System.Buffers.ArrayPool`1.Create">
<summary>Creates a new instance of the <see cref="T:System.Buffers.ArrayPool`1"></see> class.</summary>
<returns>A new instance of the <see cref="System.Buffers.ArrayPool`1"></see> class.</returns>
</member>
<member name="M:System.Buffers.ArrayPool`1.Create(System.Int32,System.Int32)">
<summary>Creates a new instance of the <see cref="T:System.Buffers.ArrayPool`1"></see> class using the specifed configuration.</summary>
<param name="maxArrayLength">The maximum length of an array instance that may be stored in the pool.</param>
<param name="maxArraysPerBucket">The maximum number of array instances that may be stored in each bucket in the pool. The pool groups arrays of similar lengths into buckets for faster access.</param>
<returns>A new instance of the <see cref="System.Buffers.ArrayPool`1"></see> class with the specified configuration.</returns>
</member>
<member name="M:System.Buffers.ArrayPool`1.Rent(System.Int32)">
<summary>Retrieves a buffer that is at least the requested length.</summary>
<param name="minimumLength">The minimum length of the array.</param>
<returns>An array of type <see cref="T[]"></see> that is at least <paramref name="minimumLength">minimumLength</paramref> in length.</returns>
</member>
<member name="M:System.Buffers.ArrayPool`1.Return(`0[],System.Boolean)">
<summary>Returns an array to the pool that was previously obtained using the <see cref="M:System.Buffers.ArrayPool`1.Rent(System.Int32)"></see> method on the same <see cref="T:System.Buffers.ArrayPool`1"></see> instance.</summary>
<param name="array">A buffer to return to the pool that was previously obtained using the <see cref="M:System.Buffers.ArrayPool`1.Rent(System.Int32)"></see> method.</param>
<param name="clearArray">Indicates whether the contents of the buffer should be cleared before reuse. If <paramref name="clearArray">clearArray</paramref> is set to true, and if the pool will store the buffer to enable subsequent reuse, the <see cref="M:System.Buffers.ArrayPool`1.Return(`0[],System.Boolean)"></see> method will clear the <paramref name="array">array</paramref> of its contents so that a subsequent caller using the <see cref="M:System.Buffers.ArrayPool`1.Rent(System.Int32)"></see> method will not see the content of the previous caller. If <paramref name="clearArray">clearArray</paramref> is set to false or if the pool will release the buffer, the array&amp;#39;s contents are left unchanged.</param>
</member>
<member name="P:System.Buffers.ArrayPool`1.Shared">
<summary>Gets a shared <see cref="T:System.Buffers.ArrayPool`1"></see> instance.</summary>
<returns>A shared <see cref="System.Buffers.ArrayPool`1"></see> instance.</returns>
</member>
</members>
</doc>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<doc>
<assembly>
<name>System.Text.Encoding.CodePages</name>
</assembly>
<members>
<member name="T:System.Text.CodePagesEncodingProvider">
<summary>Provides access to an encoding provider for code pages that otherwise are available only in the desktop .NET Framework.</summary>
</member>
<member name="M:System.Text.CodePagesEncodingProvider.GetEncoding(System.Int32)">
<summary>Returns the encoding associated with the specified code page identifier.</summary>
<param name="codepage">The code page identifier of the preferred encoding which the encoding provider may support.</param>
<returns>The encoding associated with the specified code page identifier, or <see langword="null" /> if the provider does not support the requested codepage encoding.</returns>
</member>
<member name="M:System.Text.CodePagesEncodingProvider.GetEncoding(System.String)">
<summary>Returns the encoding associated with the specified code page name.</summary>
<param name="name">The code page name of the preferred encoding which the encoding provider may support.</param>
<returns>The encoding associated with the specified code page, or <see langword="null" /> if the provider does not support the requested encoding.</returns>
</member>
<member name="M:System.Text.CodePagesEncodingProvider.GetEncodings">
<summary>Returns an array that contains all the encodings that are supported by the <see cref="T:System.Text.CodePagesEncodingProvider" />.</summary>
<returns>An array that contains all the supported encodings.</returns>
</member>
<member name="P:System.Text.CodePagesEncodingProvider.Instance">
<summary>Gets an encoding provider for code pages supported in the desktop .NET Framework but not in the current .NET Framework platform.</summary>
<returns>An encoding provider that allows access to encodings not supported on the current .NET Framework platform.</returns>
</member>
</members>
<?xml version="1.0" encoding="utf-8"?>
<doc>
<assembly>
<name>System.Text.Encoding.CodePages</name>
</assembly>
<members>
<member name="T:System.Text.CodePagesEncodingProvider">
<summary>Provides access to an encoding provider for code pages that otherwise are available only in the desktop .NET Framework.</summary>
</member>
<member name="M:System.Text.CodePagesEncodingProvider.GetEncoding(System.Int32)">
<summary>Returns the encoding associated with the specified code page identifier.</summary>
<param name="codepage">The code page identifier of the preferred encoding which the encoding provider may support.</param>
<returns>The encoding associated with the specified code page identifier, or <see langword="null" /> if the provider does not support the requested codepage encoding.</returns>
</member>
<member name="M:System.Text.CodePagesEncodingProvider.GetEncoding(System.String)">
<summary>Returns the encoding associated with the specified code page name.</summary>
<param name="name">The code page name of the preferred encoding which the encoding provider may support.</param>
<returns>The encoding associated with the specified code page, or <see langword="null" /> if the provider does not support the requested encoding.</returns>
</member>
<member name="M:System.Text.CodePagesEncodingProvider.GetEncodings">
<summary>Returns an array that contains all the encodings that are supported by the <see cref="T:System.Text.CodePagesEncodingProvider" />.</summary>
<returns>An array that contains all the supported encodings.</returns>
</member>
<member name="P:System.Text.CodePagesEncodingProvider.Instance">
<summary>Gets an encoding provider for code pages supported in the desktop .NET Framework but not in the current .NET Framework platform.</summary>
<returns>An encoding provider that allows access to encodings not supported on the current .NET Framework platform.</returns>
</member>
</members>
</doc>
\ No newline at end of file
......@@ -1353,9 +1353,21 @@ namespace WeChatWASM
// 如果是2021版本,官方symbols产生有BUG,这里需要用工具将embedded的函数名提取出来
#if UNITY_2021_2_OR_NEWER
var path = "Assets/WX-WASM-SDK/Editor/Node";
var nodePath = "node";
var nodePath = "";
#if UNITY_EDITOR_OSX
nodePath = "/usr/local/bin/node";
#else
nodePath = @"C:\Program Files\nodejs\node.exe";
if (!File.Exists(nodePath))
{
// 使用环境变量
Debug.Log($"[Converter] {nodePath}不存在。使用环境变量PATH寻找node,如果仍然报错,请重启电脑刷新环境变量后重试");
nodePath = "node";
}
else
{
Debug.Log($"[Converter] 使用默认node路径:{nodePath}");
}
#endif
WeChatWASM.UnityUtil.RunCmd(nodePath, string.Format($"--experimental-modules dump_wasm_symbol.mjs \"{dst}\""), path);
UnityEngine.Debug.LogError($"Unity 2021版本使用Embeded Symbols, 代码包中含有函数名体积较大, 发布前<a href=\"https://github.com/wechat-miniprogram/minigame-unity-webgl-transform/blob/main/Design/WasmSplit.md\">使用代码分包工具</a>进行优化");
......
......@@ -2,7 +2,7 @@
{
public class WXPluginVersion
{
public static string pluginVersion = "202211042146"; //这一行不要改他,导出的时候会自动替换
public static string pluginVersion = "202211162132"; //这一行不要改他,导出的时候会自动替换
}
public class WXPluginConf
{
......
......@@ -155,7 +155,7 @@ mergeInto(LibraryManager.library, {
var lastTid = window._lastTextureId;
function getMatchId() {
if(GameGlobal.USED_TEXTURE_COMPRESSION && internalFormat == 36196){
if(GameGlobal.USED_TEXTURE_COMPRESSION && format == 36196){
var length = HEAPU8.subarray(data, data + 1)[0];
var d = HEAPU8.subarray(data+1, data + 1 + length);
var res = [];
......@@ -423,7 +423,7 @@ mergeInto(LibraryManager.library, {
window.WXWASMSDK.WXHideAd(_WXPointer_stringify_adaptor(id), _WXPointer_stringify_adaptor(s), _WXPointer_stringify_adaptor(f));
},
WXADGetStyleValue: function (id, key) {
window.WXWASMSDK.WXADGetStyleValue(_WXPointer_stringify_adaptor(id), _WXPointer_stringify_adaptor(key));
return window.WXWASMSDK.WXADGetStyleValue(_WXPointer_stringify_adaptor(id), _WXPointer_stringify_adaptor(key));
},
WXADDestroy: function (id) {
window.WXWASMSDK.WXADDestroy(_WXPointer_stringify_adaptor(id));
......@@ -975,7 +975,48 @@ mergeInto(LibraryManager.library, {
WXUploadTaskOnProgressUpdate:function(id){
window.WXWASMSDK.WXUploadTaskOnProgressUpdate(_WXPointer_stringify_adaptor(id));
},
WXStat: function (conf, callbackId) {
window.WXWASMSDK.WXStat(_WXPointer_stringify_adaptor(conf), _WXPointer_stringify_adaptor(callbackId))
},
WX_GetGameRecorder:function() {
var res = window.WXWASMSDK.WX_GetGameRecorder();
var bufferSize = lengthBytesUTF8(res) + 1;
var buffer = _malloc(bufferSize);
stringToUTF8(res, buffer, bufferSize);
return buffer;
},
WX_GameRecorderOff:function(id, eventType){
window.WXWASMSDK.WX_GameRecorderOff(_WXPointer_stringify_adaptor(id), _WXPointer_stringify_adaptor(eventType));
},
WX_GameRecorderOn:function(id, eventType){
window.WXWASMSDK.WX_GameRecorderOn(_WXPointer_stringify_adaptor(id), _WXPointer_stringify_adaptor(eventType));
},
WX_GameRecorderStart:function(id,option){
window.WXWASMSDK.WX_GameRecorderStart(_WXPointer_stringify_adaptor(id),_WXPointer_stringify_adaptor(option));
},
WX_GameRecorderAbort:function(id){
window.WXWASMSDK.WX_GameRecorderAbort(_WXPointer_stringify_adaptor(id));
},
WX_GameRecorderPause:function(id){
window.WXWASMSDK.WX_GameRecorderPause(_WXPointer_stringify_adaptor(id));
},
WX_GameRecorderResume:function(id){
window.WXWASMSDK.WX_GameRecorderResume(_WXPointer_stringify_adaptor(id));
},
WX_GameRecorderStop:function(id){
window.WXWASMSDK.WX_GameRecorderStop(_WXPointer_stringify_adaptor(id));
},
WX_OperateGameRecorderVideo:function(option){
window.WXWASMSDK.WX_OperateGameRecorderVideo(_WXPointer_stringify_adaptor(option));
},
});
......@@ -376,6 +376,20 @@ namespace WeChatWASM
}
#endregion
#region 游戏对局回放
/// <summary>
/// [[GameRecorder](https://developers.weixin.qq.com/minigame/dev/api/game-recorder/GameRecorder.html) wx.getGameRecorder()](https://developers.weixin.qq.com/minigame/dev/api/game-recorder/wx.getGameRecorder.html)
///
/// 需要基础库: `2.26.1`
/// 需要客户端: 安卓>=`8.0.28`,目前只支持安卓
/// 获取全局唯一的游戏画面录制对象
/// </summary>
public static WXGameRecorder GetGameRecorder()
{
return WXSDKManagerHandler.Instance.GetGameRecorder();
}
#endregion
#region 相机
/// <summary>
/// [[WXCamera](https://developers.weixin.qq.com/minigame/dev/api/media/camera/Camera.html) wx.createCamera(Object object)](https://developers.weixin.qq.com/minigame/dev/api/media/camera/wx.createCamera.html)
......@@ -754,6 +768,15 @@ namespace WeChatWASM
WXSDKManagerHandler.Instance.SetPreloadList(paths);
}
#endregion
/// <summary>
/// 分享对局回放
/// 接口需要用户产生点击行为后才能调用,要在WX.OnTouchEnd事件中调用
/// </summary>
public static void OperateGameRecorderVideo(operateGameRecorderOption option)
{
WXSDKManagerHandler.Instance.OperateGameRecorderVideo(option);
}
}
}
......@@ -2162,6 +2162,8 @@ namespace WeChatWASM
/// 屏幕亮度值,范围 0 ~ 1,0 最暗,1 最亮
/// </summary>
public double value;
public string errMsg;
}
[Preserve]
public class GetSettingOption {
......
......@@ -1400,6 +1400,33 @@ namespace WeChatWASM
}
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern string WX_GetGameRecorder();
private Dictionary<string, WXGameRecorder> GameRecorderList = new Dictionary<string, WXGameRecorder>();
public WXGameRecorder GetGameRecorder()
{
var id = WX_GetGameRecorder();
var obj = new WXGameRecorder(id);
GameRecorderList.Add(id,obj);
return obj;
}
public void _OnGameRecorderCallback(string msg)
{
if (!string.IsNullOrEmpty(msg))
{
var jsCallback = JsonUtility.FromJson<WXJSCallback>(msg);
var id = jsCallback.callbackId;
var res = jsCallback.res;
var result = JsonMapper.ToObject<GameRecorderCallback>(res);
var eventType = result.eventType;
var callbackResult = JsonMapper.ToObject<GameRecorderCallbackRes>(result.result);
WXGameRecorder.OnActionList[eventType]?.Invoke(callbackResult);
}
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
......@@ -1610,6 +1637,18 @@ namespace WeChatWASM
WXUploadTask.OnProgressUpdateActionList[id]?.Invoke(result);
}
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WX_OperateGameRecorderVideo(string option);
public void OperateGameRecorderVideo(operateGameRecorderOption option)
{
WX_OperateGameRecorderVideo(JsonMapper.ToJson(option));
}
public static string GetCallbackId<T>(Dictionary<string, T> dict) {
var id = dict.Count;
......
......@@ -15,7 +15,8 @@ function compareVersion(v1, v2) {
}
const isPc = platform === "windows"
const isIOS = platform === "ios"
export const isIOS = platform === "ios"
export const isAndroid = platform === 'android'
const isDevtools = platform === "devtools"
const isMobile = !isPc && !isDevtools
// 是否iOSH5模式
......@@ -65,6 +66,9 @@ const isH5SystemVersionInvalid =
// 是否支持webgl2
const isWebgl2SystemVersionInvalid = () => isIOS && isWebgl2() && !isIOSWebgl2SystemVersionValid
// 2.25.3以上基础库需要手动启动webAudio
export const webAudioNeedResume = compareVersion(SDKVersion, '2.25.3')
/**
* 判断环境是否可使用coverview
* coverview实际需要基础库版本>=2.16.1,但因为移动端要>=2.17.0才能运行,所以移动端基本都支持coverview
......
......@@ -14,7 +14,7 @@
],
"plugins": {
"UnityPlugin": {
"version": "1.0.95",
"version": "1.1.2",
"provider": "wxe5a48f1ed5f544b7",
"contexts": [
{
......
......@@ -33,7 +33,7 @@
"packNpmRelationList": []
},
"compileType": "game",
"libVersion": "2.24.6",
"libVersion": "2.27.2",
"appid": "$APP_ID",
"projectname": "$PROJECT_NAME",
"simulatorType": "wechat",
......
import moduleHelper from './module-helper';
import response from './response';
import Audio from './audio.js'
const ads = {};
......@@ -105,6 +106,9 @@ export default {
errMsg: '',
...res,
}));
setTimeout(() => {
Audio.resumeWebAudio()
}, 0);
});
return key;
},
......@@ -244,6 +248,12 @@ export default {
ads[id].hide();
}
},
 WXADGetStyleValue(id, key) {
    if (!ads[id]) {
      return -1;
    }
    return ads[id].style[key]
  },
WXADDestroy(id) {
if (!ads[id]) {
return false;
......
import response from './response';
import moduleHelper from './module-helper';
function getDefaultData(canvas, conf) {
const config = JSON.parse(conf);
if (typeof config.x === 'undefined') {
config.x = 0;
}
if (typeof config.y === 'undefined') {
config.y = 0;
}
if (typeof config.width === 'undefined' || config.width === 0) {
config.width = canvas.width;
}
if (typeof config.height === 'undefined' || config.height === 0) {
config.height = canvas.height;
}
if (typeof config.destWidth === 'undefined' || config.destWidth === 0) {
config.destWidth = canvas.width;
}
if (typeof config.destHeight === 'undefined' || config.destHeight === 0) {
config.destHeight = canvas.height;
}
return config;
}
export default {
WXToTempFilePathSync(conf) {
return canvas.toTempFilePathSync(JSON.parse(conf));
return canvas.toTempFilePathSync(getDefaultData(canvas, conf));
},
WXToTempFilePath(conf, s, f, c) {
canvas.toTempFilePath({
...JSON.parse(conf),
...response.handleText(s, f, c),
success: (res) => {
moduleHelper.send('ToTempFilePathCallback', JSON.stringify({
callbackId: s,
errMsg: res.errMsg,
errCode: res.errCode,
tempFilePath: res.tempFilePath,
}));
},
});
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,
tempFilePath: res.tempFilePath,
}));
},
});
}
},
};
......@@ -20,7 +20,7 @@ import sdk from './sdk';
import camera from './camera';
import recorder from './recorder';
import uploadFile from './upload-file';
import './unity-adapter';
import gameRecorder from './game-recorder';
const unityVersion = '$unityVersion$';
GameGlobal.unityNamespace = GameGlobal.unityNamespace || {};
......@@ -102,6 +102,7 @@ const WXWASMSDK = {
...camera,
...recorder,
...uploadFile,
...gameRecorder
};
......
......@@ -372,6 +372,7 @@ export default {
},
GetScreenBrightnessSuccessCallbackOption:{
value:"int",
errMsg:"string",
},
GetSettingSuccessCallbackResult:{
authSetting:"AuthSetting",
......
......@@ -145,6 +145,25 @@ const mod = {
mod.reTryRemoteImageFile(path, width, height);
};
},
callbackPngFile(path, cid) {
var image = wx.createImage();
image.crossOrigin = '';
image.src = path;
image.onload = function() {
downloadedTextures[cid] = {
data: image,
tmpFile: ''
};
if (downloadingTextures[cid] instanceof Array) {
downloadingTextures[cid].forEach(v => v());
} else {
downloadingTextures[cid] && downloadingTextures[cid]();
}
delete downloadingTextures[cid];
delete downloadFailedTextures[cid];
delete downloadedTextures[cid];
};
},
downloadFile(path, width, height) {
var url = GameGlobal.manager.assetPath.replace(/\/$/, '') + '/Textures/png/' + width + "/" + path + '.png';
var cid = path;
......@@ -152,13 +171,39 @@ const mod = {
if (cache) {
mod.callbackPngFile(cache, cid);
} else {
var xmlhttp = new GameGlobal.unityNamespace.UnityLoader.UnityCache.XMLHttpRequest();
xmlhttp.responseType = 'arraybuffer';
xmlhttp.open("GET", url, true);
xmlhttp.onsave = (path) => {
mod.callbackPngFile(path, cid);
};
xmlhttp.send(null);
if(GameGlobal.unityNamespace.needCacheTextures){
var xmlhttp = new GameGlobal.unityNamespace.UnityLoader.UnityCache.XMLHttpRequest();
xmlhttp.responseType = 'arraybuffer';
xmlhttp.open("GET", url, true);
xmlhttp.onsave = function(path){
mod.callbackPngFile(path, cid);
}
xmlhttp.onerror = function() {
mod.reTryRemoteImageFile(path, width, height);
}
xmlhttp.send(null);
}else{
var image = wx.createImage();
image.crossOrigin = '';
image.src = url;
image.onload = function () {
downloadedTextures[cid] = {
data:image,
tmpFile:''
};
if(downloadingTextures[cid] instanceof Array){
downloadingTextures[cid].forEach(v=>v());
}else{
downloadingTextures[cid] && downloadingTextures[cid]();
}
delete downloadingTextures[cid];
delete downloadFailedTextures[cid];
delete downloadedTextures[cid];
};
image.onerror = function(){
mod.reTryRemoteImageFile(path,width,height);
};
}
}
},
readFile(textureId, callback, width, height) {
......
const WEBAudio = {
audioInstances: [],
audioContext: {},
audioWebEnabled: 0,
audioBufferInstances: [],
};
const disableAudio = false;
const disableAudioOptimization = false;
const UnityAdapter = {};
UnityAdapter._JS_Sound_Init = function () {
WEBAudio.audioWebEnabled = 0;
};
UnityAdapter._JS_Sound_Load = function (ptr, length) {
const sound = wx.createInnerAudioContext();
let soundIndex = -1;
for (let i = 0; i < WEBAudio.audioInstances.length; ++i) {
const audio = WEBAudio.audioInstances[i];
if (!audio) {
WEBAudio.audioInstances[i] = sound;
soundIndex = i;
break;
}
}
if (soundIndex === -1) {
soundIndex = WEBAudio.audioInstances.push(sound) - 1;
}
let soundBufferIndex = -1;
for (let i = 0; i < WEBAudio.audioBufferInstances.length; ++i) {
const audioBuffer = WEBAudio.audioBufferInstances[i];
if (audioBuffer.ptr === ptr && audioBuffer.length === length) {
sound.buffer = audioBuffer.filePath;
soundBufferIndex = i;
break;
}
}
if (soundBufferIndex === -1) {
soundBufferIndex =
WEBAudio.audioBufferInstances.push({
ptr,
length,
filePath: null,
}) - 1;
}
if (!WEBAudio.audioBufferInstances[soundBufferIndex].filePath) {
if (wx.createBufferURL && typeof wx.createBufferURL === 'function') {
const url = wx.createBufferURL(GameGlobal.unityNamespace.Module.HEAPU8.buffer.slice(ptr, ptr + length));
sound.buffer = url;
WEBAudio.audioBufferInstances[soundBufferIndex].filePath = url;
}
else {
const filePath = `${wx.env.USER_DATA_PATH}/audiowxgameaudio${soundBufferIndex}`;
wx.getFileSystemManager().writeFile({
filePath,
data: GameGlobal.unityNamespace.Module.HEAPU8.buffer.slice(ptr, ptr + length),
encoding: 'binary',
success() {
sound.buffer = filePath;
WEBAudio.audioBufferInstances[soundBufferIndex].filePath = filePath;
},
fail() {
sound.error = true;
},
});
}
}
return soundIndex;
};
UnityAdapter._JS_Sound_Create_Channel = function (_callback, _userData) {
if (disableAudio) {
return false;
}
let channelIndex = -1;
for (let i = 0; i < WEBAudio.audioInstances.length; ++i) {
const channel = WEBAudio.audioInstances[i];
if (!channel) {
WEBAudio.audioContext[i] = wx.createInnerAudioContext();
channelIndex = i;
break;
}
}
if (channelIndex === -1) {
channelIndex = WEBAudio.audioInstances.push(wx.createInnerAudioContext()) - 1;
}
return channelIndex;
};
UnityAdapter._JS_Sound_Play = function (bufferInstance, channelInstance, _offset, _delay) {
if (disableAudio) {
return false;
}
// stop sound which is playing in the channel currently.
// UnityAdapter._JS_Sound_Stop(channelInstance, 0);
let sound = WEBAudio.audioInstances[bufferInstance];
if (sound.buffer) {
sound = WEBAudio.audioInstances[bufferInstance];
const channel = WEBAudio.audioInstances[channelInstance];
channel.src = sound.buffer;
sound.duration = channel.duration;
if (channel.play) {
channel.play();
}
}
else {
console.log('play with null buffer');
}
return;
};
UnityAdapter._JS_Sound_SetLoop = function (channelInstance, loop) {
if (disableAudio) {
return false;
}
WEBAudio.audioInstances[channelInstance].loop = Boolean(loop);
return;
};
UnityAdapter._JS_Sound_Set3D = function (_channelInstance, _threeD) {
// console.log("not support in wxgame");
};
UnityAdapter._JS_Sound_Stop = function (channelInstance, delay) {
if (disableAudio) {
return false;
}
const audioInstance = WEBAudio.audioInstances[channelInstance];
if (delay === 0) {
if (audioInstance.stop) {
audioInstance.stop();
}
audioInstance.onEnded = function () { };
}
else {
setTimeout(() => {
if (audioInstance.stop) {
audioInstance.stop();
}
}, delay);
}
return;
};
const soundVolumeHandler = {};
UnityAdapter._JS_Sound_SetVolume = function (channelInstance, v) {
if (disableAudio) {
return false;
}
if (disableAudioOptimization) {
WEBAudio.audioInstances[channelInstance].volume = Number(v.toFixed(2));
return false;
}
if (soundVolumeHandler[channelInstance] === Number(v.toFixed(2))) {
return false;
}
soundVolumeHandler[channelInstance] = Number(v.toFixed(2));
WEBAudio.audioInstances[channelInstance].volume = Number(soundVolumeHandler[channelInstance]);
return;
};
UnityAdapter._JS_Sound_SetPitch = function (channelInstance, v) {
return; // todo 客户端有bug,先屏蔽,等客户端修复再打开
WEBAudio.audioInstances[channelInstance].playbackRate = v;
return;
};
UnityAdapter._JS_Sound_GetLoadState = function (bufferInstance) {
if (disableAudio) {
return false;
}
const sound = WEBAudio.audioInstances[bufferInstance];
if (sound.buffer)
return 0;
if (sound.error)
return 2;
return 1;
};
UnityAdapter._JS_Sound_ResumeIfNeeded = function () {
// 这里是页面点击的时候会来检查,这里不需要
};
UnityAdapter._JS_Sound_GetLength = function (bufferInstance) {
if (disableAudio) {
return false;
}
const sound = WEBAudio.audioInstances[bufferInstance];
return sound.duration;
};
UnityAdapter._JS_Sound_ReleaseInstance = function (instance) {
let audioInstance = WEBAudio.audioInstances[instance];
audioInstance.destroy && audioInstance.destroy();
audioInstance = null;
};
GameGlobal.unityNamespace.UnityAdapter = UnityAdapter;
......@@ -17,4 +17,7 @@ EditorBuildSettings:
- enabled: 1
path: Assets/Scenes/Recorder.unity
guid: 61476b21b30644ba3b6656f5633e7b3c
- enabled: 1
path: Assets/Scenes/GameRecorder.unity
guid: 7f727aa0bdd0740a8afa2675ed260003
m_configObjects: {}
m_EditorVersion: 2021.2.18f1c1
m_EditorVersionWithRevision: 2021.2.18f1c1 (20c61a5fa8bf)
m_EditorVersion: 2021.3.1f1c1
m_EditorVersionWithRevision: 2021.3.1f1c1 (0cb3bd085a01)
......@@ -9,13 +9,16 @@ EditorUserSettings:
value: 5a5757560101590a5d0c0e24427b5d44434e4c7a7b7a23677f2b4565b7b5353a
flags: 0
RecentlyUsedSceneGuid-1:
value: 5a5004505c0750020f5e0e7b14775c16404f4a7b742c7e6178284930b3e26760
value: 5552575556000a035a5b0e7542770d12441541797b717567297b4b61e4b3646c
flags: 0
RecentlyUsedSceneGuid-2:
value: 5500005153575b0a0f5d5c7444775d1145154e7c797e20657b7a4e36b5e2673b
value: 5a5004505c0750020f5e0e7b14775c16404f4a7b742c7e6178284930b3e26760
flags: 0
RecentlyUsedSceneGuid-3:
value: 5552575556000a035a5b0e7542770d12441541797b717567297b4b61e4b3646c
value: 5500005153575b0a0f5d5c7444775d1145154e7c797e20657b7a4e36b5e2673b
flags: 0
RecentlyUsedSceneGuid-4:
value: 545703545254080b0f0a087247770f114e161e2b7e7e7165282d4f65b2b0646b
flags: 0
vcSharedLogLevel:
value: 0d5e400f0650
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册