Skip to content

Commit 27d74f6

Browse files
committed
api界面相关demo
1 parent a4496e0 commit 27d74f6

19 files changed

+2389
-185
lines changed

Demo/API_V2/Assets/API/GUI.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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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: GUISO
14+
m_EditorClassIdentifier:
15+
categoryName: "\u754C\u9762"
16+
categorySprite: {fileID: 0}
17+
entryList:
18+
- {fileID: 11400000, guid: 546628e39e8c246c38eebcdfbfd35b47, type: 2}
19+
- {fileID: 11400000, guid: 6902bd974e09745c4a185485a99c165d, type: 2}
20+
- {fileID: 11400000, guid: 7d54d37634607415697fd83a27026953, type: 2}

Demo/API_V2/Assets/API/GUI/GUISO.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/GUI/Interact.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: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using LitJson;
4+
using UnityEngine;
5+
using WeChatWASM;
6+
public class Interact : Details
7+
{
8+
private void Start()
9+
{
10+
// 绑定额外的按钮操作
11+
GameManager.Instance.detailsController.BindExtraButtonAction(0, showModal);
12+
GameManager.Instance.detailsController.BindExtraButtonAction(1, showLoading);
13+
GameManager.Instance.detailsController.BindExtraButtonAction(2, showActionSheet);
14+
GameManager.Instance.detailsController.BindExtraButtonAction(3, hideToast);
15+
GameManager.Instance.detailsController.BindExtraButtonAction(4, hideLoading);
16+
}
17+
18+
// 测试 API
19+
protected override void TestAPI(string[] args)
20+
{
21+
showToast();
22+
}
23+
24+
public void showToast() {
25+
WX.ShowToast(new ShowToastOption
26+
{
27+
title = "showToast",
28+
duration = 5000,
29+
success = (res) =>
30+
{
31+
Debug.Log(res);
32+
},
33+
fail = (res) =>
34+
{
35+
Debug.Log("fail:" + res.errMsg);
36+
},
37+
complete = (res) =>
38+
{
39+
Debug.Log("complete!");
40+
}
41+
});
42+
}
43+
44+
public void showModal() {
45+
WX.ShowModal(new ShowModalOption
46+
{
47+
title = "showModal",
48+
content = "show",
49+
showCancel = true,
50+
cancelText = "取消",
51+
confirmText = "确定",
52+
success = (res) =>
53+
{
54+
Debug.Log("success");
55+
},
56+
fail = (res) =>
57+
{
58+
Debug.Log("fail:" + res.errMsg);
59+
},
60+
complete = (res) =>
61+
{
62+
Debug.Log("complete!");
63+
}
64+
});
65+
}
66+
67+
public void showLoading() {
68+
WX.ShowLoading(new ShowLoadingOption
69+
{
70+
title = "showLoading",
71+
success = (res) =>
72+
{
73+
Debug.Log("success");
74+
},
75+
fail = (res) =>
76+
{
77+
Debug.Log("fail:" + res.errMsg);
78+
},
79+
complete = (res) =>
80+
{
81+
Debug.Log("complete!");
82+
}
83+
});
84+
}
85+
86+
public void showActionSheet() {
87+
WX.ShowActionSheet(new ShowActionSheetOption
88+
{
89+
alertText = "showActionSheet",
90+
itemList = new string[] {"1", "2", "3"},
91+
success = (res) =>
92+
{
93+
Debug.Log("success");
94+
},
95+
fail = (res) =>
96+
{
97+
Debug.Log("fail:" + res.errMsg);
98+
},
99+
complete = (res) =>
100+
{
101+
Debug.Log("complete!");
102+
}
103+
});
104+
}
105+
106+
public void hideToast() {
107+
WX.HideToast(new HideToastOption
108+
{
109+
success = (res) =>
110+
{
111+
Debug.Log("success");
112+
},
113+
fail = (res) =>
114+
{
115+
Debug.Log("fail:" + res.errMsg);
116+
},
117+
complete = (res) =>
118+
{
119+
Debug.Log("complete!");
120+
}
121+
});
122+
}
123+
124+
public void hideLoading() {
125+
WX.HideLoading(new HideLoadingOption
126+
{
127+
success = (res) =>
128+
{
129+
Debug.Log("success");
130+
},
131+
fail = (res) =>
132+
{
133+
Debug.Log("fail:" + res.errMsg);
134+
},
135+
complete = (res) =>
136+
{
137+
Debug.Log("complete!");
138+
}
139+
});
140+
}
141+
}

Demo/API_V2/Assets/API/GUI/Interact/Interact.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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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: InteractSO
14+
m_EditorClassIdentifier:
15+
entryScriptTypeName: Interact
16+
entryName: "\u4EA4\u4E92"
17+
entryAPI: "showToast \uFF5C showModal\nshowLoading \uFF5C showActionSheet\nhideToast
18+
\uFF5ChideLoading"
19+
entryDescription:
20+
optionList: []
21+
initialButtonText: "\u663E\u793A\u6D88\u606F\u63D0\u793A\u6846"
22+
extraButtonList:
23+
- buttonText: "\u663E\u793A\u6A21\u6001\u5BF9\u8BDD\u6846"
24+
- buttonText: "\u663E\u793A loading \u63D0\u793A\u6846"
25+
- buttonText: "\u663E\u793A\u64CD\u4F5C\u83DC\u5355"
26+
- buttonText: "\u9690\u85CF\u6D88\u606F\u63D0\u793A\u6846"
27+
- buttonText: "\u9690\u85CF loading \u63D0\u793A\u6846"
28+
initialResultList: []

Demo/API_V2/Assets/API/GUI/Interact/InteractSO.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/GUI/Menu.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: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using LitJson;
4+
using UnityEngine;
5+
using WeChatWASM;
6+
public class Menu : Details
7+
{
8+
private void Start()
9+
{
10+
// 绑定额外的按钮操作
11+
GameManager.Instance.detailsController.BindExtraButtonAction(0, getMenuButtonBoundingClientRect);
12+
GameManager.Instance.detailsController.BindExtraButtonAction(0, setStatusBarStyle);
13+
}
14+
15+
// 测试 API
16+
protected override void TestAPI(string[] args)
17+
{
18+
setMenuStyle();
19+
}
20+
21+
public void setMenuStyle() {
22+
WX.SetMenuStyle(new SetMenuStyleOption
23+
{
24+
style = "light",
25+
success = (res) =>
26+
{
27+
WX.ShowToast(new ShowToastOption
28+
{
29+
title = "设置成功"
30+
});
31+
},
32+
fail = (res) =>
33+
{
34+
Debug.Log("fail:" + res.errMsg);
35+
},
36+
complete = (res) =>
37+
{
38+
Debug.Log("complete!");
39+
}
40+
});
41+
}
42+
43+
public void getMenuButtonBoundingClientRect() {
44+
var res = WX.GetMenuButtonBoundingClientRect();
45+
46+
// 访问成功,显示结果
47+
WX.ShowModal(new ShowModalOption()
48+
{
49+
content = "Access Success, Result: " + JsonMapper.ToJson(res)
50+
});
51+
}
52+
53+
public void setStatusBarStyle() {
54+
WX.SetStatusBarStyle(new SetStatusBarStyleOption
55+
{
56+
style = "black",
57+
success = (res) =>
58+
{
59+
WX.ShowToast(new ShowToastOption
60+
{
61+
title = "设置成功"
62+
});
63+
},
64+
fail = (res) =>
65+
{
66+
Debug.Log("fail:" + res.errMsg);
67+
},
68+
complete = (res) =>
69+
{
70+
Debug.Log("complete!");
71+
}
72+
});
73+
}
74+
}

0 commit comments

Comments
 (0)