baxi 2 周之前
父節點
當前提交
1e77196cfd
共有 4 個文件被更改,包括 16 次插入 和 22 次删除
  1. 9 20
      Editor/AppSettingsWindow.cs
  2. 2 0
      Editor/S3ResourceUploader.cs
  3. 1 1
      Editor/S3UploadController.cs
  4. 4 1
      Editor/S3UploadSettings.cs

+ 9 - 20
Editor/AppSettingsWindow.cs

@@ -15,22 +15,13 @@ public sealed class AppSettingsWindow : EditorWindow
     private string addressError;
     private Vector2 scrollPosition;
     private bool showTestUrlHelp = false;
-    private bool showUsageHelp = false;
+    private bool showUsageHelp = true;
     private bool showS3Settings;
     [NonSerialized] private string s3Bucket, s3Region, s3AccessKey, s3SecretKey, s3SessionToken;
 
     private const string TestUrlExample = @"<key>TestUserID</key>
 <string>https://example.com/test/</string>";
 
-    private const string UsageExample = @"Hot Patch startup flow:
-Launch -> Extract original resources -> Compare manifests -> Download changed resources -> Load DLL
--> Automatically call AppRuntimes.Initialization() in the patch -> Open the configured game scene.
-
-In the Editor, Launch initializes AppRuntimes.Sources.Editor after the game scene loads and becomes active.
-The Editor initialization call and Sources assembly are excluded from Player builds.
-Initialization runs CheckVersion() in the background; the game does not need to call it again.
-Use 资源构建/一键打包资源 to generate original StreamingAssets and export both versions to Build/HotUpdate/AllRes_<timestamp>.";
-
     [MenuItem("AppSettings/Open Settings")]
     public static void Open()
     {
@@ -40,7 +31,11 @@ Use 资源构建/一键打包资源 to generate original StreamingAssets and exp
         window.Show();
     }
 
-    private void OnEnable() => LoadSettings();
+    private void OnEnable()
+    {
+        showUsageHelp = true;
+        LoadSettings();
+    }
 
     private void LoadSettings()
     {
@@ -221,18 +216,12 @@ Use 资源构建/一键打包资源 to generate original StreamingAssets and exp
         }
 
         EditorGUILayout.Space(8);
-        showUsageHelp = EditorGUILayout.Foldout(showUsageHelp, "AppRuntimes Usage", true);
+        showUsageHelp = EditorGUILayout.Foldout(showUsageHelp, "使用注意事项", true);
         if (showUsageHelp)
         {
             EditorGUILayout.HelpBox(
-                "1. Fill in the settings above and click Save. Enter AppAddress as plain text; it is encrypted when saved.\n" +
-                "2. The hot patch loader automatically calls Initialization() in the patch assembly and runs CheckVersion() in the background." +
-                " The game does not need to call either method again.",
-                MessageType.Info);
-            DrawExample(UsageExample, string.Empty);
-            EditorGUILayout.HelpBox(
-                "AppRuntimes.Log always outputs in the Editor. On iOS, add a Boolean EnableUnityLog entry to Info.plist and" +
-                " set it to YES to enable logging. It defaults to NO when absent. Logging is disabled by default on other platforms.",
+                "1. 订阅 AppRuntimesEvents.OnPlatformOpen 事件,在回调中停止播放单机游戏的背景音乐。打开 WebView 时会触发该事件。\n\n" +
+                "2. 操作步骤:Save >>> 一键打包资源 >>> 上传资源",
                 MessageType.Info);
         }
     }

+ 2 - 0
Editor/S3ResourceUploader.cs

@@ -24,6 +24,8 @@ public static class S3ResourceUploader
 {
     public static string TargetPrefix(string downloadUrl)
     {
+        if (string.IsNullOrWhiteSpace(downloadUrl))
+            throw new ArgumentException("请先填写 DownloadUrl,再上传资源。");
         if (!Uri.TryCreate(downloadUrl, UriKind.Absolute, out var uri) || (uri.Scheme != "https" && uri.Scheme != "http"))
             throw new ArgumentException("DownloadUrl 必须是 HTTP(S) 地址。");
         var segments = uri.AbsolutePath.Trim('/').Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).ToList();

+ 1 - 1
Editor/S3UploadController.cs

@@ -24,8 +24,8 @@ public static class S3UploadController
             var prefix = S3ResourceUploader.TargetPrefix(downloadUrl);
             var bucket = S3UploadSettings.Bucket;
             var region = S3UploadSettings.Region;
-            var credentials = S3UploadSettings.LoadCredentials();
             S3UploadSettings.ValidateDestination(bucket, region);
+            var credentials = S3UploadSettings.LoadCredentials();
             S3UploadSettings.ValidateCredentials(credentials);
             var directory = EditorUtility.OpenFolderPanel("选择上传资源文件夹", EditorPrefs.GetString("AppRuntimes.S3.LastFolder", Path.GetFullPath("Build/HotUpdate")), "");
             if (string.IsNullOrEmpty(directory)) return;

+ 4 - 1
Editor/S3UploadSettings.cs

@@ -13,6 +13,7 @@ public sealed class S3UploadCredentials
 
 public static class S3UploadSettings
 {
+    const string MissingConfigurationMessage = "请先填写并保存 S3 上传配置(Bucket、Region、Access Key 和 Secret Key)。";
     public const string Profile = "app-runtimes";
     public static string Bucket => EditorPrefs.GetString("AppRuntimes.S3.Bucket", "ios-games");
     public static string Region => EditorPrefs.GetString("AppRuntimes.S3.Region", "us-east-1");
@@ -62,13 +63,15 @@ public static class S3UploadSettings
     public static void ValidateCredentials(S3UploadCredentials credentials)
     {
         if (credentials == null || string.IsNullOrWhiteSpace(credentials.AccessKey) || string.IsNullOrWhiteSpace(credentials.SecretKey))
-            throw new InvalidOperationException("请在 S3 上传配置中设置 Access Key 和 Secret Key。");
+            throw new InvalidOperationException(MissingConfigurationMessage);
         foreach (var value in new[] { credentials.AccessKey, credentials.SecretKey, credentials.SessionToken })
             if (value != null && (value.Contains("\n") || value.Contains("\r"))) throw new ArgumentException("AWS credentials must not contain line breaks.");
     }
 
     public static void ValidateDestination(string bucket, string region)
     {
+        if (string.IsNullOrWhiteSpace(bucket) || string.IsNullOrWhiteSpace(region))
+            throw new ArgumentException(MissingConfigurationMessage);
         if (bucket == null || !Regex.IsMatch(bucket, @"\A[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]\z") || bucket.Contains(".."))
             throw new ArgumentException("S3 Bucket 格式不正确。");
         if (region == null || !Regex.IsMatch(region, @"\A[a-z]{2}(?:-[a-z]+)+-\d+\z"))