AASDKDemoScript.cs
1.7 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
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;
// Start is called before the first frame update
void Start()
{
antiAddictionSDK = new AntiAddictionStytemSDK();
antiAddictionSDK.ZAASDKCompleted += HandleZAASDKCompleted;
}
// 获取用户实名认证状态
// 0: 未实名认证
// 1:已实名认证
public void IsAuthenticated()
{
statusText.text = "IsAuthenticated";
if (antiAddictionSDK != null)
{
statusText.text = antiAddictionSDK.IsAuthenticated()+"";
}
}
// 获取当前用户年龄段
// 0 未认证
// 1 成年人
// 2 未成年人
public void GetUserAgeGroup()
{
statusText.text = "GetUserAgeGroup";
if (antiAddictionSDK != null)
{
statusText.text = antiAddictionSDK.AgeGroupOfCurrentUser()+"";
}
}
// 获取当前用户剩余可玩时长
// 如果为-1,表示当前用户为成年人账号,将不受防沉迷限制
// 如果为大于0的数,返回的为当前用户的剩余可玩时长,单位秒
public void LeftTimeOfCurrentUser()
{
statusText.text = "LeftTimeOfCurrentUser";
if (antiAddictionSDK != null)
{
statusText.text = antiAddictionSDK.LeftTimeOfCurrentUser()+"";
}
}
public void HandleZAASDKCompleted(object sender, EventArgs args)
{
statusText.text = "HandleZAASDKCompleted";
print("AntiAddiction---HandleZAASDKCompleted");
}
}