File tree 2 files changed +49
-4
lines changed
Demo/API_V2/Assets/API/Render/Render
2 files changed +49
-4
lines changed Original file line number Diff line number Diff line change @@ -14,12 +14,12 @@ private void Start()
14
14
// 测试 API
15
15
protected override void TestAPI ( string [ ] args )
16
16
{
17
- setPreferredFramesPerSecond ( ) ;
17
+ setFPS ( ) ;
18
18
}
19
19
20
- public void setPreferredFramesPerSecond ( )
20
+ public void setFPS ( )
21
21
{
22
- WX . SetPreferredFramesPerSecond ( 50 ) ;
22
+ Application . targetFrameRate = 30 ;
23
23
}
24
24
25
25
public void loadFont ( )
@@ -30,6 +30,6 @@ public void loadFont()
30
30
31
31
public void Destroy ( )
32
32
{
33
- WX . SetPreferredFramesPerSecond ( 60 ) ;
33
+ Application . targetFrameRate = 60 ;
34
34
}
35
35
}
Original file line number Diff line number Diff line change
1
+ # 自定义SDK调用
2
+ 微信SDK提供了` WX.CallJSFunction ` 与` WX.CallJSFunctionWithReturn ` 接口实现了简单的第三方SDK调用,支持可序列化为JSON的** 任意数量的参数** 与** 返回值** 。
3
+
4
+ 其中,JS侧的实际调用逻辑为` GameGlobal.sdkName.functionName(args) ` ,所以在调用之前需要保证SDK位于` GameGlobal ` 下且SDK中含有该名称的function。
5
+
6
+ 在` WX.CallJSFunctionWithReturn ` 中,会将函数返回值转换为JSON后传回,若无返回值则传回` "" ` 。
7
+
8
+ 如需更加复杂的调用,可参考[ WebGL:与浏览器脚本交互] ( https://docs.unity3d.com/cn/2018.4/Manual/webgl-interactingwithbrowserscripting.html ) 进行自定义定制。
9
+
10
+ ## 版本要求
11
+ ` 转换插件 >= 202406062127 `
12
+
13
+ ## 代码示例
14
+
15
+ 示例中的"sdk"、"testFunction"、TestFunctionOption仅作为演示,实际使用中请自行更改。
16
+
17
+ ``` csharp
18
+ WeChatWASM .WX .CallJSFunction (" sdk" , " testFunction" , new TestFunctionOption
19
+ {
20
+ type = " text" ,
21
+ text = " 反馈" ,
22
+ style = new OptionStyle ()
23
+ {
24
+ left = 10 ,
25
+ top = 10 ,
26
+ width = 100 ,
27
+ height = 100 ,
28
+ backgroundColor = " #ff0000" ,
29
+ color = " #ffffff" ,
30
+ textAlign = " center" ,
31
+ fontSize = 20 ,
32
+ borderRadius = 10 ,
33
+ lineHeight = 100 ,
34
+ }
35
+ });
36
+ ```
37
+
38
+ 另外,在js侧代码中合适位置添加以下代码,可配合[ 构建模版能力] ( https://wechat-miniprogram.github.io/minigame-unity-webgl-transform/Design/BuildTemplate.html ) 使用。
39
+
40
+ ``` js
41
+ GameGlobal[" sdk" ] = sdk;
42
+ ```
43
+
44
+
45
+
You can’t perform that action at this time.
0 commit comments