AASDKDemoScript.cs
2.9 KB
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;
using UnityEngine;
using AntiAddictionSDK.Api;
using AntiAddictionSDK.Common;
using AntiAddictionSDK;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class AASDKDemoScript: MonoBehaviour
{
AntiAddictionStytemSDK antiAddictionSDK;
public Text statusText;
public InputField inputField;
// Start is called before the first frame update
void Start()
{
antiAddictionSDK = new AntiAddictionStytemSDK();
antiAddictionSDK.ZAASDKCompleted += HandleZAASDKCompleted;
antiAddictionSDK.ZAASDKCheckPayCompleted += HandleZAASDKCheckPayCompleted;
}
// 获取用户实名认证状态
// 0: 未实名认证
// 1:已实名认证
public void IsAuthenticated()
{
if (antiAddictionSDK != null)
{
String infoString = "--- IsAuthenticated:" + antiAddictionSDK.IsAuthenticated();
print(infoString);
statusText.text = infoString;
}
}
// 获取当前用户年龄段
// 0 未认证
// 1 成年人
// 2 未成年人
public void GetUserAgeGroup()
{
if (antiAddictionSDK != null)
{
String infoString = "--- GetUserAgeGroup:" + antiAddictionSDK.AgeGroupOfCurrentUser();
print(infoString);
statusText.text = infoString;
}
}
// 获取当前用户剩余可玩时长
// 如果为-1,表示当前用户为成年人账号,将不受防沉迷限制
// 如果为大于0的数,返回的为当前用户的剩余可玩时长,单位秒
public void LeftTimeOfCurrentUser()
{
if (antiAddictionSDK != null)
{
String infoString = "--- LeftTimeOfCurrentUser:" + antiAddictionSDK.LeftTimeOfCurrentUser();
print(infoString);
statusText.text = infoString;
}
}
public void checkPayWithAmount()
{
if (antiAddictionSDK != null)
{
antiAddictionSDK.checkPayWithAmount(inputField.text);
String infoString = "--- checkPayWithAmount:" + inputField.text;
print(infoString);
statusText.text = infoString;
}
}
public void recordPayWithAmount()
{
if (antiAddictionSDK != null)
{
antiAddictionSDK.recordPayWithAmount(inputField.text);
String infoString = "--- recordPayWithAmount:" + inputField.text;
print(infoString);
statusText.text = infoString;
}
}
public void HandleZAASDKCompleted(object sender, EventArgs args)
{
String infoString = "--- ZAASDK HandleZAASDKCompleted !";
print(infoString);
statusText.text = infoString;
}
public void HandleZAASDKCheckPayCompleted(object sender, EventArgs args)
{
String infoString = "--- The check passes, you can pay ";
print(infoString);
statusText.text = infoString;
}
}