#if UNITY_WEBGL using UnityEngine; using LitJson; using System; /// /// WebGL平台SDK实现,继承SDKBaseImpl。 /// WebGL无原生SDK层,登录直接模拟回调,退出跳转空白页。 /// 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