yyl
2026-05-11 51b0f6ed9f4e1d3bb6f8144470b46908c7699a96
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
#if UNITY_WEBGL
using UnityEngine;
using LitJson;
using System;
 
/// <summary>
/// WebGL平台SDK实现,继承SDKBaseImpl。
/// WebGL无原生SDK层,登录直接模拟回调,退出跳转空白页。
/// </summary>
public class SDKWebGLImpl : SDKBaseImpl
{
    public SDKWebGLImpl(SDKUtils utils) : base(utils) { }
 
    // -------------------------------------------------------
    // 消息发送 —— WebGL无原生SDK,标记初始化完成即可
    // -------------------------------------------------------
    public override void SendToNative(string jsonStr)
    {
        // WebGL无原生SDK Bridge,收到第一次SendToNative(Init消息)后标记完成
        utils.InitFinished = true;
    }
 
    // -------------------------------------------------------
    // 初始化 —— WebGL无内置资源拷贝流程
    // -------------------------------------------------------
    public override void InitPlatform()
    {
        // WebGL不需要内置资源拷贝状态检查
    }
 
    // -------------------------------------------------------
    // SDK登录 —— WebGL直接模拟登录成功回调
    // -------------------------------------------------------
    public override void FreePlatformLogin()
    {
        Debug.Log("[SDKWebGLImpl] FreePlatformLogin: WebGL模拟登录");
 
        var info = new SDKUtils.FP_LoginOk
        {
            account      = "webgl_user",
            token        = "111",          // 内测服免密约定,与 InterTest Password 一致
            qkUserName   = "webgl_user",
            tokenExpire  = "9999999999",
            accountID    = 0,
            phone        = 0,
        };
 
        utils.FreePlatformInfo = info;
        utils.onFreePlatformLoginOk?.Invoke(info);
    }
 
    // -------------------------------------------------------
    // 设备信息 —— WebGL无特有设备字段
    // -------------------------------------------------------
    public override void FillDeviceInfo(JsonData json)
    {
        // WebGL下无mac/imei等字段,不做额外填充
    }
 
    // -------------------------------------------------------
    // 退出游戏 —— WebGL跳转空白页
    // -------------------------------------------------------
    public override void ExitGame()
    {
        Application.OpenURL("about:blank");
    }
}
#endif