Skip to content

fix:生命周期添加说明 #985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions Demo/API_V2/Assets/API/Base/LifeCycle/LifeCycle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,31 @@

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<OnShowListenerResult> _onShow = (res) =>
{
var result = "onShow\n" + JsonMapper.ToJson(res);
var result = "OnShow\n" + JsonMapper.ToJson(res);
GameManager.Instance.detailsController.AddResult(
new ResultData() { initialContentText = result }
);
};

private readonly Action<GeneralCallbackResult> _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)
{
Expand All @@ -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()
Expand Down
18 changes: 12 additions & 6 deletions Demo/API_V2/Assets/API/Base/LifeCycle/LifeCycleSO.asset
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ MonoBehaviour:
m_EditorClassIdentifier:
entryScriptTypeName: LifeCycle
entryName: "\u751F\u547D\u5468\u671F"
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:
entryOrder: 2
8 changes: 8 additions & 0 deletions Demo/API_V2/Assets/API/Media/InnerAudio.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions Demo/API_V2/Assets/API/Media/InnerAudio/InnerAudio.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
11 changes: 11 additions & 0 deletions Demo/API_V2/Assets/API/Media/InnerAudio/InnerAudio.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions Demo/API_V2/Assets/API/Media/InnerAudio/InnerAudioSO.asset
Original file line number Diff line number Diff line change
@@ -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: fb48e4613a53bb941a20036d7c08fefb, type: 3}
m_Name: InnerAudioSO
m_EditorClassIdentifier:
entryScriptTypeName: InnerAudio
entryName: "\u97F3\u9891\u793A\u4F8B"
entryAPI:
entryDescription:
optionList: []
initialButtonText: "\u64AD\u653E\u97F3\u9891"
extraButtonList:
- buttonText: "\u6682\u505C"
- buttonText: "\u505C\u6B62"
- buttonText: "\u8DF3\u8F6C"
initialResultList: []
entryOrder: 0

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Demo/API_V2/Assets/API/Media/MediaSO.asset
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ MonoBehaviour:
categorySprite: {fileID: 21300000, guid: 10009e080ceca4d88b96fcdff0749dfc, type: 3}
entryList:
- {fileID: 11400000, guid: 1d998af43281d4eee9e1effc8f83bddd, type: 2}
- {fileID: 11400000, guid: fc3a7d7719412264b914d0ae6e094405, type: 2}
- {fileID: 11400000, guid: 1055cfc5cdda7407298fa2ff9997d0c6, type: 2}
- {fileID: 11400000, guid: 480646e3cd4d6a948a7538d483c1b043, type: 2}
- {fileID: 11400000, guid: ad04526c3748b4e2b8498f998dfea973, type: 2}
Expand Down
Loading
Loading