Skip to content

Commit b4615ae

Browse files
authored
Merge pull request #840 from wechat-miniprogram/fix/apiv2_0812
Fix/apiv2 0812
2 parents b72d1c1 + dd79e08 commit b4615ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+522
-446
lines changed

Demo/API_V2/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,7 @@ crashlytics-build.properties
8383

8484
# Idea
8585
.idea/
86+
87+
.vscode/
88+
wxbuild/
89+
wxbuild2/

Demo/API_V2/Assets/API/APISO.asset

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ MonoBehaviour:
1919
- {fileID: 11400000, guid: 9977a581037b84833a32b508e00eb1a2, type: 2}
2020
- {fileID: 11400000, guid: 56f316e0e10ba419bbf19bd7a68bfc4c, type: 2}
2121
- {fileID: 11400000, guid: 6f0972f5fdc56c543b23c9873d760bf5, type: 2}
22-
- {fileID: 11400000, guid: 7ef06699cee7846b7823e4cc421418eb, type: 2}
2322
- {fileID: 11400000, guid: a461b8cd70d9e4e23ad1cc953bec31e9, type: 2}
23+
- {fileID: 11400000, guid: 7ef06699cee7846b7823e4cc421418eb, type: 2}
2424
- {fileID: 11400000, guid: 55de20d536f8c4689bbd80553d87fe46, type: 2}
2525
- {fileID: 11400000, guid: f2c56d751bb7c4c398db7c1db352517d, type: 2}
2626
- {fileID: 11400000, guid: b4a6196f623dd4435a4f3bd70af92d06, type: 2}

Demo/API_V2/Assets/API/Ad/AdWithAudio/AdWithAudio.cs

-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
using System;
22
using System.Collections;
3-
using System.Collections.Generic;
43
using UnityEngine;
5-
using UnityEngine.Audio;
64
using UnityEngine.Networking;
7-
using UnityEngine.Networking;
8-
using UnityEngine.UI;
95
using WeChatWASM;
106

117
public class AdWithAudio : Details

Demo/API_V2/Assets/API/Base/Get/GetInfo.cs renamed to Demo/API_V2/Assets/API/Base/GetInfo/GetInfo.cs

+82-85
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,26 @@
1-
using System;
2-
using System.Collections.Generic;
31
using LitJson;
4-
using UnityEngine;
52
using WeChatWASM;
63

74
public class GetInfo : Details
85
{
96
private void Start()
107
{
118
// 绑定额外的按钮操作
12-
GameManager.Instance.detailsController.BindExtraButtonAction(0, getSystemSetting);
13-
GameManager.Instance.detailsController.BindExtraButtonAction(1, getSystemInfoSync);
14-
GameManager.Instance.detailsController.BindExtraButtonAction(2, getSystemInfoAsync);
15-
GameManager.Instance.detailsController.BindExtraButtonAction(3, getSystemInfo);
16-
GameManager.Instance.detailsController.BindExtraButtonAction(4, getDeviceInfo);
17-
GameManager.Instance.detailsController.BindExtraButtonAction(5, getAppBaseInfo);
18-
GameManager.Instance.detailsController.BindExtraButtonAction(6, getAppAuthorizeSetting);
19-
GameManager.Instance.detailsController.BindExtraButtonAction(7, getLaunchOptionsSync);
20-
GameManager.Instance.detailsController.BindExtraButtonAction(8, getEnterOptionsSync);
9+
GameManager.Instance.detailsController.BindExtraButtonAction(0, getAppAuthorizeSetting);
10+
GameManager.Instance.detailsController.BindExtraButtonAction(1, getDeviceInfo);
11+
GameManager.Instance.detailsController.BindExtraButtonAction(2, getWindowInfo);
12+
GameManager.Instance.detailsController.BindExtraButtonAction(3, getAppBaseInfo);
13+
// GameManager.Instance.detailsController.BindExtraButtonAction(1, getSystemInfoSync);
14+
// GameManager.Instance.detailsController.BindExtraButtonAction(2, getSystemInfoAsync);
15+
// GameManager.Instance.detailsController.BindExtraButtonAction(3, getSystemInfo);
16+
GameManager.Instance.detailsController.BindExtraButtonAction(4, getLaunchOptionsSync);
17+
GameManager.Instance.detailsController.BindExtraButtonAction(5, getEnterOptionsSync);
2118
}
2219

2320
// 测试 API
2421
protected override void TestAPI(string[] args)
2522
{
26-
getWindowInfo();
27-
}
28-
29-
public void getWindowInfo()
30-
{
31-
var res = WX.GetWindowInfo();
32-
33-
// 访问成功,显示结果
34-
WX.ShowModal(
35-
new ShowModalOption() { content = "Access Success, Result: " + JsonMapper.ToJson(res) }
36-
);
23+
getSystemSetting();
3724
}
3825

3926
public void getSystemSetting()
@@ -46,68 +33,16 @@ public void getSystemSetting()
4633
);
4734
}
4835

49-
public void getSystemInfoSync()
36+
public void getAppAuthorizeSetting()
5037
{
51-
var res = WX.GetSystemInfoSync();
38+
var res = WX.GetAppAuthorizeSetting();
5239

5340
// 访问成功,显示结果
5441
WX.ShowModal(
5542
new ShowModalOption() { content = "Access Success, Result: " + JsonMapper.ToJson(res) }
5643
);
5744
}
5845

59-
public void getSystemInfoAsync()
60-
{
61-
WX.GetSystemInfoAsync(
62-
new GetSystemInfoAsyncOption
63-
{
64-
success = (res) =>
65-
{
66-
WX.ShowModal(
67-
new ShowModalOption()
68-
{
69-
content = "Access Success, Result: " + JsonMapper.ToJson(res)
70-
}
71-
);
72-
},
73-
fail = (res) =>
74-
{
75-
Debug.Log("fail:" + res.errMsg);
76-
},
77-
complete = (res) =>
78-
{
79-
Debug.Log("complete!");
80-
}
81-
}
82-
);
83-
}
84-
85-
public void getSystemInfo()
86-
{
87-
WX.GetSystemInfo(
88-
new GetSystemInfoOption
89-
{
90-
success = (res) =>
91-
{
92-
WX.ShowModal(
93-
new ShowModalOption()
94-
{
95-
content = "Access Success, Result: " + JsonMapper.ToJson(res)
96-
}
97-
);
98-
},
99-
fail = (res) =>
100-
{
101-
Debug.Log("fail:" + res.errMsg);
102-
},
103-
complete = (res) =>
104-
{
105-
Debug.Log("complete!");
106-
}
107-
}
108-
);
109-
}
110-
11146
public void getDeviceInfo()
11247
{
11348
var res = WX.GetDeviceInfo();
@@ -118,39 +53,101 @@ public void getDeviceInfo()
11853
);
11954
}
12055

121-
public void getAppBaseInfo()
56+
public void getWindowInfo()
12257
{
123-
var res = WX.GetAppBaseInfo();
58+
var res = WX.GetWindowInfo();
12459

12560
// 访问成功,显示结果
12661
WX.ShowModal(
12762
new ShowModalOption() { content = "Access Success, Result: " + JsonMapper.ToJson(res) }
12863
);
12964
}
13065

131-
public void getAppAuthorizeSetting()
66+
public void getAppBaseInfo()
13267
{
133-
var res = WX.GetAppAuthorizeSetting();
68+
var res = WX.GetAppBaseInfo();
13469

13570
// 访问成功,显示结果
13671
WX.ShowModal(
13772
new ShowModalOption() { content = "Access Success, Result: " + JsonMapper.ToJson(res) }
13873
);
13974
}
14075

141-
public void getEnterOptionsSync()
76+
// public void getSystemInfoSync()
77+
// {
78+
// var res = WX.GetSystemInfoSync();
79+
//
80+
// // 访问成功,显示结果
81+
// WX.ShowModal(
82+
// new ShowModalOption() { content = "Access Success, Result: " + JsonMapper.ToJson(res) }
83+
// );
84+
// }
85+
//
86+
// public void getSystemInfoAsync()
87+
// {
88+
// WX.GetSystemInfoAsync(
89+
// new GetSystemInfoAsyncOption
90+
// {
91+
// success = (res) =>
92+
// {
93+
// WX.ShowModal(
94+
// new ShowModalOption()
95+
// {
96+
// content = "Access Success, Result: " + JsonMapper.ToJson(res)
97+
// }
98+
// );
99+
// },
100+
// fail = (res) =>
101+
// {
102+
// Debug.Log("fail:" + res.errMsg);
103+
// },
104+
// complete = (res) =>
105+
// {
106+
// Debug.Log("complete!");
107+
// }
108+
// }
109+
// );
110+
// }
111+
//
112+
// public void getSystemInfo()
113+
// {
114+
// WX.GetSystemInfo(
115+
// new GetSystemInfoOption
116+
// {
117+
// success = (res) =>
118+
// {
119+
// WX.ShowModal(
120+
// new ShowModalOption()
121+
// {
122+
// content = "Access Success, Result: " + JsonMapper.ToJson(res)
123+
// }
124+
// );
125+
// },
126+
// fail = (res) =>
127+
// {
128+
// Debug.Log("fail:" + res.errMsg);
129+
// },
130+
// complete = (res) =>
131+
// {
132+
// Debug.Log("complete!");
133+
// }
134+
// }
135+
// );
136+
// }
137+
138+
public void getLaunchOptionsSync()
142139
{
143-
var res = WX.GetEnterOptionsSync();
140+
var res = WX.GetLaunchOptionsSync();
144141

145142
// 访问成功,显示结果
146143
WX.ShowModal(
147144
new ShowModalOption() { content = "Access Success, Result: " + JsonMapper.ToJson(res) }
148145
);
149146
}
150147

151-
public void getLaunchOptionsSync()
148+
public void getEnterOptionsSync()
152149
{
153-
var res = WX.GetLaunchOptionsSync();
150+
var res = WX.GetEnterOptionsSync();
154151

155152
// 访问成功,显示结果
156153
WX.ShowModal(

Demo/API_V2/Assets/API/Base/Get/GetInfoSO.asset renamed to Demo/API_V2/Assets/API/Base/GetInfo/GetInfoSO.asset

+6-10
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,16 @@ MonoBehaviour:
1414
m_EditorClassIdentifier:
1515
entryScriptTypeName: GetInfo
1616
entryName: "\u83B7\u53D6\u7CFB\u7EDF\u548C\u8BBE\u5907\u4FE1\u606F"
17-
entryAPI: "getWindowInfo\uFF5CgetSystemSetting\ngetSystemInfoSync \uFF5CgetSystemInfoAsync\ngetSystemInfo
18-
\uFF5CgetDeviceInfo\ngetAppBaseInfo \uFF5CgetAppAuthorizeSetting\ngetEnterOptionsSync
19-
\uFF5C getLaunchOptionsSync"
20-
entryDescription:
17+
entryAPI: "getSystemSetting\uFF5CgetAppAuthorizeSetting\ngetDeviceInfo\uFF5CgetWindowInfo\ngetAppBaseInfo\ngetEnterOptionsSync\uFF5CgetLaunchOptionsSync"
18+
entryDescription: "<color=red>\u4ECE\u57FA\u7840\u5E93 2.20.1 \u5F00\u59CB\uFF0Cwx.getSystemInfo(Sync/Async)\u505C\u6B62\u7EF4\u62A4
19+
</color>"
2120
optionList: []
22-
initialButtonText: "\u83B7\u53D6\u7A97\u53E3\u4FE1\u606F"
21+
initialButtonText: "\u83B7\u53D6\u8BBE\u5907\u8BBE\u7F6E"
2322
extraButtonList:
24-
- buttonText: "\u83B7\u53D6\u8BBE\u5907\u8BBE\u7F6E "
25-
- buttonText: "\u83B7\u53D6\u7CFB\u7EDF\u4FE1\u606F-\u540C\u6B65"
26-
- buttonText: "\u83B7\u53D6\u7CFB\u7EDF\u4FE1\u606F-\u5F02\u6B65"
27-
- buttonText: "\u83B7\u53D6\u7CFB\u7EDF\u4FE1\u606F"
23+
- buttonText: "\u83B7\u53D6\u5FAE\u4FE1APP\u6388\u6743\u8BBE\u7F6E"
2824
- buttonText: "\u83B7\u53D6\u8BBE\u5907\u57FA\u7840\u4FE1\u606F"
25+
- buttonText: "\u83B7\u53D6\u7A97\u53E3\u4FE1\u606F"
2926
- buttonText: "\u83B7\u53D6\u5FAE\u4FE1APP\u57FA\u7840\u4FE1\u606F"
30-
- buttonText: "\u83B7\u53D6\u5FAE\u4FE1APP\u6388\u6743\u8BBE\u7F6E"
3127
- buttonText: "\u83B7\u53D6\u5C0F\u6E38\u620F\u51B7\u542F\u52A8\u65F6\u7684\u53C2\u6570"
3228
- buttonText: "\u83B7\u53D6\u5C0F\u6E38\u620F\u6253\u5F00\u7684\u53C2\u6570"
3329
initialResultList: []

Demo/API_V2/Assets/API/Facility/FacilitySO.asset

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ MonoBehaviour:
1515
categoryName: "\u8BBE\u5907"
1616
categorySprite: {fileID: 21300000, guid: fcbb6947b033746dabecaec0f84b0434, type: 3}
1717
entryList:
18-
- {fileID: 11400000, guid: a24af43ae51914d26b0bf637c283dab2, type: 2}
19-
- {fileID: 11400000, guid: 4eba2c9f2f2064e4081be74302ca4c33, type: 2}
2018
- {fileID: 11400000, guid: bbbc9b983d6d34ad3bac2921509f612f, type: 2}
2119
- {fileID: 11400000, guid: c17ae0ce755f04419b700825b20fd386, type: 2}
20+
- {fileID: 11400000, guid: a24af43ae51914d26b0bf637c283dab2, type: 2}
21+
- {fileID: 11400000, guid: 4eba2c9f2f2064e4081be74302ca4c33, type: 2}
2222
- {fileID: 11400000, guid: ac09abff5d8bc48bbabd08bde820b58b, type: 2}
2323
- {fileID: 11400000, guid: 3bf339b994c544db3860ddf0a0dc8e20, type: 2}
2424
- {fileID: 11400000, guid: e92d94924be504167a342e42e1162f21, type: 2}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class Screen : Details
1010
private bool _isListening1 = false;
1111
private System.Random random = new System.Random();
1212

13-
private readonly Action<GeneralCallbackResult> _onUserCaptureScreen = (res) =>
13+
private readonly Action<OnUserCaptureScreenListenerResult> _onUserCaptureScreen = (res) =>
1414
{
1515
WX.ShowToast(new ShowToastOption { title = "截屏触发" });
1616
var result = "_onUserCaptureScreen\n" + JsonMapper.ToJson(res);

Demo/API_V2/Assets/API/FileSystem/FileSystemSO.asset

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ MonoBehaviour:
2424
- {fileID: 11400000, guid: 65ab1b01a722b4542a14fcf9decca3de, type: 2}
2525
- {fileID: 11400000, guid: 19b80cb144f0c4ea28a4ddca7a2c2f09, type: 2}
2626
- {fileID: 11400000, guid: 0aa5d76237c844275add1612c47bddaa, type: 2}
27-
- {fileID: 11400000, guid: 65a826f5f949544d8990e673231bb80f, type: 2}
2827
- {fileID: 11400000, guid: 73c05fc1ffae94ec1b69a00ee261d529, type: 2}
28+
- {fileID: 11400000, guid: 65a826f5f949544d8990e673231bb80f, type: 2}
2929
- {fileID: 11400000, guid: 3a901e80b59ad4aafbe373ee6a8df2d8, type: 2}
3030
- {fileID: 11400000, guid: e7ea0be62dc6543b0a8dc629489c5e7e, type: 2}

Demo/API_V2/Assets/API/Media/WXVideo/WXvideo.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void Start()
1919

2020
private void AutoPlayVideo()
2121
{
22-
var systemInfo = WX.GetSystemInfoSync();
22+
var windowInfo = GameManager.Instance.WindowInfo;
2323
_video = WX.CreateVideo(
2424
new WXCreateVideoParam()
2525
{
@@ -31,8 +31,8 @@ private void AutoPlayVideo()
3131
autoplay = true,
3232
showCenterPlayBtn = false,
3333
underGameView = true,
34-
width = ((int)systemInfo.screenWidth),
35-
height = ((int)systemInfo.screenHeight),
34+
width = ((int)windowInfo.screenWidth),
35+
height = ((int)windowInfo.screenHeight),
3636
}
3737
);
3838
_video.OnPlay(() =>

Demo/API_V2/Assets/API/Network/UDPSocket/UDPSocket.cs

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using LitJson;
41
using UnityEngine;
52
using WeChatWASM;
63

@@ -84,9 +81,7 @@ private void write()
8481
{
8582
if (_udpSocket != null && _connected)
8683
{
87-
Debug.LogError("接口有bug暂未修复 当前为placeholder");
88-
/*
89-
UDPSocketWriteOption option = new UDPSocketWriteOption()
84+
UDPSocketSendOption option = new UDPSocketSendOption()
9085
{
9186
address = "www.oooceanworld.com",
9287
port = 8101
@@ -100,7 +95,7 @@ private void write()
10095
option.message = _bufferData;
10196
}
10297
_udpSocket.Write(option);
103-
*/
98+
Debug.Log("Message: " + option.message);
10499
}
105100
else
106101
{

Demo/API_V2/Assets/API/Network/UnityWebRequest/WebRequest.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ IEnumerator Get()
4242

4343
yield return webRequest.SendWebRequest();
4444

45-
if (webRequest.isHttpError || webRequest.isNetworkError)
45+
if (webRequest.result is UnityWebRequest.Result.ProtocolError or UnityWebRequest.Result.ConnectionError)
4646
Debug.Log(webRequest.error);
4747
else
4848
{
@@ -62,7 +62,7 @@ IEnumerator Post()
6262

6363
yield return webRequest.SendWebRequest();
6464

65-
if (webRequest.isHttpError || webRequest.isNetworkError)
65+
if (webRequest.result is UnityWebRequest.Result.ProtocolError or UnityWebRequest.Result.ConnectionError)
6666
Debug.Log(webRequest.error);
6767
else
6868
{

0 commit comments

Comments
 (0)