From b9e724aff9c5a69eb20c6a93185bdb0d07b120c5 Mon Sep 17 00:00:00 2001 From: rainhong Date: Thu, 24 Jul 2025 15:03:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(APIV2):=20=E9=85=8D=E7=BD=AE=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Demo/API_V2/Assets/WX-WASM-SDK-V2/Editor/MiniGameConfig.asset | 2 ++ Demo/API_V2/Packages/manifest.json | 2 +- Demo/API_V2/Packages/packages-lock.json | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Demo/API_V2/Assets/WX-WASM-SDK-V2/Editor/MiniGameConfig.asset b/Demo/API_V2/Assets/WX-WASM-SDK-V2/Editor/MiniGameConfig.asset index 8a9e69c7a..2ae88a18b 100644 --- a/Demo/API_V2/Assets/WX-WASM-SDK-V2/Editor/MiniGameConfig.asset +++ b/Demo/API_V2/Assets/WX-WASM-SDK-V2/Editor/MiniGameConfig.asset @@ -19,6 +19,7 @@ MonoBehaviour: assetLoadType: 1 compressDataPackage: 1 VideoUrl: + relativeDST: DST: StreamCDN: bundleHashLength: 32 @@ -65,6 +66,7 @@ MonoBehaviour: enablePerfAnalysis: 0 iOSAutoGCInterval: 10000 enableIOSPerformancePlus: 0 + enableiOSMetal: 0 brotliMT: 0 enableWasm2023: 0 CompressTexture: diff --git a/Demo/API_V2/Packages/manifest.json b/Demo/API_V2/Packages/manifest.json index 711cb3750..55fb4d08d 100644 --- a/Demo/API_V2/Packages/manifest.json +++ b/Demo/API_V2/Packages/manifest.json @@ -7,7 +7,7 @@ "com.unity.ai.navigation": "1.1.5", "com.unity.analytics": "3.8.1", "com.unity.collab-proxy": "2.2.0", - "com.unity.ide.rider": "3.0.26", + "com.unity.ide.rider": "3.0.36", "com.unity.ide.visualstudio": "2.0.22", "com.unity.ide.vscode": "1.2.5", "com.unity.purchasing": "4.9.3", diff --git a/Demo/API_V2/Packages/packages-lock.json b/Demo/API_V2/Packages/packages-lock.json index af50e71b6..a02a04dba 100644 --- a/Demo/API_V2/Packages/packages-lock.json +++ b/Demo/API_V2/Packages/packages-lock.json @@ -65,7 +65,7 @@ "url": "https://packages.unity.com" }, "com.unity.ide.rider": { - "version": "3.0.26", + "version": "3.0.36", "depth": 0, "source": "registry", "dependencies": { From a0eb8bdc7768aca8f0fccd1a006e9572e9a8947b Mon Sep 17 00:00:00 2001 From: rainhong Date: Fri, 25 Jul 2025 17:28:01 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat(APIV2):=20WX=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E9=87=8D=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Demo/API_V2/Assets/API/Media/MediaSO.asset | 1 + .../WXVideo.meta => Media/Video.meta} | 2 +- Demo/API_V2/Assets/API/Media/Video/Video.cs | 133 ++ .../Video/Video.cs.meta} | 2 +- .../Assets/API/Media/Video/VideoSO.asset | 146 ++ .../Video/VideoSO.asset.meta} | 2 +- .../InputField/TmpTextInit.cs | 2 +- .../API/NativeVideo/NativeVideoSO.asset | 1 - .../Assets/API/NativeVideo/WXVideo/WXVideo.cs | 57 - .../API/NativeVideo/WXVideo/WXVideoSO.asset | 16 - .../Render/ToTempFilePath/ToTempFilePath.cs | 32 +- Demo/API_V2/Assets/Scenes/WXVideoScene.unity | 1984 ----------------- .../Assets/Scenes/WXVideoScene.unity.meta | 7 - .../Assets/Scripts/DetailsEntry/Details.cs | 57 +- Demo/API_V2/Assets/Scripts/GameManager.cs | 8 +- .../Editor/MiniGameConfig.asset | 20 +- Demo/API_V2/Packages/manifest.json | 2 +- Demo/API_V2/Packages/packages-lock.json | 4 +- .../ProjectSettings/EditorBuildSettings.asset | 3 - 19 files changed, 368 insertions(+), 2111 deletions(-) rename Demo/API_V2/Assets/API/{NativeVideo/WXVideo.meta => Media/Video.meta} (77%) create mode 100644 Demo/API_V2/Assets/API/Media/Video/Video.cs rename Demo/API_V2/Assets/API/{NativeVideo/WXVideo/WXVideo.cs.meta => Media/Video/Video.cs.meta} (83%) create mode 100644 Demo/API_V2/Assets/API/Media/Video/VideoSO.asset rename Demo/API_V2/Assets/API/{NativeVideo/WXVideo/WXVideoSO.asset.meta => Media/Video/VideoSO.asset.meta} (79%) delete mode 100644 Demo/API_V2/Assets/API/NativeVideo/WXVideo/WXVideo.cs delete mode 100644 Demo/API_V2/Assets/API/NativeVideo/WXVideo/WXVideoSO.asset delete mode 100644 Demo/API_V2/Assets/Scenes/WXVideoScene.unity delete mode 100644 Demo/API_V2/Assets/Scenes/WXVideoScene.unity.meta diff --git a/Demo/API_V2/Assets/API/Media/MediaSO.asset b/Demo/API_V2/Assets/API/Media/MediaSO.asset index d33fc71f1..7e7ba02a2 100644 --- a/Demo/API_V2/Assets/API/Media/MediaSO.asset +++ b/Demo/API_V2/Assets/API/Media/MediaSO.asset @@ -20,6 +20,7 @@ MonoBehaviour: - {fileID: 11400000, guid: 1055cfc5cdda7407298fa2ff9997d0c6, type: 2} - {fileID: 11400000, guid: 480646e3cd4d6a948a7538d483c1b043, type: 2} - {fileID: 11400000, guid: ad04526c3748b4e2b8498f998dfea973, type: 2} + - {fileID: 11400000, guid: 74a62098b548c4c9e985d91d4f60bcb9, type: 2} - {fileID: 11400000, guid: 38b7b2300105146ce94a785a915252de, type: 2} - {fileID: 11400000, guid: 04a7c5dbfc2464252841043ba677dcab, type: 2} categoryOrder: 9 diff --git a/Demo/API_V2/Assets/API/NativeVideo/WXVideo.meta b/Demo/API_V2/Assets/API/Media/Video.meta similarity index 77% rename from Demo/API_V2/Assets/API/NativeVideo/WXVideo.meta rename to Demo/API_V2/Assets/API/Media/Video.meta index 51612fd63..76f83812d 100644 --- a/Demo/API_V2/Assets/API/NativeVideo/WXVideo.meta +++ b/Demo/API_V2/Assets/API/Media/Video.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 3871f3583d0374d0ba711452505caa5d +guid: 9fe9f477259b04f18b8c4f9bd2c7ef64 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Demo/API_V2/Assets/API/Media/Video/Video.cs b/Demo/API_V2/Assets/API/Media/Video/Video.cs new file mode 100644 index 000000000..3d7e93f04 --- /dev/null +++ b/Demo/API_V2/Assets/API/Media/Video/Video.cs @@ -0,0 +1,133 @@ +using System; +using LitJson; +using UnityEngine; +using WeChatWASM; + +public class Video : Details +{ + private WXVideo _video; + + private readonly Action _onEnded = () => + { + const string result = "【Video】OnEnded"; + GameManager.Instance.detailsController.AddResult( + new ResultData() { initialContentText = result } + ); + }; + private readonly Action _onError = (res) => + { + var result = "【Video】OnError: " + JsonMapper.ToJson(res); + GameManager.Instance.detailsController.AddResult( + new ResultData() { initialContentText = result } + ); + }; + private readonly Action _onPause = () => + { + const string result = "【Video】OnPause"; + GameManager.Instance.detailsController.AddResult( + new ResultData() { initialContentText = result } + ); + }; + private readonly Action _onPlay = () => + { + const string result = "【Video】OnPlay"; + GameManager.Instance.detailsController.AddResult( + new ResultData() { initialContentText = result } + ); + }; + private readonly Action _onProgress = (res) => + { + var result = "【Video】OnProgress: " + JsonMapper.ToJson(res); + GameManager.Instance.detailsController.AddResult( + new ResultData() { initialContentText = result } + ); + }; + private readonly Action _onTimeUpdate = (res) => + { + var result = "【Video】OnTimeUpdate: " + JsonMapper.ToJson(res); + GameManager.Instance.detailsController.AddResult( + new ResultData() { initialContentText = result } + ); + }; + private readonly Action _onWaiting = () => + { + const string result = "【Video】OnWaiting"; + GameManager.Instance.detailsController.AddResult( + new ResultData() { initialContentText = result } + ); + }; + + private void Start() + { + GameManager.Instance.detailsController.BindExtraButtonAction(0, ChangeMuteState); + } + + // 创建视频 + protected override void TestAPI(string[] args) + { + if (_video != null) + { + _video.Destroy(); + } + var createVideoOption = new CreateVideoOption() + { + x = GetOptionValue(0), + y = GetOptionValue(1), + width = GetOptionValue(2), + height = GetOptionValue(3), + src = args[4] == "示例视频" ? "http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400" : "", + poster = args[5] == "示例封面" ? "https://mmgame.qpic.cn/image/b4e70a6cba5ccad456667d85c3c0ea3c02e4f879a9705ed75071595a3e9f4ca0/0" : "", + initialTime = GetOptionValue(6), + playbackRate = GetOptionValue(7), + live = GetOptionValue(8), + objectFit = GetOptionString(9), + controls = GetOptionValue(10), + showProgress = GetOptionValue(11), + showProgressInControlMode = GetOptionValue(12), + backgroundColor = GetOptionString(13), + autoplay = GetOptionValue(14), + loop = GetOptionValue(15), + muted = GetOptionValue(16), + obeyMuteSwitch = GetOptionValue(17), + enableProgressGesture = GetOptionValue(18), + enablePlayGesture = GetOptionValue(19), + showCenterPlayBtn = GetOptionValue(20), + underGameView = GetOptionValue(21), + autoPauseIfNavigate = GetOptionValue(22), + autoPauseIfOpenNative = GetOptionValue(23), + }; + _video = WX.CreateVideo(createVideoOption); + _video.OnEnded(_onEnded); + _video.OnError(_onError); + _video.OnPause(_onPause); + _video.OnPlay(_onPlay); + _video.OnProgress(_onProgress); + _video.OnTimeUpdate(_onTimeUpdate); + _video.OnWaiting(_onWaiting); + } + + private void ChangeMuteState() + { + if (_video == null) + { + WX.ShowModal(new ShowModalOption() { content = "请先创建视频" }); + return; + } + + // 确保 muted 属性存在 + _video.muted ??= false; + + _video.muted = !_video.muted.Value; + GameManager.Instance.detailsController.ChangeExtraButtonText(0, _video.muted.Value ? "取消静音" : "静音"); + var result = "【Video】Mute state changed: " + _video.muted.Value; + WX.ShowModal(new ShowModalOption() { content = result }); + } + + private void OnDestroy() + { + if (_video != null) + { + _video.Destroy(); + } + } +} diff --git a/Demo/API_V2/Assets/API/NativeVideo/WXVideo/WXVideo.cs.meta b/Demo/API_V2/Assets/API/Media/Video/Video.cs.meta similarity index 83% rename from Demo/API_V2/Assets/API/NativeVideo/WXVideo/WXVideo.cs.meta rename to Demo/API_V2/Assets/API/Media/Video/Video.cs.meta index 401a818e9..e399df500 100644 --- a/Demo/API_V2/Assets/API/NativeVideo/WXVideo/WXVideo.cs.meta +++ b/Demo/API_V2/Assets/API/Media/Video/Video.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: b6f50f478ae16468fad92af4f7c5b7ee +guid: 5891aaa249e0740f1a0ba77397d39844 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Demo/API_V2/Assets/API/Media/Video/VideoSO.asset b/Demo/API_V2/Assets/API/Media/Video/VideoSO.asset new file mode 100644 index 000000000..a2c7304ba --- /dev/null +++ b/Demo/API_V2/Assets/API/Media/Video/VideoSO.asset @@ -0,0 +1,146 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 57c8415214254e23a63d9bfb8c6bbf62, type: 3} + m_Name: VideoSO + m_EditorClassIdentifier: + entryName: "\u89C6\u9891" + entryOrder: 0 + entryScriptTypeName: Video + entryAPI: CreateVideo + entryDescription: "\u521B\u5EFA\u89C6\u9891" + optionList: + - optionName: x + availableOptions: + - null + - 0 + - 100 + - optionName: y + availableOptions: + - null + - 0 + - 100 + - optionName: width + availableOptions: + - null + - 0 + - 100 + - optionName: height + availableOptions: + - null + - 0 + - 100 + - optionName: src + availableOptions: + - "\u793A\u4F8B\u89C6\u9891" + - optionName: poster + availableOptions: + - null + - "\u793A\u4F8B\u5C01\u9762" + - optionName: initialTime + availableOptions: + - null + - 0 + - 100 + - optionName: playbackRate + availableOptions: + - null + - 0.5 + - 0.8 + - 1.0 + - 1.25 + - 1.5 + - optionName: live + availableOptions: + - null + - false + - true + - optionName: objectFit + availableOptions: + - null + - fill + - contain + - cover + - optionName: controls + availableOptions: + - null + - false + - true + - optionName: showProgress + availableOptions: + - null + - false + - true + - optionName: showProgressInControlMode + availableOptions: + - null + - false + - true + - optionName: backgroundColor + availableOptions: + - null + - '#000000' + - '#FFFFFFF' + - '#07C160' + - optionName: autoplay + availableOptions: + - null + - false + - true + - optionName: loop + availableOptions: + - null + - false + - true + - optionName: muted + availableOptions: + - null + - false + - true + - optionName: obeyMuteSwitch + availableOptions: + - null + - false + - true + - optionName: enableProgressGesture + availableOptions: + - null + - false + - true + - optionName: enablePlayGesture + availableOptions: + - null + - false + - true + - optionName: showCenterPlayBtn + availableOptions: + - null + - false + - true + - optionName: underGameView + availableOptions: + - null + - false + - true + - optionName: autoPauseIfNavigate + availableOptions: + - null + - false + - true + - optionName: autoPauseIfOpenNative + availableOptions: + - null + - false + - true + initialButtonText: "\u521B\u5EFA\u89C6\u9891" + extraButtonList: + - buttonText: "\u9759\u97F3" + initialResultList: [] diff --git a/Demo/API_V2/Assets/API/NativeVideo/WXVideo/WXVideoSO.asset.meta b/Demo/API_V2/Assets/API/Media/Video/VideoSO.asset.meta similarity index 79% rename from Demo/API_V2/Assets/API/NativeVideo/WXVideo/WXVideoSO.asset.meta rename to Demo/API_V2/Assets/API/Media/Video/VideoSO.asset.meta index d595d3d4e..0f2735018 100644 --- a/Demo/API_V2/Assets/API/NativeVideo/WXVideo/WXVideoSO.asset.meta +++ b/Demo/API_V2/Assets/API/Media/Video/VideoSO.asset.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: ebd496025e81f434bb6b5b487cfbf2ed +guid: 74a62098b548c4c9e985d91d4f60bcb9 NativeFormatImporter: externalObjects: {} mainObjectFileID: 11400000 diff --git a/Demo/API_V2/Assets/API/NativeInputField/InputField/TmpTextInit.cs b/Demo/API_V2/Assets/API/NativeInputField/InputField/TmpTextInit.cs index dd5985ff2..ee3225860 100644 --- a/Demo/API_V2/Assets/API/NativeInputField/InputField/TmpTextInit.cs +++ b/Demo/API_V2/Assets/API/NativeInputField/InputField/TmpTextInit.cs @@ -19,7 +19,7 @@ private void Start() // 如果 GameManager 的字体已经加载,直接设置 Text 的字体 if (GameManager.Instance.font != null) { - _text.font = GameManager.Instance.fonts; + _text.font = GameManager.Instance.TMP_font; } else { diff --git a/Demo/API_V2/Assets/API/NativeVideo/NativeVideoSO.asset b/Demo/API_V2/Assets/API/NativeVideo/NativeVideoSO.asset index a928a6271..270471374 100644 --- a/Demo/API_V2/Assets/API/NativeVideo/NativeVideoSO.asset +++ b/Demo/API_V2/Assets/API/NativeVideo/NativeVideoSO.asset @@ -18,5 +18,4 @@ MonoBehaviour: entryList: - {fileID: 11400000, guid: 5073e277b29d95642abb3c49fe94eea0, type: 2} - {fileID: 11400000, guid: 27654a238f98e4f7e8756e4caed418e1, type: 2} - - {fileID: 11400000, guid: ebd496025e81f434bb6b5b487cfbf2ed, type: 2} categoryOrder: 0 diff --git a/Demo/API_V2/Assets/API/NativeVideo/WXVideo/WXVideo.cs b/Demo/API_V2/Assets/API/NativeVideo/WXVideo/WXVideo.cs deleted file mode 100644 index dcbd8e81d..000000000 --- a/Demo/API_V2/Assets/API/NativeVideo/WXVideo/WXVideo.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.UI; -using WeChatWASM; - -public class WXvideo : MonoBehaviour -{ - private WXVideo _video; - - // Start is called before the first frame update - void Start() - { - var btn = this.GetComponent