diff --git a/Demo/API_V2/Assets/API/Base/LifeCycle/LifeCycle.cs b/Demo/API_V2/Assets/API/Base/LifeCycle/LifeCycle.cs index 932e63af..2ed34325 100644 --- a/Demo/API_V2/Assets/API/Base/LifeCycle/LifeCycle.cs +++ b/Demo/API_V2/Assets/API/Base/LifeCycle/LifeCycle.cs @@ -6,11 +6,17 @@ public class LifeCycle : Details { + private void Start() + { + // 绑定额外的按钮操作 + GameManager.Instance.detailsController.BindExtraButtonAction(0, getLaunchOptionsSync); + GameManager.Instance.detailsController.BindExtraButtonAction(1, getEnterOptionsSync); + } private bool _isListening = false; private readonly Action _onShow = (res) => { - var result = "onShow\n" + JsonMapper.ToJson(res); + var result = "OnShow\n" + JsonMapper.ToJson(res); GameManager.Instance.detailsController.AddResult( new ResultData() { initialContentText = result } ); @@ -18,12 +24,13 @@ public class LifeCycle : Details private readonly Action _onHide = (res) => { - var result = "onHide\n" + JsonMapper.ToJson(res); + var result = "OnHide\n" + JsonMapper.ToJson(res); GameManager.Instance.detailsController.AddResult( new ResultData() { initialContentText = result } ); }; + // 测试 API protected override void TestAPI(string[] args) { @@ -39,8 +46,27 @@ protected override void TestAPI(string[] args) } _isListening = !_isListening; GameManager.Instance.detailsController.ChangeInitialButtonText( - _isListening ? "取消监听" : "开始监听" + _isListening ? "取消监听hide/show事件" : "开始监听hide/show事件" + ); + } + + public void getLaunchOptionsSync() + { + var LaunchOptionsSync = WX.GetLaunchOptionsSync(); + var result = "GetLaunchOptionsSync\n" + JsonMapper.ToJson(LaunchOptionsSync); + GameManager.Instance.detailsController.AddResult( + new ResultData() { initialContentText = result } + ); + } + + public void getEnterOptionsSync() + { + var EnterOptionsSync = WX.GetEnterOptionsSync(); + var result = "GetEnterOptionsSync\n" + JsonMapper.ToJson(EnterOptionsSync); + GameManager.Instance.detailsController.AddResult( + new ResultData() { initialContentText = result } ); + } private void OnDestroy() diff --git a/Demo/API_V2/Assets/API/Base/LifeCycle/LifeCycleSO.asset b/Demo/API_V2/Assets/API/Base/LifeCycle/LifeCycleSO.asset index 7799a14b..135cf925 100644 --- a/Demo/API_V2/Assets/API/Base/LifeCycle/LifeCycleSO.asset +++ b/Demo/API_V2/Assets/API/Base/LifeCycle/LifeCycleSO.asset @@ -15,11 +15,17 @@ MonoBehaviour: entryName: "\u751F\u547D\u5468\u671F" entryOrder: 2 entryScriptTypeName: LifeCycle - entryAPI: 'onHide | onShow + entryAPI: 'OnHide | OnShow - offHIde | offHide' - entryDescription: + OffHide | OffShow' + entryDescription: "OnHide\uFF1A\u76D1\u542C\u5C0F\u6E38\u620F\u9690\u85CF\u5230\u540E\u53F0\nOnShow\uFF1A\u76D1\u542C\u5C0F\u6E38\u620F\u56DE\u5230\u524D\u53F0\u7684\u4E8B\u4EF6\nOffHide + / OffShow : \u79FB\u9664\u76D1\u542C" optionList: [] - initialButtonText: "\u5F00\u59CB\u76D1\u542C" - extraButtonList: [] - initialResultList: [] + initialButtonText: "\u5F00\u59CB\u76D1\u542Chide/show\u4E8B\u4EF6" + extraButtonList: + - buttonText: "\u83B7\u53D6\u5C0F\u6E38\u620F\u51B7\u542F\u52A8\u53C2\u6570" + - buttonText: "\u83B7\u53D6\u5C0F\u6E38\u620F\u6253\u5F00\u7684\u53C2\u6570" + initialResultList: + - isDisableInitially: 0 + initialTitleText: + initialContentText: diff --git a/Demo/API_V2/Assets/API/Media/InnerAudio.meta b/Demo/API_V2/Assets/API/Media/InnerAudio.meta new file mode 100644 index 00000000..e8f6b36b --- /dev/null +++ b/Demo/API_V2/Assets/API/Media/InnerAudio.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cd9da7ec11585544998b4c9e6e9433f2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Demo/API_V2/Assets/API/Media/InnerAudio/InnerAudio.cs b/Demo/API_V2/Assets/API/Media/InnerAudio/InnerAudio.cs new file mode 100644 index 00000000..450df442 --- /dev/null +++ b/Demo/API_V2/Assets/API/Media/InnerAudio/InnerAudio.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using LitJson; +using UnityEngine; +using WeChatWASM; + +public class InnerAudio : Details +{ + WXInnerAudioContext music; + private void Start() + { + // 绑定额外的按钮操作 + GameManager.Instance.detailsController.BindExtraButtonAction(0, pause); + GameManager.Instance.detailsController.BindExtraButtonAction(1, stop); + GameManager.Instance.detailsController.BindExtraButtonAction(2, seek); + } + + protected override void TestAPI(string[] args) + { + music = WX.CreateInnerAudioContext(new InnerAudioContextParam() { + src = "https://res.wx.qq.com/wechatgame/product/webpack/userupload/20220901/211827/CallMeTeenTop.mp3", + needDownload = true //表示等下载完之后再播放,便于后续复用,无延迟 + }); + music.OnCanplay(() => + { + Debug.Log("OnCanplay"); + music.Play(); + }); + } + + + //暂停 + public void pause() + { + Debug.Log("pause"); + music.Pause(); + } + + //停止 + public void stop() + { + Debug.Log("stop"); + music.Stop(); + + } + + //跳转 + public void seek() + { + + Debug.Log("seek"); + music.Seek(3); + } + + private void OnDestroy() + { + Debug.Log("音频示例 OnDestroy"); + music.Stop(); + music.Destroy(); + } +} diff --git a/Demo/API_V2/Assets/API/Media/InnerAudio/InnerAudio.cs.meta b/Demo/API_V2/Assets/API/Media/InnerAudio/InnerAudio.cs.meta new file mode 100644 index 00000000..22aa981e --- /dev/null +++ b/Demo/API_V2/Assets/API/Media/InnerAudio/InnerAudio.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d34440f857f826341a067af6e2496220 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Demo/API_V2/Assets/API/Media/InnerAudio/InnerAudioSO.asset b/Demo/API_V2/Assets/API/Media/InnerAudio/InnerAudioSO.asset new file mode 100644 index 00000000..c5fce969 --- /dev/null +++ b/Demo/API_V2/Assets/API/Media/InnerAudio/InnerAudioSO.asset @@ -0,0 +1,26 @@ +%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: InnerAudioSO + m_EditorClassIdentifier: + entryName: "\u97F3\u9891" + entryOrder: 0 + entryScriptTypeName: InnerAudio + entryAPI: WX.CreateInnerAudioContext + entryDescription: + optionList: [] + initialButtonText: "\u64AD\u653E" + extraButtonList: + - buttonText: "\u6682\u505C" + - buttonText: "\u505C\u6B62" + - buttonText: "\u8DF3\u8F6C" + initialResultList: [] diff --git a/Demo/API_V2/Assets/API/Media/InnerAudio/InnerAudioSO.asset.meta b/Demo/API_V2/Assets/API/Media/InnerAudio/InnerAudioSO.asset.meta new file mode 100644 index 00000000..eaddebf2 --- /dev/null +++ b/Demo/API_V2/Assets/API/Media/InnerAudio/InnerAudioSO.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0a7c9b9ec3936214887602ce8fa8ab53 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Demo/API_V2/Assets/API/Media/MediaSO.asset b/Demo/API_V2/Assets/API/Media/MediaSO.asset index d33fc71f..a025235f 100644 --- a/Demo/API_V2/Assets/API/Media/MediaSO.asset +++ b/Demo/API_V2/Assets/API/Media/MediaSO.asset @@ -17,6 +17,7 @@ MonoBehaviour: categorySprite: {fileID: 21300000, guid: 10009e080ceca4d88b96fcdff0749dfc, type: 3} entryList: - {fileID: 11400000, guid: 1d998af43281d4eee9e1effc8f83bddd, type: 2} + - {fileID: 11400000, guid: 0a7c9b9ec3936214887602ce8fa8ab53, type: 2} - {fileID: 11400000, guid: 1055cfc5cdda7407298fa2ff9997d0c6, type: 2} - {fileID: 11400000, guid: 480646e3cd4d6a948a7538d483c1b043, type: 2} - {fileID: 11400000, guid: ad04526c3748b4e2b8498f998dfea973, type: 2} diff --git a/Demo/API_V2/Assets/Scenes/MainScene.unity b/Demo/API_V2/Assets/Scenes/MainScene.unity index 8420af92..caa0f150 100644 --- a/Demo/API_V2/Assets/Scenes/MainScene.unity +++ b/Demo/API_V2/Assets/Scenes/MainScene.unity @@ -6926,7 +6926,7 @@ LightingSettings: m_AlbedoBoost: 1 m_IndirectOutputScale: 1 m_UsingShadowmask: 1 - m_BakeBackend: 2 + m_BakeBackend: 1 m_LightmapMaxSize: 512 m_BakeResolution: 10 m_Padding: 2 @@ -47012,6 +47012,81 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2064680149} m_CullTransparentMesh: 0 +--- !u!1 &2070383677 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2070383678} + - component: {fileID: 2070383680} + - component: {fileID: 2070383679} + m_Layer: 5 + m_Name: Arrow + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2070383678 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2070383677} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.7, y: 0.7, z: 0.7} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1155040624} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 1, y: 0.5} + m_AnchorMax: {x: 1, y: 0.5} + m_AnchoredPosition: {x: -25, y: 0} + m_SizeDelta: {x: 72, y: 72} + m_Pivot: {x: 1, y: 0.5} +--- !u!114 &2070383679 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2070383677} + 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: 21300000, guid: b1a5e6c3cca1748e0a56f2485c899ceb, type: 3} + m_Type: 0 + 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 &2070383680 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2070383677} + m_CullTransparentMesh: 0 --- !u!1 &2072623566 GameObject: m_ObjectHideFlags: 0