From 77a24fd883295e5c5bb5f72badceaaab598faa9b Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期二, 12 五月 2026 10:35:09 +0800
Subject: [PATCH] 漏提交部分
---
Assets/Launch/Config/UrlRemoteServices.cs | 68 +++++++++++++++++
Assets/Launch/Config/WebGLRemoteConfig.cs | 98 ++++++++++++++++++++++++
Assets/HybridCLRDlls.meta | 8 ++
Assets/Launch/Config/WebGLRemoteConfig.cs.meta | 11 ++
Assets/Launch/Config/UrlRemoteServices.cs.meta | 11 ++
5 files changed, 196 insertions(+), 0 deletions(-)
diff --git a/Assets/HybridCLRDlls.meta b/Assets/HybridCLRDlls.meta
new file mode 100644
index 0000000..2aa71af
--- /dev/null
+++ b/Assets/HybridCLRDlls.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: abc904664683ec645829ea85e356b657
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Launch/Config/UrlRemoteServices.cs b/Assets/Launch/Config/UrlRemoteServices.cs
new file mode 100644
index 0000000..d00b637
--- /dev/null
+++ b/Assets/Launch/Config/UrlRemoteServices.cs
@@ -0,0 +1,68 @@
+using System;
+using UnityEngine;
+using YooAsset;
+
+/// <summary>
+/// 閫氱敤鐨勫熀浜� URL 鐨勮繙绋嬭祫婧愭湇鍔°��
+/// 鐢ㄤ簬闈� WebGL 姝e紡鍖呯殑 HostPlayMode锛屼粠鐗堟湰鏈嶅姟鍣ㄨ繑鍥炵殑 resource_url 鏋勫缓銆�
+/// </summary>
+public class UrlRemoteServices : IRemoteServices
+{
+ private readonly string _mainUrl;
+ private readonly string _fallbackUrl;
+
+#if UNITY_WEBGL || TEST_BUILD
+ private const int MaxLoggedUrlCount = 120;
+ private static int _loggedUrlCount;
+#endif
+
+ public UrlRemoteServices(string baseUrl) : this(baseUrl, baseUrl) { }
+
+ public UrlRemoteServices(string mainUrl, string fallbackUrl)
+ {
+ _mainUrl = mainUrl.TrimEnd('/');
+ _fallbackUrl = fallbackUrl.TrimEnd('/');
+ }
+
+ public string GetRemoteMainURL(string fileName)
+ {
+ var url = $"{_mainUrl}/{fileName}";
+#if UNITY_WEBGL || TEST_BUILD
+ LogRemoteUrl("main", fileName, url);
+#endif
+ return url;
+ }
+
+ public string GetRemoteFallbackURL(string fileName)
+ {
+ var url = $"{_fallbackUrl}/{fileName}";
+#if UNITY_WEBGL || TEST_BUILD
+ if (!string.Equals(_mainUrl, _fallbackUrl, StringComparison.OrdinalIgnoreCase))
+ LogRemoteUrl("fallback", fileName, url);
+#endif
+ return url;
+ }
+
+#if UNITY_WEBGL || TEST_BUILD
+ private static void LogRemoteUrl(string source, string fileName, string url)
+ {
+ if (_loggedUrlCount >= MaxLoggedUrlCount)
+ return;
+
+ if (!ShouldLog(fileName))
+ return;
+
+ _loggedUrlCount++;
+ Debug.Log($"[UrlRemoteServices][Diag] {source} file='{fileName}' url='{url}'");
+ }
+
+ private static bool ShouldLog(string fileName)
+ {
+ return fileName.EndsWith(".version", StringComparison.OrdinalIgnoreCase)
+ || fileName.EndsWith(".hash", StringComparison.OrdinalIgnoreCase)
+ || fileName.EndsWith(".bytes", StringComparison.OrdinalIgnoreCase)
+ || fileName.EndsWith(".bundle", StringComparison.OrdinalIgnoreCase)
+ || fileName.EndsWith(".rawfile", StringComparison.OrdinalIgnoreCase);
+ }
+#endif
+}
diff --git a/Assets/Launch/Config/UrlRemoteServices.cs.meta b/Assets/Launch/Config/UrlRemoteServices.cs.meta
new file mode 100644
index 0000000..d598be8
--- /dev/null
+++ b/Assets/Launch/Config/UrlRemoteServices.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: e2f5bbf079899b14a835dc61f75ca2a9
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Launch/Config/WebGLRemoteConfig.cs b/Assets/Launch/Config/WebGLRemoteConfig.cs
new file mode 100644
index 0000000..d544cbc
--- /dev/null
+++ b/Assets/Launch/Config/WebGLRemoteConfig.cs
@@ -0,0 +1,98 @@
+// ============================================================================
+// WebGLRemoteConfig.cs 鈥� WebGL 杩滅▼璧勬簮鍔犺浇閰嶇疆
+// 缁熶竴閰嶇疆锛欵ditor 鍜屾瀯寤轰骇鐗╀娇鐢ㄥ悓涓�濂楀彉閲忥紝鏀硅繖閲屽氨鏄敼鎵�鏈夌幆澧冪殑琛屼负銆�
+// ============================================================================
+
+using UnityEngine;
+using YooAsset;
+
+public static class WebGLRemoteConfig
+{
+ // ====================================================================
+ // 鈽呪槄鈽� 缁熶竴閰嶇疆 鈥� Editor 鍜屾瀯寤轰骇鐗╅兘璇昏繖閲岋紝鏀瑰畬閲嶆柊缂栬瘧/鏋勫缓鍗冲彲 鈽呪槄鈽�
+ // ====================================================================
+
+ /// <summary>
+ /// 璧勬簮鍔犺浇妯″紡锛堝叏鐜缁熶竴锛夈��
+ /// Local = 璧勬簮闅忓寘锛屼粠 StreamingAssets 鍔犺浇
+ /// LocalCDN = 璧勬簮涓嶉殢鍖咃紝浠庢湰鍦� HTTP 鏈嶅姟鍣ㄥ姞杞斤紙寮�鍙戣皟璇曪級
+ /// RemoteCDN = 璧勬簮涓嶉殢鍖咃紝浠庤繙绋� CDN 鍔犺浇锛堢敓浜х幆澧冿級
+ /// </summary>
+ public static readonly ResourceMode CurrentMode = ResourceMode.RemoteCDN;
+
+ /// <summary>
+ /// LocalCDN 妯″紡涓嬬殑 HTTP 鏈嶅姟鍣ㄥ湴鍧�锛堟湰鍦扮鐩樺惎 HTTP 鏈嶅姟鍣級銆�
+ /// </summary>
+ public static readonly string LocalCDNServerURL = "http://localhost:9095";
+
+ /// <summary>
+ /// RemoteCDN 妯″紡涓嬬殑涓� CDN 鍦板潃銆�
+ /// </summary>
+ public static readonly string RemoteMainURL = "https://cdn.example.com/bundles/WebGL";
+
+ /// <summary>
+ /// RemoteCDN 妯″紡涓嬬殑澶囩敤 CDN 鍦板潃锛堢暀绌哄垯涓庝富鍦板潃鐩稿悓锛夈��
+ /// </summary>
+ public static readonly string RemoteFallbackURL = "";
+
+ /// <summary>
+ /// 鏈湴 CDN 鐨勭鐩樿矾寰勶紙浠呯敤浜� Editor 宸ュ叿鐢熸垚 CDN 鐩綍鏃剁殑榛樿璺緞锛夈��
+ /// </summary>
+ public static readonly string LocalCDNPath = @"D:\LocalCDN";
+
+ // ====================================================================
+ // 璧勬簮妯″紡鏋氫妇
+ // ====================================================================
+
+ public enum ResourceMode
+ {
+ Local,
+ LocalCDN,
+ RemoteCDN,
+ }
+
+ // ====================================================================
+ // 渚挎嵎灞炴��
+ // ====================================================================
+
+ public static bool EnableRemoteMode => CurrentMode != ResourceMode.Local;
+
+ public static string ActiveServerURL
+ {
+ get
+ {
+ switch (CurrentMode)
+ {
+ case ResourceMode.LocalCDN: return LocalCDNServerURL;
+ case ResourceMode.RemoteCDN: return RemoteMainURL;
+ default: return "";
+ }
+ }
+ }
+
+ // ====================================================================
+ // IRemoteServices 鍒涘缓
+ // ====================================================================
+
+ public static IRemoteServices CreateRemoteServices()
+ {
+ if (CurrentMode == ResourceMode.Local)
+ return null;
+
+ string mainUrl = ActiveServerURL;
+ if (string.IsNullOrEmpty(mainUrl))
+ {
+ Debug.LogWarning($"[WebGLRemoteConfig] 妯″紡={CurrentMode} 浣嗘湇鍔″櫒鍦板潃涓虹┖锛屽洖閫�鍒� Local 妯″紡");
+ return null;
+ }
+
+ string fallbackUrl;
+ if (CurrentMode == ResourceMode.RemoteCDN && !string.IsNullOrEmpty(RemoteFallbackURL))
+ fallbackUrl = RemoteFallbackURL;
+ else
+ fallbackUrl = mainUrl;
+
+ Debug.Log($"[WebGLRemoteConfig] 妯″紡={CurrentMode}, MainURL={mainUrl}, FallbackURL={fallbackUrl}");
+ return new UrlRemoteServices(mainUrl, fallbackUrl);
+ }
+}
diff --git a/Assets/Launch/Config/WebGLRemoteConfig.cs.meta b/Assets/Launch/Config/WebGLRemoteConfig.cs.meta
new file mode 100644
index 0000000..5c29869
--- /dev/null
+++ b/Assets/Launch/Config/WebGLRemoteConfig.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 42942d325df0d1141a646ecea2a93e63
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
--
Gitblit v1.8.0