-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLaunchOpera.cs
107 lines (96 loc) · 3.12 KB
/
LaunchOpera.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System.Collections;
using System.Collections.Generic;
using LitJson;
using UnityEngine;
using UnityEngine.UI;
using WeChatWASM;
public class LaunchOpera : MonoBehaviour
{
public Button ResetNewUser;
public Button SyncDemo;
public Button AsyncDemo;
public Button CustomPrgressDemo;
// Start is called before the first frame update
void Start()
{
ResetNewUser.onClick.AddListener(() =>
{
WX.RemoveStorageSync("launchOperaLocalData_Demo");
WX.ShowToast(
new ShowToastOption()
{
title = "Cleaned up, please restart the game",
icon = "none",
}
);
});
SyncDemo.onClick.AddListener(() =>
{
WX.RemoveStorageSync("launchOperaLocalData_Async");
WX.ShowModal(
new ShowModalOption()
{
content =
"Successfully set, restart the game and when a new user starts playing the LaunchOpera, otherwise it will not be played.",
showCancel = false,
}
);
});
AsyncDemo.onClick.AddListener(() =>
{
WX.StorageSetStringSync("launchOperaLocalData_Async", "1");
WX.ShowModal(
new ShowModalOption()
{
content =
"Successfully set, restart the game and New users play the complete LaunchOpera, while old users only play the logo video.",
showCancel = false,
}
);
});
CustomPrgressDemo.onClick.AddListener(() =>
{
WX.StorageSetStringSync("launchOperaLocalData_UseCustomProgress", "1");
WX.ShowModal(
new ShowModalOption()
{
content =
"Successfully set, restart the game and progress bar will eventually stop at 85%",
showCancel = false,
}
);
string req = JsonMapper.ToJson(new object[] { 1, "a", false });
Debug.Log(req);
WX.GetLaunchOperaHandler().SetPercentage(0.5);
});
// CustomProgress Test
// 70% + 30% * 0.5 = 85%
WX.GetLaunchOperaHandler().SetPercentage(0.5);
// On LaunchOpera End
WX.GetLaunchOperaHandler()
.onEnd(
(status) =>
{
WX.ShowToast(
new ShowToastOption()
{
title = "C#(WASM) received the ending callback event!",
icon = "none",
}
);
}
);
}
private class JsMethodInfo
{
public string function;
public object[] args;
public JsMethodInfo(string func, object[] args)
{
this.function = func;
this.args = args == null ? new object[] { } : args;
}
}
// Update is called once per frame
void Update() { }
}