Skip to content

Fix/apiv2 0812 #840

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

Merged
merged 5 commits into from
Aug 19, 2024
Merged
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
4 changes: 4 additions & 0 deletions Demo/API_V2/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,7 @@ crashlytics-build.properties

# Idea
.idea/

.vscode/
wxbuild/
wxbuild2/
2 changes: 1 addition & 1 deletion Demo/API_V2/Assets/API/APISO.asset
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ MonoBehaviour:
- {fileID: 11400000, guid: 9977a581037b84833a32b508e00eb1a2, type: 2}
- {fileID: 11400000, guid: 56f316e0e10ba419bbf19bd7a68bfc4c, type: 2}
- {fileID: 11400000, guid: 6f0972f5fdc56c543b23c9873d760bf5, type: 2}
- {fileID: 11400000, guid: 7ef06699cee7846b7823e4cc421418eb, type: 2}
- {fileID: 11400000, guid: a461b8cd70d9e4e23ad1cc953bec31e9, type: 2}
- {fileID: 11400000, guid: 7ef06699cee7846b7823e4cc421418eb, type: 2}
- {fileID: 11400000, guid: 55de20d536f8c4689bbd80553d87fe46, type: 2}
- {fileID: 11400000, guid: f2c56d751bb7c4c398db7c1db352517d, type: 2}
- {fileID: 11400000, guid: b4a6196f623dd4435a4f3bd70af92d06, type: 2}
Expand Down
4 changes: 0 additions & 4 deletions Demo/API_V2/Assets/API/Ad/AdWithAudio/AdWithAudio.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Networking;
using UnityEngine.Networking;
using UnityEngine.UI;
using WeChatWASM;

public class AdWithAudio : Details
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,26 @@
using System;
using System.Collections.Generic;
using LitJson;
using UnityEngine;
using WeChatWASM;

public class GetInfo : Details
{
private void Start()
{
// 绑定额外的按钮操作
GameManager.Instance.detailsController.BindExtraButtonAction(0, getSystemSetting);
GameManager.Instance.detailsController.BindExtraButtonAction(1, getSystemInfoSync);
GameManager.Instance.detailsController.BindExtraButtonAction(2, getSystemInfoAsync);
GameManager.Instance.detailsController.BindExtraButtonAction(3, getSystemInfo);
GameManager.Instance.detailsController.BindExtraButtonAction(4, getDeviceInfo);
GameManager.Instance.detailsController.BindExtraButtonAction(5, getAppBaseInfo);
GameManager.Instance.detailsController.BindExtraButtonAction(6, getAppAuthorizeSetting);
GameManager.Instance.detailsController.BindExtraButtonAction(7, getLaunchOptionsSync);
GameManager.Instance.detailsController.BindExtraButtonAction(8, getEnterOptionsSync);
GameManager.Instance.detailsController.BindExtraButtonAction(0, getAppAuthorizeSetting);
GameManager.Instance.detailsController.BindExtraButtonAction(1, getDeviceInfo);
GameManager.Instance.detailsController.BindExtraButtonAction(2, getWindowInfo);
GameManager.Instance.detailsController.BindExtraButtonAction(3, getAppBaseInfo);
// GameManager.Instance.detailsController.BindExtraButtonAction(1, getSystemInfoSync);
// GameManager.Instance.detailsController.BindExtraButtonAction(2, getSystemInfoAsync);
// GameManager.Instance.detailsController.BindExtraButtonAction(3, getSystemInfo);
GameManager.Instance.detailsController.BindExtraButtonAction(4, getLaunchOptionsSync);
GameManager.Instance.detailsController.BindExtraButtonAction(5, getEnterOptionsSync);
}

// 测试 API
protected override void TestAPI(string[] args)
{
getWindowInfo();
}

public void getWindowInfo()
{
var res = WX.GetWindowInfo();

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

public void getSystemSetting()
Expand All @@ -46,68 +33,16 @@ public void getSystemSetting()
);
}

public void getSystemInfoSync()
public void getAppAuthorizeSetting()
{
var res = WX.GetSystemInfoSync();
var res = WX.GetAppAuthorizeSetting();

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

public void getSystemInfoAsync()
{
WX.GetSystemInfoAsync(
new GetSystemInfoAsyncOption
{
success = (res) =>
{
WX.ShowModal(
new ShowModalOption()
{
content = "Access Success, Result: " + JsonMapper.ToJson(res)
}
);
},
fail = (res) =>
{
Debug.Log("fail:" + res.errMsg);
},
complete = (res) =>
{
Debug.Log("complete!");
}
}
);
}

public void getSystemInfo()
{
WX.GetSystemInfo(
new GetSystemInfoOption
{
success = (res) =>
{
WX.ShowModal(
new ShowModalOption()
{
content = "Access Success, Result: " + JsonMapper.ToJson(res)
}
);
},
fail = (res) =>
{
Debug.Log("fail:" + res.errMsg);
},
complete = (res) =>
{
Debug.Log("complete!");
}
}
);
}

public void getDeviceInfo()
{
var res = WX.GetDeviceInfo();
Expand All @@ -118,39 +53,101 @@ public void getDeviceInfo()
);
}

public void getAppBaseInfo()
public void getWindowInfo()
{
var res = WX.GetAppBaseInfo();
var res = WX.GetWindowInfo();

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

public void getAppAuthorizeSetting()
public void getAppBaseInfo()
{
var res = WX.GetAppAuthorizeSetting();
var res = WX.GetAppBaseInfo();

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

public void getEnterOptionsSync()
// public void getSystemInfoSync()
// {
// var res = WX.GetSystemInfoSync();
//
// // 访问成功,显示结果
// WX.ShowModal(
// new ShowModalOption() { content = "Access Success, Result: " + JsonMapper.ToJson(res) }
// );
// }
//
// public void getSystemInfoAsync()
// {
// WX.GetSystemInfoAsync(
// new GetSystemInfoAsyncOption
// {
// success = (res) =>
// {
// WX.ShowModal(
// new ShowModalOption()
// {
// content = "Access Success, Result: " + JsonMapper.ToJson(res)
// }
// );
// },
// fail = (res) =>
// {
// Debug.Log("fail:" + res.errMsg);
// },
// complete = (res) =>
// {
// Debug.Log("complete!");
// }
// }
// );
// }
//
// public void getSystemInfo()
// {
// WX.GetSystemInfo(
// new GetSystemInfoOption
// {
// success = (res) =>
// {
// WX.ShowModal(
// new ShowModalOption()
// {
// content = "Access Success, Result: " + JsonMapper.ToJson(res)
// }
// );
// },
// fail = (res) =>
// {
// Debug.Log("fail:" + res.errMsg);
// },
// complete = (res) =>
// {
// Debug.Log("complete!");
// }
// }
// );
// }

public void getLaunchOptionsSync()
{
var res = WX.GetEnterOptionsSync();
var res = WX.GetLaunchOptionsSync();

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

public void getLaunchOptionsSync()
public void getEnterOptionsSync()
{
var res = WX.GetLaunchOptionsSync();
var res = WX.GetEnterOptionsSync();

// 访问成功,显示结果
WX.ShowModal(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,16 @@ MonoBehaviour:
m_EditorClassIdentifier:
entryScriptTypeName: GetInfo
entryName: "\u83B7\u53D6\u7CFB\u7EDF\u548C\u8BBE\u5907\u4FE1\u606F"
entryAPI: "getWindowInfo\uFF5CgetSystemSetting\ngetSystemInfoSync \uFF5CgetSystemInfoAsync\ngetSystemInfo
\uFF5CgetDeviceInfo\ngetAppBaseInfo \uFF5CgetAppAuthorizeSetting\ngetEnterOptionsSync
\uFF5C getLaunchOptionsSync"
entryDescription:
entryAPI: "getSystemSetting\uFF5CgetAppAuthorizeSetting\ngetDeviceInfo\uFF5CgetWindowInfo\ngetAppBaseInfo\ngetEnterOptionsSync\uFF5CgetLaunchOptionsSync"
entryDescription: "<color=red>\u4ECE\u57FA\u7840\u5E93 2.20.1 \u5F00\u59CB\uFF0Cwx.getSystemInfo(Sync/Async)\u505C\u6B62\u7EF4\u62A4
</color>"
optionList: []
initialButtonText: "\u83B7\u53D6\u7A97\u53E3\u4FE1\u606F"
initialButtonText: "\u83B7\u53D6\u8BBE\u5907\u8BBE\u7F6E"
extraButtonList:
- buttonText: "\u83B7\u53D6\u8BBE\u5907\u8BBE\u7F6E "
- buttonText: "\u83B7\u53D6\u7CFB\u7EDF\u4FE1\u606F-\u540C\u6B65"
- buttonText: "\u83B7\u53D6\u7CFB\u7EDF\u4FE1\u606F-\u5F02\u6B65"
- buttonText: "\u83B7\u53D6\u7CFB\u7EDF\u4FE1\u606F"
- buttonText: "\u83B7\u53D6\u5FAE\u4FE1APP\u6388\u6743\u8BBE\u7F6E"
- buttonText: "\u83B7\u53D6\u8BBE\u5907\u57FA\u7840\u4FE1\u606F"
- buttonText: "\u83B7\u53D6\u7A97\u53E3\u4FE1\u606F"
- buttonText: "\u83B7\u53D6\u5FAE\u4FE1APP\u57FA\u7840\u4FE1\u606F"
- buttonText: "\u83B7\u53D6\u5FAE\u4FE1APP\u6388\u6743\u8BBE\u7F6E"
- buttonText: "\u83B7\u53D6\u5C0F\u6E38\u620F\u51B7\u542F\u52A8\u65F6\u7684\u53C2\u6570"
- buttonText: "\u83B7\u53D6\u5C0F\u6E38\u620F\u6253\u5F00\u7684\u53C2\u6570"
initialResultList: []
4 changes: 2 additions & 2 deletions Demo/API_V2/Assets/API/Facility/FacilitySO.asset
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ MonoBehaviour:
categoryName: "\u8BBE\u5907"
categorySprite: {fileID: 21300000, guid: fcbb6947b033746dabecaec0f84b0434, type: 3}
entryList:
- {fileID: 11400000, guid: a24af43ae51914d26b0bf637c283dab2, type: 2}
- {fileID: 11400000, guid: 4eba2c9f2f2064e4081be74302ca4c33, type: 2}
- {fileID: 11400000, guid: bbbc9b983d6d34ad3bac2921509f612f, type: 2}
- {fileID: 11400000, guid: c17ae0ce755f04419b700825b20fd386, type: 2}
- {fileID: 11400000, guid: a24af43ae51914d26b0bf637c283dab2, type: 2}
- {fileID: 11400000, guid: 4eba2c9f2f2064e4081be74302ca4c33, type: 2}
- {fileID: 11400000, guid: ac09abff5d8bc48bbabd08bde820b58b, type: 2}
- {fileID: 11400000, guid: 3bf339b994c544db3860ddf0a0dc8e20, type: 2}
- {fileID: 11400000, guid: e92d94924be504167a342e42e1162f21, type: 2}
Expand Down
2 changes: 1 addition & 1 deletion Demo/API_V2/Assets/API/Facility/Screen/Screen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Screen : Details
private bool _isListening1 = false;
private System.Random random = new System.Random();

private readonly Action<GeneralCallbackResult> _onUserCaptureScreen = (res) =>
private readonly Action<OnUserCaptureScreenListenerResult> _onUserCaptureScreen = (res) =>
{
WX.ShowToast(new ShowToastOption { title = "截屏触发" });
var result = "_onUserCaptureScreen\n" + JsonMapper.ToJson(res);
Expand Down
2 changes: 1 addition & 1 deletion Demo/API_V2/Assets/API/FileSystem/FileSystemSO.asset
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ MonoBehaviour:
- {fileID: 11400000, guid: 65ab1b01a722b4542a14fcf9decca3de, type: 2}
- {fileID: 11400000, guid: 19b80cb144f0c4ea28a4ddca7a2c2f09, type: 2}
- {fileID: 11400000, guid: 0aa5d76237c844275add1612c47bddaa, type: 2}
- {fileID: 11400000, guid: 65a826f5f949544d8990e673231bb80f, type: 2}
- {fileID: 11400000, guid: 73c05fc1ffae94ec1b69a00ee261d529, type: 2}
- {fileID: 11400000, guid: 65a826f5f949544d8990e673231bb80f, type: 2}
- {fileID: 11400000, guid: 3a901e80b59ad4aafbe373ee6a8df2d8, type: 2}
- {fileID: 11400000, guid: e7ea0be62dc6543b0a8dc629489c5e7e, type: 2}
6 changes: 3 additions & 3 deletions Demo/API_V2/Assets/API/Media/WXVideo/WXvideo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void Start()

private void AutoPlayVideo()
{
var systemInfo = WX.GetSystemInfoSync();
var windowInfo = GameManager.Instance.WindowInfo;
_video = WX.CreateVideo(
new WXCreateVideoParam()
{
Expand All @@ -31,8 +31,8 @@ private void AutoPlayVideo()
autoplay = true,
showCenterPlayBtn = false,
underGameView = true,
width = ((int)systemInfo.screenWidth),
height = ((int)systemInfo.screenHeight),
width = ((int)windowInfo.screenWidth),
height = ((int)windowInfo.screenHeight),
}
);
_video.OnPlay(() =>
Expand Down
9 changes: 2 additions & 7 deletions Demo/API_V2/Assets/API/Network/UDPSocket/UDPSocket.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using LitJson;
using UnityEngine;
using WeChatWASM;

Expand Down Expand Up @@ -84,9 +81,7 @@ private void write()
{
if (_udpSocket != null && _connected)
{
Debug.LogError("接口有bug暂未修复 当前为placeholder");
/*
UDPSocketWriteOption option = new UDPSocketWriteOption()
UDPSocketSendOption option = new UDPSocketSendOption()
{
address = "www.oooceanworld.com",
port = 8101
Expand All @@ -100,7 +95,7 @@ private void write()
option.message = _bufferData;
}
_udpSocket.Write(option);
*/
Debug.Log("Message: " + option.message);
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions Demo/API_V2/Assets/API/Network/UnityWebRequest/WebRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ IEnumerator Get()

yield return webRequest.SendWebRequest();

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

yield return webRequest.SendWebRequest();

if (webRequest.isHttpError || webRequest.isNetworkError)
if (webRequest.result is UnityWebRequest.Result.ProtocolError or UnityWebRequest.Result.ConnectionError)
Debug.Log(webRequest.error);
else
{
Expand Down
Loading
Loading