From 1ab047b5fdd933c38ba0519ec2e83a44512ea8d7 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期四, 26 三月 2026 17:46:11 +0800
Subject: [PATCH] webgl代码合并 1

---
 Main/Core/Platform/DouyinPlatform.cs |  330 +++++++++++++++++++++++++++---------------------------
 1 files changed, 165 insertions(+), 165 deletions(-)

diff --git a/Main/Core/Platform/DouyinPlatform.cs b/Main/Core/Platform/DouyinPlatform.cs
index 04adc3d..fb32988 100644
--- a/Main/Core/Platform/DouyinPlatform.cs
+++ b/Main/Core/Platform/DouyinPlatform.cs
@@ -1,193 +1,193 @@
-using System;
-using System.Runtime.InteropServices;
-using Cysharp.Threading.Tasks;
-using UnityEngine;
+// using System;
+// using System.Runtime.InteropServices;
+// using Cysharp.Threading.Tasks;
+// using UnityEngine;
 
-/// <summary>
-/// 鎶栭煶灏忔父鎴忓钩鍙板疄鐜�
-/// </summary>
-public class DouyinPlatform : IPlatformService
-{
-    #if UNITY_WEBGL && !UNITY_EDITOR
-    // JavaScript 鎻掍欢鏂规硶澹版槑
-    [DllImport("__Internal")]
-    private static extern bool TT_Init();
+// /// <summary>
+// /// 鎶栭煶灏忔父鎴忓钩鍙板疄鐜�
+// /// </summary>
+// public class DouyinPlatform : IPlatformService
+// {
+//     #if UNITY_WEBGL && !UNITY_EDITOR
+//     // JavaScript 鎻掍欢鏂规硶澹版槑
+//     [DllImport("__Internal")]
+//     private static extern bool TT_Init();
     
-    [DllImport("__Internal")]
-    private static extern void TT_Login(string callbackObjectName, string callbackMethodName);
+//     [DllImport("__Internal")]
+//     private static extern void TT_Login(string callbackObjectName, string callbackMethodName);
     
-    [DllImport("__Internal")]
-    private static extern string TT_GetSystemInfo();
+//     [DllImport("__Internal")]
+//     private static extern string TT_GetSystemInfo();
     
-    [DllImport("__Internal")]
-    private static extern void TT_ShareAppMessage(string title, string imageUrl);
+//     [DllImport("__Internal")]
+//     private static extern void TT_ShareAppMessage(string title, string imageUrl);
     
-    [DllImport("__Internal")]
-    private static extern void TT_CreateRewardedVideoAd(string adUnitId, string callbackObjectName, string callbackMethodName);
+//     [DllImport("__Internal")]
+//     private static extern void TT_CreateRewardedVideoAd(string adUnitId, string callbackObjectName, string callbackMethodName);
     
-    [DllImport("__Internal")]
-    private static extern void TT_SetStorageSync(string key, string value);
+//     [DllImport("__Internal")]
+//     private static extern void TT_SetStorageSync(string key, string value);
     
-    [DllImport("__Internal")]
-    private static extern string TT_GetStorageSync(string key);
+//     [DllImport("__Internal")]
+//     private static extern string TT_GetStorageSync(string key);
     
-    [DllImport("__Internal")]
-    private static extern void TT_VibrateShort();
+//     [DllImport("__Internal")]
+//     private static extern void TT_VibrateShort();
     
-    [DllImport("__Internal")]
-    private static extern void TT_VibrateLong();
-    #endif
+//     [DllImport("__Internal")]
+//     private static extern void TT_VibrateLong();
+//     #endif
     
-    private SystemInfo _cachedSystemInfo;
-    private bool _isInitialized = false;
+//     private SystemInfo _cachedSystemInfo;
+//     private bool _isInitialized = false;
     
-    public async UniTask<bool> InitAsync()
-    {
-        Debug.Log("[DouyinPlatform] 鍒濆鍖栨姈闊冲皬娓告垙骞冲彴");
+//     public async UniTask<bool> InitAsync()
+//     {
+//         Debug.Log("[DouyinPlatform] 鍒濆鍖栨姈闊冲皬娓告垙骞冲彴");
         
-        #if UNITY_WEBGL && !UNITY_EDITOR
-        try
-        {
-            _isInitialized = TT_Init();
-            if (_isInitialized)
-            {
-                _cachedSystemInfo = GetSystemInfo();
-                Debug.Log("[DouyinPlatform] 鍒濆鍖栨垚鍔�");
-            }
-            return _isInitialized;
-        }
-        catch (Exception e)
-        {
-            Debug.LogError($"[DouyinPlatform] 鍒濆鍖栧け璐�: {e.Message}");
-            return false;
-        }
-        #else
-        await UniTask.Delay(100);
-        _isInitialized = true;
-        _cachedSystemInfo = CreateMockSystemInfo();
-        return true;
-        #endif
-    }
+//         #if UNITY_WEBGL && !UNITY_EDITOR
+//         try
+//         {
+//             _isInitialized = TT_Init();
+//             if (_isInitialized)
+//             {
+//                 _cachedSystemInfo = GetSystemInfo();
+//                 Debug.Log("[DouyinPlatform] 鍒濆鍖栨垚鍔�");
+//             }
+//             return _isInitialized;
+//         }
+//         catch (Exception e)
+//         {
+//             Debug.LogError($"[DouyinPlatform] 鍒濆鍖栧け璐�: {e.Message}");
+//             return false;
+//         }
+//         #else
+//         await UniTask.Delay(100);
+//         _isInitialized = true;
+//         _cachedSystemInfo = CreateMockSystemInfo();
+//         return true;
+//         #endif
+//     }
     
-    public PlatformType GetPlatformType()
-    {
-        return PlatformType.Douyin;
-    }
+//     public PlatformType GetPlatformType()
+//     {
+//         return PlatformType.Douyin;
+//     }
     
-    public async UniTask<LoginResult> LoginAsync()
-    {
-        Debug.Log("[DouyinPlatform] 寮�濮嬬櫥褰�");
+//     public async UniTask<LoginResult> LoginAsync()
+//     {
+//         Debug.Log("[DouyinPlatform] 寮�濮嬬櫥褰�");
         
-        #if UNITY_WEBGL && !UNITY_EDITOR
-        // TODO: 瀹炵幇鎶栭煶鐧诲綍閫昏緫
-        await UniTask.Delay(500);
-        return new LoginResult { Success = true, UserId = "douyin_user" };
-        #else
-        await UniTask.Delay(500);
-        return new LoginResult { Success = true, UserId = "douyin_test_user" };
-        #endif
-    }
+//         #if UNITY_WEBGL && !UNITY_EDITOR
+//         // TODO: 瀹炵幇鎶栭煶鐧诲綍閫昏緫
+//         await UniTask.Delay(500);
+//         return new LoginResult { Success = true, UserId = "douyin_user" };
+//         #else
+//         await UniTask.Delay(500);
+//         return new LoginResult { Success = true, UserId = "douyin_test_user" };
+//         #endif
+//     }
     
-    public async UniTask<bool> ShareAsync(ShareData shareData)
-    {
-        Debug.Log($"[DouyinPlatform] 鍒嗕韩: {shareData.Title}");
+//     public async UniTask<bool> ShareAsync(ShareData shareData)
+//     {
+//         Debug.Log($"[DouyinPlatform] 鍒嗕韩: {shareData.Title}");
         
-        #if UNITY_WEBGL && !UNITY_EDITOR
-        TT_ShareAppMessage(shareData.Title, shareData.ImageUrl);
-        #endif
+//         #if UNITY_WEBGL && !UNITY_EDITOR
+//         TT_ShareAppMessage(shareData.Title, shareData.ImageUrl);
+//         #endif
         
-        await UniTask.Delay(300);
-        return true;
-    }
+//         await UniTask.Delay(300);
+//         return true;
+//     }
     
-    public async UniTask<AdResult> ShowAdAsync(AdType adType)
-    {
-        Debug.Log($"[DouyinPlatform] 鏄剧ず骞垮憡: {adType}");
+//     public async UniTask<AdResult> ShowAdAsync(AdType adType)
+//     {
+//         Debug.Log($"[DouyinPlatform] 鏄剧ず骞垮憡: {adType}");
         
-        #if UNITY_WEBGL && !UNITY_EDITOR
-        // TODO: 瀹炵幇鎶栭煶骞垮憡閫昏緫
-        #endif
+//         #if UNITY_WEBGL && !UNITY_EDITOR
+//         // TODO: 瀹炵幇鎶栭煶骞垮憡閫昏緫
+//         #endif
         
-        await UniTask.Delay(1000);
-        return new AdResult { Success = true, Completed = true };
-    }
+//         await UniTask.Delay(1000);
+//         return new AdResult { Success = true, Completed = true };
+//     }
     
-    public async UniTask<bool> SaveDataAsync(string key, string value)
-    {
-        #if UNITY_WEBGL && !UNITY_EDITOR
-        TT_SetStorageSync(key, value);
-        #endif
-        await UniTask.Yield();
-        return true;
-    }
+//     public async UniTask<bool> SaveDataAsync(string key, string value)
+//     {
+//         #if UNITY_WEBGL && !UNITY_EDITOR
+//         TT_SetStorageSync(key, value);
+//         #endif
+//         await UniTask.Yield();
+//         return true;
+//     }
     
-    public async UniTask<string> LoadDataAsync(string key)
-    {
-        #if UNITY_WEBGL && !UNITY_EDITOR
-        string value = TT_GetStorageSync(key);
-        await UniTask.Yield();
-        return value;
-        #else
-        await UniTask.Yield();
-        return null;
-        #endif
-    }
+//     public async UniTask<string> LoadDataAsync(string key)
+//     {
+//         #if UNITY_WEBGL && !UNITY_EDITOR
+//         string value = TT_GetStorageSync(key);
+//         await UniTask.Yield();
+//         return value;
+//         #else
+//         await UniTask.Yield();
+//         return null;
+//         #endif
+//     }
     
-    public async UniTask<string> DownloadFileAsync(string url, string localPath, Action<float> onProgress = null)
-    {
-        Debug.Log($"[DouyinPlatform] 涓嬭浇鏂囦欢: {url}");
-        await UniTask.Delay(500);
-        return localPath;
-    }
+//     public async UniTask<string> DownloadFileAsync(string url, string localPath, Action<float> onProgress = null)
+//     {
+//         Debug.Log($"[DouyinPlatform] 涓嬭浇鏂囦欢: {url}");
+//         await UniTask.Delay(500);
+//         return localPath;
+//     }
     
-    public SystemInfo GetSystemInfo()
-    {
-        if (_cachedSystemInfo != null)
-            return _cachedSystemInfo;
+//     public SystemInfo GetSystemInfo()
+//     {
+//         if (_cachedSystemInfo != null)
+//             return _cachedSystemInfo;
         
-        #if UNITY_WEBGL && !UNITY_EDITOR
-        try
-        {
-            string jsonInfo = TT_GetSystemInfo();
-            _cachedSystemInfo = JsonUtility.FromJson<SystemInfo>(jsonInfo);
-            return _cachedSystemInfo;
-        }
-        catch (Exception e)
-        {
-            Debug.LogError($"[DouyinPlatform] 鑾峰彇绯荤粺淇℃伅澶辫触: {e.Message}");
-            return CreateMockSystemInfo();
-        }
-        #else
-        return CreateMockSystemInfo();
-        #endif
-    }
+//         #if UNITY_WEBGL && !UNITY_EDITOR
+//         try
+//         {
+//             string jsonInfo = TT_GetSystemInfo();
+//             _cachedSystemInfo = JsonUtility.FromJson<SystemInfo>(jsonInfo);
+//             return _cachedSystemInfo;
+//         }
+//         catch (Exception e)
+//         {
+//             Debug.LogError($"[DouyinPlatform] 鑾峰彇绯荤粺淇℃伅澶辫触: {e.Message}");
+//             return CreateMockSystemInfo();
+//         }
+//         #else
+//         return CreateMockSystemInfo();
+//         #endif
+//     }
     
-    public void Vibrate(VibrationType vibrationType)
-    {
-        #if UNITY_WEBGL && !UNITY_EDITOR
-        switch (vibrationType)
-        {
-            case VibrationType.Light:
-            case VibrationType.Medium:
-                TT_VibrateShort();
-                break;
-            case VibrationType.Heavy:
-                TT_VibrateLong();
-                break;
-        }
-        #endif
-    }
+//     public void Vibrate(VibrationType vibrationType)
+//     {
+//         #if UNITY_WEBGL && !UNITY_EDITOR
+//         switch (vibrationType)
+//         {
+//             case VibrationType.Light:
+//             case VibrationType.Medium:
+//                 TT_VibrateShort();
+//                 break;
+//             case VibrationType.Heavy:
+//                 TT_VibrateLong();
+//                 break;
+//         }
+//         #endif
+//     }
     
-    private SystemInfo CreateMockSystemInfo()
-    {
-        return new SystemInfo
-        {
-            DeviceModel = UnityEngine.SystemInfo.deviceModel,
-            PlatformVersion = "Douyin 1.0.0",
-            ScreenWidth = Screen.width,
-            ScreenHeight = Screen.height,
-            SafeArea = SafeAreaData.FromRect(Screen.safeArea),
-            PixelRatio = Screen.dpi / 160f
-        };
-    }
-}
+//     private SystemInfo CreateMockSystemInfo()
+//     {
+//         return new SystemInfo
+//         {
+//             DeviceModel = UnityEngine.SystemInfo.deviceModel,
+//             PlatformVersion = "Douyin 1.0.0",
+//             ScreenWidth = Screen.width,
+//             ScreenHeight = Screen.height,
+//             SafeArea = SafeAreaData.FromRect(Screen.safeArea),
+//             PixelRatio = Screen.dpi / 160f
+//         };
+//     }
+// }

--
Gitblit v1.8.0