Skip to content

Commit 1be1d5d

Browse files
committed
社交组件-demo
1 parent 445e276 commit 1be1d5d

File tree

9 files changed

+1198
-29
lines changed

9 files changed

+1198
-29
lines changed

Demo/API_V2/Assets/API/Chat.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/Chat/ChatManager.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: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
using UnityEngine;
2+
3+
using WeChatWASM;
4+
5+
public class ChatManager : Details
6+
{
7+
private static WXChat WxChat = null;
8+
9+
private void Start()
10+
{
11+
CreateChat();
12+
SetTabs();
13+
14+
// 绑定额外的按钮操作
15+
GameManager.Instance.detailsController.BindExtraButtonAction(0, Hide);
16+
GameManager.Instance.detailsController.BindExtraButtonAction(1, Open);
17+
GameManager.Instance.detailsController.BindExtraButtonAction(2, Close);
18+
}
19+
20+
// 测试 API
21+
protected override void TestAPI(string[] args)
22+
{
23+
Show();
24+
}
25+
26+
private void CreateChat()
27+
{
28+
if (WxChat != null)
29+
{
30+
// 已创建
31+
Debug.Log("已创建");
32+
return;
33+
}
34+
35+
WxChat = WX.CreateMiniGameChat();
36+
37+
if (WxChat == null)
38+
{
39+
// 创建失败
40+
return;
41+
}
42+
43+
WxChat.On("ready", (res) =>
44+
{
45+
Debug.Log("wxChat ready");
46+
});
47+
48+
WxChat.On("show", (res) =>
49+
{
50+
Debug.Log("wxChat show");
51+
});
52+
53+
WxChat.On("hide", (res) =>
54+
{
55+
Debug.Log("wxChat hide");
56+
});
57+
58+
WxChat.On("open", (res) =>
59+
{
60+
Debug.Log("wxChat open");
61+
});
62+
63+
WxChat.On("close", (res) =>
64+
{
65+
Debug.Log("wxChat close");
66+
});
67+
68+
WxChat.On("interact", (res) =>
69+
{
70+
Debug.Log("wxChat interact");
71+
Debug.Log(JsonUtility.ToJson(res));
72+
73+
// TODO 处理互动消息
74+
});
75+
76+
WxChat.On("authorize", (res) =>
77+
{
78+
Debug.Log("wxChat authorize");
79+
Debug.Log(JsonUtility.ToJson(res));
80+
81+
// TODO 传rawData给后台,后台计算出signature后设置
82+
WxChat.SetChatSignature("test signature");
83+
});
84+
}
85+
86+
public void Show()
87+
{
88+
if (WxChat != null)
89+
{
90+
WxChat.Show();
91+
}
92+
}
93+
94+
public void Hide()
95+
{
96+
if (WxChat != null)
97+
{
98+
WxChat.Hide();
99+
}
100+
}
101+
102+
public void SetTabs()
103+
{
104+
if (WxChat != null)
105+
{
106+
WxChat.SetTabs(new string[] { "chat", "player" });
107+
}
108+
}
109+
110+
public void Open()
111+
{
112+
if (WxChat != null)
113+
{
114+
WxChat.Open();
115+
}
116+
}
117+
118+
public void Close()
119+
{
120+
if (WxChat != null)
121+
{
122+
WxChat.Close();
123+
}
124+
}
125+
126+
private void OnDestroy()
127+
{
128+
Hide();
129+
}
130+
}

Demo/API_V2/Assets/API/Chat/ChatManager/ChatManager.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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: ChatManagerSO
14+
m_EditorClassIdentifier:
15+
entryScriptTypeName: ChatManager
16+
entryName: "\u793E\u4EA4\u7EC4\u4EF6"
17+
entryAPI: 'CreateMiniGameChat
18+
19+
'
20+
entryDescription:
21+
optionList: []
22+
initialButtonText: "\u663E\u793A"
23+
extraButtonList:
24+
- buttonText: "\u9690\u85CF"
25+
- buttonText: "\u6253\u5F00"
26+
- buttonText: "\u5173\u95ED"
27+
initialResultList: []

Demo/API_V2/Assets/API/Chat/ChatManager/ChatManagerSO.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.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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: 4a9e19ed69c041c408533b50f5572d0f, type: 3}
13+
m_Name: ChatSO
14+
m_EditorClassIdentifier:
15+
categoryName: "\u793E\u4EA4\u7EC4\u4EF6"
16+
categorySprite: {fileID: 0}
17+
entryList:
18+
- {fileID: 11400000, guid: 26e13aeac49284f87b5aaba6366af379, type: 2}

Demo/API_V2/Assets/API/Chat/ChatSO.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.

0 commit comments

Comments
 (0)