Skip to content

Commit 848c743

Browse files
authored
Merge pull request #812 from kstjxy/main
统一全部Demo引擎与插件版本, 更新api_v2 中的tcp和游戏圈demo展示
2 parents 62eee4f + 9a4ff0e commit 848c743

File tree

3,972 files changed

+1948
-779487
lines changed

Some content is hidden

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

3,972 files changed

+1948
-779487
lines changed

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: a461b8cd70d9e4e23ad1cc953bec31e9, type: 2}
2322
- {fileID: 11400000, guid: 7ef06699cee7846b7823e4cc421418eb, type: 2}
23+
- {fileID: 11400000, guid: a461b8cd70d9e4e23ad1cc953bec31e9, 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/DataStorage/DataStorageSO.asset

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ MonoBehaviour:
1313
m_Name: DataStorageSO
1414
m_EditorClassIdentifier:
1515
categoryName: "\u6570\u636E\u7F13\u5B58"
16-
categorySprite: {fileID: 0}
16+
categorySprite: {fileID: 21300000, guid: aedb8ebe6c4a14a13b23dc2e9ab42dcf, type: 3}
1717
entryList:
1818
- {fileID: 11400000, guid: a587889226c1f491fa6c783db1e12837, type: 2}

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: bbbc9b983d6d34ad3bac2921509f612f, type: 2}
19-
- {fileID: 11400000, guid: c17ae0ce755f04419b700825b20fd386, type: 2}
2018
- {fileID: 11400000, guid: a24af43ae51914d26b0bf637c283dab2, type: 2}
2119
- {fileID: 11400000, guid: 4eba2c9f2f2064e4081be74302ca4c33, type: 2}
20+
- {fileID: 11400000, guid: bbbc9b983d6d34ad3bac2921509f612f, type: 2}
21+
- {fileID: 11400000, guid: c17ae0ce755f04419b700825b20fd386, 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/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: 73c05fc1ffae94ec1b69a00ee261d529, type: 2}
2827
- {fileID: 11400000, guid: 65a826f5f949544d8990e673231bb80f, type: 2}
28+
- {fileID: 11400000, guid: 73c05fc1ffae94ec1b69a00ee261d529, type: 2}
2929
- {fileID: 11400000, guid: 3a901e80b59ad4aafbe373ee6a8df2d8, type: 2}
3030
- {fileID: 11400000, guid: e7ea0be62dc6543b0a8dc629489c5e7e, type: 2}

Demo/API_V2/Assets/API/GUI/GUISO.asset

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ MonoBehaviour:
1313
m_Name: GUISO
1414
m_EditorClassIdentifier:
1515
categoryName: "\u754C\u9762"
16-
categorySprite: {fileID: 0}
16+
categorySprite: {fileID: 21300000, guid: bd5165d5d0b9b4f55b39dce7f4638c81, type: 3}
1717
entryList:
1818
- {fileID: 11400000, guid: 546628e39e8c246c38eebcdfbfd35b47, type: 2}
1919
- {fileID: 11400000, guid: 6902bd974e09745c4a185485a99c165d, type: 2}

Demo/API_V2/Assets/API/Network/NetworkSO.asset

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ MonoBehaviour:
1212
m_Script: {fileID: 11500000, guid: 4a9e19ed69c041c408533b50f5572d0f, type: 3}
1313
m_Name: NetworkSO
1414
m_EditorClassIdentifier:
15-
categoryName: "\u4E0B\u8F7D"
16-
categorySprite: {fileID: 0}
15+
categoryName: "\u7F51\u7EDC"
16+
categorySprite: {fileID: 21300000, guid: bb0b97758d57042a296e1ecd925f8088, type: 3}
1717
entryList:
1818
- {fileID: 11400000, guid: 8fb54c5918d454eea90d5147f2c316ea, type: 2}
1919
- {fileID: 11400000, guid: 1e0539509d074443f92d17035efbe40f, type: 2}

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

+92-22
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,114 @@
66
public class TCPSocket : Details
77
{
88
private WXTCPSocket _tcpSocket;
9+
private bool _connected = false;
10+
11+
// 数据
12+
private string _stringData1 = "String Data";
13+
private string _stringData2 = "123\n";
14+
15+
16+
private byte[] _bufferData1 = { 66, 117, 102, 102, 101, 114, 32, 68, 97, 116, 97, 32 };
17+
private byte[] _bufferData2 = { 0xab, 0x05, 0xd7, 0x05 };
18+
private byte[] _bufferData3 = new byte[8];
919

1020
private void Start() {
11-
GameManager.Instance.detailsController.BindExtraButtonAction(0, connect);
12-
GameManager.Instance.detailsController.BindExtraButtonAction(1, close);
21+
GameManager.Instance.detailsController.BindExtraButtonAction(0, connect);
22+
GameManager.Instance.detailsController.BindExtraButtonAction(1, write);
23+
GameManager.Instance.detailsController.BindExtraButtonAction(2, writeBuffer);
24+
GameManager.Instance.detailsController.BindExtraButtonAction(3, close);
1325
}
1426

1527
// 测试 API
1628
protected override void TestAPI(string[] args)
1729
{
18-
_tcpSocket = WX.CreateTCPSocket();
19-
Debug.Log("tcpSocket: " + JsonUtility.ToJson(_tcpSocket));
30+
if(_tcpSocket == null)
31+
{
32+
_tcpSocket = WX.CreateTCPSocket();
33+
Debug.Log("tcpSocket: " + JsonUtility.ToJson(_tcpSocket));
2034

21-
_tcpSocket.OnConnect((res) => {
22-
Debug.Log("onConnect: " + JsonUtility.ToJson(res));
23-
});
35+
_tcpSocket.OnMessage((res) => {
36+
Debug.Log("onMessage: " + JsonUtility.ToJson(res));
37+
});
2438

25-
_tcpSocket.OnError((res) => {
26-
Debug.Log("onError: " + JsonUtility.ToJson(res));
27-
});
39+
_tcpSocket.OnConnect((res) => {
40+
Debug.Log("onConnect: " + JsonUtility.ToJson(res));
41+
});
2842

29-
_tcpSocket.OnClose((res) => {
30-
Debug.Log("onClose: " + JsonUtility.ToJson(res));
31-
});
43+
_tcpSocket.OnError((res) => {
44+
Debug.Log("onError: " + JsonUtility.ToJson(res));
45+
});
3246

33-
_tcpSocket.OnMessage((res) => {
34-
Debug.Log("onMessage: " + JsonUtility.ToJson(res));
35-
});
47+
_tcpSocket.OnClose((res) => {
48+
Debug.Log("onClose: " + JsonUtility.ToJson(res));
49+
});
50+
} else
51+
{
52+
Debug.Log("tcp实例已初始化");
53+
}
54+
3655
}
3756

57+
private void close()
58+
{
59+
if(_tcpSocket != null && _connected)
60+
{
61+
Debug.Log("close test start");
62+
_tcpSocket.Close();
63+
_connected = false;
64+
} else
65+
{
66+
Debug.Log("关闭失败:tcp实例未初始化或未连接");
67+
}
68+
69+
}
70+
71+
3872
private void connect() {
39-
_tcpSocket.Connect(new TCPSocketConnectOption() {
40-
address = "192.168.193.2",
41-
port = 8848
42-
});
73+
if (_tcpSocket != null && !_connected) {
74+
Debug.Log("connect test start");
75+
_tcpSocket.Connect(new TCPSocketConnectOption()
76+
{
77+
address = "www.oooceanworld.com",
78+
port = 8101
79+
});
80+
_connected = true;
81+
} else
82+
{
83+
Debug.Log("连接失败:tcp实例未初始化或已连接");
84+
}
85+
}
86+
87+
private void write() {
88+
if (_tcpSocket != null && _connected)
89+
{
90+
Debug.Log("write string test start:");
91+
Debug.Log("test 1: " + _stringData1);
92+
_tcpSocket.Write(_stringData1);
93+
Debug.Log("test 2: " + _stringData2);
94+
_tcpSocket.Write(_stringData2);
95+
} else
96+
{
97+
Debug.Log("发送失败:tcp实例未初始化或未连接");
98+
}
99+
43100
}
44101

45-
private void close() {
46-
_tcpSocket.Close();
102+
private void writeBuffer() {
103+
if (_tcpSocket != null && _connected)
104+
{
105+
Debug.Log("write buffer test start:");
106+
Debug.Log("test 1: " + _bufferData1);
107+
_tcpSocket.Write(_bufferData1);
108+
Debug.Log("test 2: " + _bufferData2);
109+
_tcpSocket.Write(_bufferData2);
110+
Debug.Log("test 3: " + _bufferData3);
111+
_tcpSocket.Write(_bufferData3);
112+
}
113+
else
114+
{
115+
Debug.Log("发送失败:tcp实例未初始化或未连接");
116+
}
47117
}
48118
}
49119

Demo/API_V2/Assets/API/Network/TCPSocket/TCPSocketSO.asset

+2
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ MonoBehaviour:
2020
initialButtonText: "\u521B\u5EFAtcp\u5B9E\u4F8B"
2121
extraButtonList:
2222
- buttonText: "\u8FDE\u63A5"
23+
- buttonText: "\u53D1\u9001String"
24+
- buttonText: "\u53D1\u9001Buffer"
2325
- buttonText: "\u5173\u95ED"
2426
initialResultList: []

Demo/API_V2/Assets/Plugins/Editor.meta renamed to Demo/API_V2/Assets/API/OpenInterface/GameClub.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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: GameClub SO
14+
m_EditorClassIdentifier:
15+
entryScriptTypeName: GameClub
16+
entryName: "\u6E38\u620F\u5708"
17+
entryAPI: "getGameClubData\uFF0C createGameClubButton"
18+
entryDescription:
19+
optionList: []
20+
initialButtonText: "\u83B7\u53D6\u6E38\u620F\u5708\u6570\u636E"
21+
extraButtonList:
22+
- buttonText: "\u8FDB\u5165\u6E38\u620F\u5708"
23+
initialResultList: []

Demo/LaunchOpera/Assets/WX-WASM-SDK-V2/Editor/MiniGameConfig.asset.meta renamed to Demo/API_V2/Assets/API/OpenInterface/GameClub/GameClub SO.asset.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using UnityEngine;
5+
using LitJson;
6+
using WeChatWASM;
7+
using System.Threading;
8+
9+
public class GameClub : Details
10+
{
11+
private int[] _data = { 1, 3, 4 };
12+
13+
private WXGameClubButton _gameClubButton;
14+
15+
// Start is called before the first frame update
16+
private void Start()
17+
{
18+
var result = WX.GetLaunchOptionsSync();
19+
Debug.Log(JsonUtility.ToJson(result));
20+
21+
StartCoroutine(CreateGameClubButton(1.0f));
22+
23+
GameManager.Instance.detailsController.BindExtraButtonAction(0, GameClubButtonSwitch);
24+
}
25+
26+
IEnumerator CreateGameClubButton(float delay)
27+
{
28+
yield return new WaitForSeconds(delay);
29+
30+
Vector2 size = GameManager.Instance.detailsController.GetInitialButtonSize();
31+
Vector2 position = GameManager.Instance.detailsController.GetButtonPosition(0);
32+
var systemInfo = WX.GetSystemInfoSync();
33+
_gameClubButton = WX.CreateGameClubButton(new WXCreateGameClubButtonParam()
34+
{
35+
type = GameClubButtonType.text,
36+
style = new GameClubButtonStyle()
37+
{
38+
left = Math.Abs((int)(position.x / systemInfo.pixelRatio)),
39+
top = Math.Abs((int)(position.y / systemInfo.pixelRatio)),
40+
width = (int)(size.x * systemInfo.screenWidth / 1080f),
41+
height = (int)(size.y * systemInfo.screenWidth / 1080f),
42+
}
43+
});
44+
}
45+
46+
// ²âÊÔ API
47+
protected override void TestAPI(string[] args)
48+
{
49+
getGameClubData();
50+
}
51+
52+
private void getGameClubData()
53+
{
54+
GetGameClubDataOption option = new GetGameClubDataOption();
55+
56+
option.dataTypeList = new DataType[_data.Length];
57+
58+
for (int i = 0; i < _data.Length; i++)
59+
{
60+
option.dataTypeList[i] = new DataType();
61+
option.dataTypeList[i].type = _data[i];
62+
}
63+
64+
option.fail = (res) =>
65+
{
66+
Debug.Log("GetGameClubData fail: " + res.errMsg);
67+
};
68+
69+
option.complete = (res) =>
70+
{
71+
Debug.Log("GetGameClubData complete: " + JsonUtility.ToJson(res));
72+
};
73+
74+
option.success = (res) =>
75+
{
76+
Debug.Log("GetGameClubData success: " + JsonUtility.ToJson(res));
77+
Debug.Log("encryptedData:" + res.encryptedData);
78+
};
79+
80+
WX.GetGameClubData(option);
81+
}
82+
83+
private bool _isGameClubShow = false;
84+
85+
// Çл»ÓÎϷȦ°´Å¥ÏÔʾ/Òþ²Ø
86+
private void GameClubButtonSwitch()
87+
{
88+
//if (_isGameClubShow)
89+
//{
90+
// // ÏÔʾÓÎϷȦ°´Å¥
91+
// _gameClubButton.Show();
92+
// GameManager.Instance.detailsController.ChangeExtraButtonText(0, "Òþ²ØÓÎϷȦ°´Å¥");
93+
//}
94+
//else
95+
//{
96+
// // Òþ²ØÓÎϷȦ°´Å¥
97+
// _gameClubButton.Hide();
98+
// GameManager.Instance.detailsController.ChangeExtraButtonText(0, "ÏÔʾÓÎϷȦ°´Å¥");
99+
//}
100+
//_isGameClubShow = !_isGameClubShow;
101+
}
102+
103+
private void GameClubButtonDestroy()
104+
{
105+
Debug.Log("gameclub destroy");
106+
_gameClubButton.Destroy();
107+
}
108+
109+
public void Destroy()
110+
{
111+
if (_gameClubButton != null)
112+
{
113+
_gameClubButton.Hide();
114+
GameClubButtonDestroy();
115+
_gameClubButton = null;
116+
}
117+
}
118+
119+
}
120+
121+

Demo/API_V2/Assets/WX-WASM-SDK-V2/Editor/PicCompressor.cs.meta renamed to Demo/API_V2/Assets/API/OpenInterface/GameClub/GameClub.cs.meta

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Demo/API_V2/Assets/API/OpenInterface/OpenInterfaceSO.asset

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ MonoBehaviour:
1313
m_Name: OpenInterfaceSO
1414
m_EditorClassIdentifier:
1515
categoryName: "\u5F00\u653E\u63A5\u53E3"
16-
categorySprite: {fileID: 0}
16+
categorySprite: {fileID: 21300000, guid: 655a4cabb9e794434b9c028267c63e10, type: 3}
1717
entryList:
18+
- {fileID: 11400000, guid: d0c8de90644082f418ae2ec91900bd8f, type: 2}
1819
- {fileID: 11400000, guid: 8a4f679875fb6413b9b0df39d1359e57, type: 2}
1920
- {fileID: 11400000, guid: 2957939a29ac24a2e9ca1d4f6ccdb41e, type: 2}
2021
- {fileID: 11400000, guid: 2c8c997508e96423fa1031b948386d44, type: 2}

0 commit comments

Comments
 (0)