Skip to content

Commit 36da128

Browse files
author
Ocean
committed
2 parents 4aef33c + 1e98b80 commit 36da128

File tree

129 files changed

+17505
-169
lines changed

Some content is hidden

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

129 files changed

+17505
-169
lines changed

.config/.vitepress/config.mts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ export default defineConfig({
118118
{ text: "优化Unity WebGL的渲染性能", link: "/Design/RenderOptimization" },
119119
{ text: "定制微信小游戏的 URP 管线", link: "/Design/CustomURP" },
120120
{ text: "WebGL2.0渲染支持说明", link: "/Design/WebGL2" },
121+
{ text: "性能深度分析工具", link: "/Design/DeepProfileTool" },
122+
{ text: "高精度时间", link: "/Design/HighPreciseTime" },
121123
],
122124
},
123125
],
@@ -141,7 +143,8 @@ export default defineConfig({
141143
{ text: "后端服务指引", link: "/Design/BackendServiceStartup" },
142144
{ text: "网络通信适配", link: "/Design/UsingNetworking" },
143145
{ text: "使用水印保护代码包安全", link: "/Design/wasmWaterMark" },
144-
{ text: "配置构建模板", link: "/Design/BuildTemplate.md" }
146+
{ text: "配置构建模板", link: "/Design/BuildTemplate.md" },
147+
{ text: "实时预览工具", link: "/Design/WechatPreview.md" },
145148
],
146149
},
147150
{

Demo/API_V2/Assets/API/APISO.asset

Lines changed: 1 addition & 1 deletion
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/Facility/FacilitySO.asset

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ MonoBehaviour:
1515
categoryName: "\u8BBE\u5907"
1616
categorySprite: {fileID: 21300000, guid: 53dd2b1922e5142ec8a53037f362fc56, 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/Facility/Screen/ScreenSO.asset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ MonoBehaviour:
2626
- buttonText: "\u67E5\u8BE2\u7528\u6237\u662F\u5426\u5728\u5F55\u5C4F"
2727
- buttonText: "\u83B7\u53D6\u5C4F\u5E55\u4EAE\u5EA6"
2828
initialResultList: []
29+
entryOrder: 0

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ 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}
3131
categoryOrder: 11
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using UnityEngine;
2+
using TMPro;
3+
4+
// 添加 Text 组件的依赖
5+
[RequireComponent(typeof(TMP_Text))]
6+
public class TMPTextInit : MonoBehaviour
7+
{
8+
private TMP_Text _text;
9+
10+
11+
private void Awake()
12+
{
13+
// 获取 Text 组件
14+
_text = GetComponent<TMP_Text>();
15+
}
16+
17+
private void Start()
18+
{
19+
// 如果 GameManager 的字体已经加载,直接设置 Text 的字体
20+
if (GameManager.Instance.font != null)
21+
{
22+
_text.font = GameManager.Instance.fonts;
23+
}
24+
else
25+
{
26+
// 如果字体还未加载,添加字体加载事件监听器
27+
GameManager.Instance.OnTMPFontLoaded += OnFontLoaded;
28+
}
29+
}
30+
31+
private void OnDestroy()
32+
{
33+
// 移除字体加载事件监听器
34+
GameManager.Instance.OnTMPFontLoaded -= OnFontLoaded;
35+
}
36+
37+
// 当字体加载完成时,设置 Text 的字体
38+
private void OnFontLoaded(TMP_FontAsset fonts)
39+
{
40+
_text.font = fonts;
41+
}
42+
}

Demo/API_V2/Assets/API/InputField/TmpTextInit.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.

Demo/API_V2/Assets/API/InputField/WXInputFieldAdapter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private void ShowKeyboard()
6262

6363
WX.ShowKeyboard(new ShowKeyboardOption()
6464
{
65-
defaultValue = "xxx",
65+
defaultValue = _inputField.text,
6666
maxLength = 20,
6767
confirmType = "go"
6868
});
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
using UnityEngine;
2+
using WeChatWASM;
3+
using TMPro;
4+
using UnityEngine.EventSystems;
5+
6+
// 要求该组件必须附加 TMP_InputField 组件
7+
[RequireComponent(typeof(TMP_InputField))]
8+
public class WXInputFieldTmpAdapter : MonoBehaviour, IPointerClickHandler, IPointerExitHandler
9+
{
10+
private TMP_InputField _inputField; // 存储 TMP_InputField 组件的引用
11+
private bool _isShowKeyboard = false; // 标记键盘是否显示
12+
13+
private void Start()
14+
{
15+
// 获取挂载在同一游戏对象上的 TMP_InputField 组件
16+
_inputField = GetComponent<TMP_InputField>();
17+
}
18+
19+
// 当指针点击该组件时调用
20+
public void OnPointerClick(PointerEventData eventData)
21+
{
22+
ShowKeyboard(); // 显示键盘
23+
}
24+
25+
// 当指针离开该组件时调用
26+
public void OnPointerExit(PointerEventData eventData)
27+
{
28+
// 如果 TMP_InputField 没有被聚焦,则隐藏键盘
29+
if (!_inputField.isFocused)
30+
{
31+
HideKeyboard();
32+
}
33+
}
34+
35+
// 输入法输入回调
36+
private void OnInput(OnKeyboardInputListenerResult v)
37+
{
38+
// 如果 TMP_InputField 被聚焦,则将输入值赋给 TMP_InputField
39+
if (_inputField.isFocused)
40+
{
41+
_inputField.text = v.value;
42+
}
43+
}
44+
45+
// 输入法确认回调
46+
private void OnConfirm(OnKeyboardInputListenerResult v)
47+
{
48+
HideKeyboard(); // 隐藏键盘
49+
}
50+
51+
// 输入法完成回调
52+
private void OnComplete(OnKeyboardInputListenerResult v)
53+
{
54+
HideKeyboard(); // 隐藏键盘
55+
}
56+
57+
// 显示键盘的方法
58+
private void ShowKeyboard()
59+
{
60+
// 如果键盘已经显示,则直接返回
61+
if (_isShowKeyboard) return;
62+
63+
// 调用 WeChat API 显示键盘
64+
WX.ShowKeyboard(new ShowKeyboardOption()
65+
{
66+
defaultValue = _inputField.text,//传入当前文本作为默认值
67+
maxLength = 20, // 最大输入长度
68+
confirmType = "go" // 确认按钮类型
69+
});
70+
71+
// 绑定键盘事件回调
72+
WX.OnKeyboardConfirm(this.OnConfirm);
73+
WX.OnKeyboardComplete(this.OnComplete);
74+
WX.OnKeyboardInput(this.OnInput);
75+
_isShowKeyboard = true; // 更新键盘显示状态
76+
}
77+
78+
// 隐藏键盘的方法
79+
private void HideKeyboard()
80+
{
81+
// 如果键盘未显示,则直接返回
82+
if (!_isShowKeyboard) return;
83+
84+
// 调用 WeChat API 隐藏键盘
85+
WX.HideKeyboard(new HideKeyboardOption());
86+
// 移除事件监听
87+
WX.OffKeyboardInput(this.OnInput);
88+
WX.OffKeyboardConfirm(this.OnConfirm);
89+
WX.OffKeyboardComplete(this.OnComplete);
90+
_isShowKeyboard = false; // 更新键盘显示状态
91+
}
92+
}

Demo/API_V2/Assets/API/InputField/WXInputFieldTmpAdapter.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.

0 commit comments

Comments
 (0)