Skip to content

Commit aae7260

Browse files
authored
Merge pull request #719 from wumeibanfa/feat/demo-test
Feat/demo test
2 parents 0f4bfe5 + ae4112a commit aae7260

34 files changed

+4111
-876
lines changed

Demo/API_V2/Assets/API/Audio/AudioManager.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using UnityEngine;
2-
2+
using UnityEngine.Networking;
33
public class AudioManager : MonoBehaviour
44
{
55
public AudioSource AudioSource;
@@ -39,4 +39,11 @@ public void Stop()
3939
{
4040
AudioSource.Stop();
4141
}
42+
43+
public void playDelayed()
44+
{
45+
AudioSource.clip = AudioClipLong;
46+
AudioSource.loop = true;
47+
AudioSource.PlayDelayed(3);
48+
}
4249
}

Demo/API_V2/Assets/API/Base/BaseSO.asset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ MonoBehaviour:
2020
- {fileID: 11400000, guid: 29b8eb105fe9d400f9a79bdb140e85c9, type: 2}
2121
- {fileID: 11400000, guid: 3996b93c3d76d47088845abcebf960fb, type: 2}
2222
- {fileID: 11400000, guid: 9d4267fc1b8274349a253ca28e0340d7, type: 2}
23+
- {fileID: 11400000, guid: e6944788ab3d04858bc3c6cf1f2f7273, type: 2}
2324
- {fileID: 11400000, guid: e535490610e214b1cabe9378cb46ea5a, type: 2}

Demo/API_V2/Assets/API/Base/RealtimeLog.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using LitJson;
4+
using UnityEngine;
5+
using WeChatWASM;
6+
7+
public class RealtimeLog : Details
8+
{
9+
private WXRealtimeLogManager _log;
10+
11+
private void Start()
12+
{
13+
_log = WX.GetRealtimeLogManager();
14+
_log.AddFilterMsg("test");
15+
16+
GameManager.Instance.detailsController.BindExtraButtonAction(0, warn);
17+
GameManager.Instance.detailsController.BindExtraButtonAction(1, error);
18+
}
19+
20+
// 测试 API
21+
protected override void TestAPI(string[] args)
22+
{
23+
_log.Info("info msg");
24+
}
25+
26+
private void error() {
27+
_log.Error("error msg");
28+
}
29+
30+
private void warn() {
31+
_log.Warn("warn msg");
32+
}
33+
}

Demo/API_V2/Assets/script.cs.meta renamed to Demo/API_V2/Assets/API/Base/RealtimeLog/RealtimeLog.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: fb48e4613a53bb941a20036d7c08fefb, type: 3}
13+
m_Name: RealtimeLogSO
14+
m_EditorClassIdentifier:
15+
entryScriptTypeName: RealtimeLog
16+
entryName: "\u5B9E\u65F6\u65E5\u5FD7"
17+
entryAPI:
18+
entryDescription:
19+
optionList: []
20+
initialButtonText: "\u4E0A\u4F20info\u65E5\u5FD7"
21+
extraButtonList:
22+
- buttonText: "\u4E0A\u4F20warn\u65E5\u5FD7"
23+
- buttonText: "\u4E0A\u4F20error\u65E5\u5FD7"
24+
initialResultList: []

Demo/API_V2/Assets/API/Base/RealtimeLog/RealtimeLogSO.asset.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Demo/API_V2/Assets/API/Facility/Keyboard/Keyboard.cs

Lines changed: 76 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,74 +9,89 @@ public class Keyboard : Details
99
private bool _isListening = false;
1010
private System.Random random = new System.Random();
1111

12-
private readonly Action<OnKeyDownListenerResult> _onKeyUp = (res) => {
12+
private readonly Action<OnKeyDownListenerResult> _onKeyUp = (res) =>
13+
{
1314
var result = "onKeyUp\n" + JsonMapper.ToJson(res);
1415
GameManager.Instance.detailsController.AddResult(new ResultData()
1516
{
1617
initialContentText = result
1718
});
1819
};
1920

20-
private readonly Action<OnKeyDownListenerResult> _onKeyDown = (res) => {
21+
private readonly Action<OnKeyDownListenerResult> _onKeyDown = (res) =>
22+
{
2123
var result = "onKeyDown\n" + JsonMapper.ToJson(res);
2224
GameManager.Instance.detailsController.AddResult(new ResultData()
2325
{
2426
initialContentText = result
2527
});
2628
};
2729

28-
private readonly Action<OnKeyboardInputListenerResult> _onKeyboardInput = (res) => {
30+
private readonly Action<OnKeyboardInputListenerResult> _onKeyboardInput = (res) =>
31+
{
2932
var result = "onKeyboardInput\n" + JsonMapper.ToJson(res);
3033
GameManager.Instance.detailsController.AddResult(new ResultData()
3134
{
3235
initialContentText = result
3336
});
3437
};
3538

36-
private readonly Action<OnKeyboardInputListenerResult> _onKeyboardComplete = (res) => {
39+
private readonly Action<OnKeyboardInputListenerResult> _onKeyboardComplete = (res) =>
40+
{
3741
var result = "onKeyboardComplete\n" + JsonMapper.ToJson(res);
3842
GameManager.Instance.detailsController.AddResult(new ResultData()
3943
{
4044
initialContentText = result
4145
});
4246
};
4347

44-
private readonly Action<OnKeyboardInputListenerResult> _onKeyboardConfirm = (res) => {
48+
private readonly Action<OnKeyboardInputListenerResult> _onKeyboardConfirm = (res) =>
49+
{
4550
var result = "onKeyboardConfirm\n" + JsonMapper.ToJson(res);
4651
GameManager.Instance.detailsController.AddResult(new ResultData()
4752
{
4853
initialContentText = result
4954
});
5055
};
5156

52-
private readonly Action<OnKeyboardHeightChangeListenerResult> _onKeyboardHeightChange = (res) => {
57+
private readonly Action<OnKeyboardHeightChangeListenerResult> _onKeyboardHeightChange = (res) =>
58+
{
5359
var result = "onKeyboardHeightChange\n" + JsonMapper.ToJson(res);
5460
GameManager.Instance.detailsController.AddResult(new ResultData()
5561
{
5662
initialContentText = result
5763
});
5864
};
59-
65+
6066

6167
private void Start()
6268
{
6369
// 绑定额外的按钮操作
6470
GameManager.Instance.detailsController.BindExtraButtonAction(0, showKeyboard);
6571
GameManager.Instance.detailsController.BindExtraButtonAction(1, updateKeyboard);
6672
GameManager.Instance.detailsController.BindExtraButtonAction(2, hideKeyboard);
73+
GameManager.Instance.detailsController.BindExtraButtonAction(3, listening);
6774
}
6875

6976
// 测试 API
7077
protected override void TestAPI(string[] args)
7178
{
72-
if (!_isListening) {
79+
showMultipleKeyboard();
80+
}
81+
82+
public void listening()
83+
{
84+
if (!_isListening)
85+
{
7386
WX.OnKeyUp(_onKeyUp);
7487
WX.OnKeyDown(_onKeyDown);
7588
WX.OnKeyboardInput(_onKeyboardInput);
7689
WX.OnKeyboardHeightChange(_onKeyboardHeightChange);
7790
WX.OnKeyboardConfirm(_onKeyboardConfirm);
7891
WX.OnKeyboardComplete(_onKeyboardComplete);
79-
} else {
92+
}
93+
else
94+
{
8095
WX.OffKeyUp(_onKeyUp);
8196
WX.OffKeyDown(_onKeyDown);
8297
WX.OffKeyboardInput(_onKeyboardInput);
@@ -85,73 +100,110 @@ protected override void TestAPI(string[] args)
85100
WX.OffKeyboardComplete(_onKeyboardComplete);
86101
}
87102
_isListening = !_isListening;
88-
GameManager.Instance.detailsController.ChangeInitialButtonText(_isListening ? "取消监听" : "开始监听");
103+
GameManager.Instance.detailsController.ChangeExtraButtonText(3, _isListening ? "取消监听" : "开始监听");
89104
}
90105

91-
public void showKeyboard()
106+
public void showMultipleKeyboard()
92107
{
93-
WX.ShowKeyboard(new ShowKeyboardOption
108+
WX.ShowKeyboard(new ShowKeyboardOption
94109
{
95110
defaultValue = "test",
96111
maxLength = 20,
97112
multiple = true,
98113
confirmHold = false,
99114
confirmType = "done",
100-
success = (res) => {
115+
success = (res) =>
116+
{
101117
Debug.Log("success");
102118
},
103-
fail = (res) => {
119+
fail = (res) =>
120+
{
104121
Debug.Log("fail" + res.errMsg);
105122
},
106-
complete = (res) => {
123+
complete = (res) =>
124+
{
107125
Debug.Log("complete");
108126
}
109127
});
110128
}
111129

112-
public void updateKeyboard() {
130+
public void showKeyboard()
131+
{
132+
WX.ShowKeyboard(new ShowKeyboardOption
133+
{
134+
defaultValue = "test",
135+
maxLength = 20,
136+
multiple = false,
137+
confirmHold = false,
138+
confirmType = "done",
139+
success = (res) =>
140+
{
141+
Debug.Log("success");
142+
},
143+
fail = (res) =>
144+
{
145+
Debug.Log("fail" + res.errMsg);
146+
},
147+
complete = (res) =>
148+
{
149+
Debug.Log("complete");
150+
}
151+
});
152+
}
153+
154+
public void updateKeyboard()
155+
{
113156
WX.UpdateKeyboard(new UpdateKeyboardOption
114157
{
115158
value = "test" + random.Next(0, 100),
116-
success = (res) => {
159+
success = (res) =>
160+
{
117161
Debug.Log("success");
118162
WX.ShowToast(new ShowToastOption
119163
{
120164
title = "更改成功"
121165
});
122166
},
123-
fail = (res) => {
167+
fail = (res) =>
168+
{
124169
Debug.Log("fail" + res.errMsg);
125170
},
126-
complete = (res) => {
171+
complete = (res) =>
172+
{
127173
Debug.Log("complete");
128174
}
129175
});
130176
}
131177

132-
public void hideKeyboard() {
178+
public void hideKeyboard()
179+
{
133180
WX.HideKeyboard(new HideKeyboardOption
134181
{
135-
success = (res) => {
182+
success = (res) =>
183+
{
136184
Debug.Log("success");
137185
},
138-
fail = (res) => {
186+
fail = (res) =>
187+
{
139188
Debug.Log("fail" + res.errMsg);
140189
},
141-
complete = (res) => {
190+
complete = (res) =>
191+
{
142192
Debug.Log("complete");
143193
}
144194
});
145195
}
146196

147-
private void OnDestroy()
197+
public void Destroy()
148198
{
149199
WX.OffKeyUp(_onKeyUp);
150200
WX.OffKeyDown(_onKeyDown);
151201
WX.OffKeyboardInput(_onKeyboardInput);
152202
WX.OffKeyboardHeightChange(_onKeyboardHeightChange);
153203
WX.OffKeyboardConfirm(_onKeyboardConfirm);
154204
WX.OffKeyboardComplete(_onKeyboardComplete);
205+
206+
hideKeyboard();
155207
}
156208
}
157209

Demo/API_V2/Assets/API/Facility/Keyboard/KeyboardSO.asset

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ MonoBehaviour:
1717
entryAPI: "\u952E\u76D8\u76F8\u5173API"
1818
entryDescription:
1919
optionList: []
20-
initialButtonText: "\u5F00\u59CB\u76D1\u542C"
20+
initialButtonText: "\u663E\u793A\u591A\u884C\u952E\u76D8"
2121
extraButtonList:
22-
- buttonText: "\u663E\u793A\u952E\u76D8"
22+
- buttonText: "\u663E\u793A\u5355\u884C\u952E\u76D8"
2323
- buttonText: "\u66F4\u65B0\u952E\u76D8\u8F93\u5165\u6846\u5185\u5BB9"
2424
- buttonText: "\u9690\u85CF\u952E\u76D8"
25+
- buttonText: "\u5F00\u59CB\u76D1\u542C"
2526
initialResultList: []

Demo/API_V2/Assets/API/GUI/Menu/MenuSO.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ MonoBehaviour:
2121
setStatusBarStyle
2222
2323
'
24-
entryDescription: "\u4F7F\u7528setStatusBarStyle\uFF0C\u9700\u8981\u5728json\u91CC\u6DFB\u52A0showStatusBarStyle"
24+
entryDescription: "\u4F7F\u7528setStatusBarStyle\uFF0C\u9700\u8981\u5728json\u91CC\u6DFB\u52A0showStatusBar"
2525
optionList: []
2626
initialButtonText: "\u8BBE\u7F6E\u83DC\u5355\u6837\u5F0F"
2727
extraButtonList:

0 commit comments

Comments
 (0)