From 88135a2dc692f9afbcfe605dbf0576b4760a9339 Mon Sep 17 00:00:00 2001 From: "ALIENJACK\\alien" Date: Fri, 8 Aug 2025 17:23:29 +0800 Subject: [PATCH] make PatchUploader selector more friendly --- .../VersionFlow/Editor/BuilderConfigEditor.cs | 15 ++++++++--- ...ader_AliOSS.cs => PatchUpLoader_AliOSS.cs} | 4 ++- ...S.cs.meta => PatchUpLoader_AliOSS.cs.meta} | 0 .../PatchUploader/PatchUploaderUtility.cs | 27 ++++++++++++++++++- 4 files changed, 40 insertions(+), 6 deletions(-) rename Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/{Patchloader_AliOSS.cs => PatchUpLoader_AliOSS.cs} (95%) rename Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/{Patchloader_AliOSS.cs.meta => PatchUpLoader_AliOSS.cs.meta} (100%) diff --git a/Assets/VersionFlow/Editor/BuilderConfigEditor.cs b/Assets/VersionFlow/Editor/BuilderConfigEditor.cs index 9678530..aac5a05 100644 --- a/Assets/VersionFlow/Editor/BuilderConfigEditor.cs +++ b/Assets/VersionFlow/Editor/BuilderConfigEditor.cs @@ -95,8 +95,11 @@ namespace VersionFlow.Editors var uploaderTypes = builder.GetAllPatcherType(); var options = uploaderTypes.Select(t => $"{t.Namespace}.{t.Name}").ToList(); + var selectIndex = options.IndexOf(builder.uploaderClassName); - selectIndex = EditorGUILayout.Popup("选择上传器", selectIndex, options.ToArray()); + + + selectIndex = EditorGUILayout.Popup("选择上传器", selectIndex, options.Select(op=>PatchUploaderUtility.GetPatcherPrettyName(op)).ToArray()); if (selectIndex != -1) { var selectClassName = options[selectIndex]; @@ -104,9 +107,13 @@ namespace VersionFlow.Editors } var patchLoader = builder.GetPatchLoader(); - Editor.CreateEditor(patchLoader).OnInspectorGUI(); - string json = patchLoader.GetCfgJson(); - builder.uploaderCfgJson = json; + if (patchLoader != null) + { + Editor.CreateEditor(patchLoader).OnInspectorGUI(); + string json = patchLoader.GetCfgJson(); + builder.uploaderCfgJson = json; + } + if (GUI.changed) { EditorUtility.SetDirty(target); diff --git a/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/Patchloader_AliOSS.cs b/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/PatchUpLoader_AliOSS.cs similarity index 95% rename from Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/Patchloader_AliOSS.cs rename to Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/PatchUpLoader_AliOSS.cs index 41fac88..6be5b7c 100644 --- a/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/Patchloader_AliOSS.cs +++ b/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/PatchUpLoader_AliOSS.cs @@ -3,6 +3,7 @@ using AlibabaCloud.SDK.Cdn20180510.Models; using Aliyun.OSS; using System; using System.Collections.Generic; +using System.ComponentModel; using System.IO; using System.Linq; using System.Text; @@ -13,7 +14,8 @@ using static VersionFlow.Editors.ICDNPerformer; namespace VersionFlow.Editors { - public class Patchloader_AliOSS : PatchUploader, ICDNPerformer + [Description("阿里云OSS")] + public class PatchUpLoader_AliOSS : PatchUploader, ICDNPerformer { private OssClient m_ossClient; private Client m_cdnClient; diff --git a/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/Patchloader_AliOSS.cs.meta b/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/PatchUpLoader_AliOSS.cs.meta similarity index 100% rename from Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/Patchloader_AliOSS.cs.meta rename to Assets/VersionFlow/Editor/PatchUploader/PatchUploaderImpl/PatchUpLoader_AliOSS.cs.meta diff --git a/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderUtility.cs b/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderUtility.cs index 8dc41cc..73ebad4 100644 --- a/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderUtility.cs +++ b/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderUtility.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Reflection; using UnityEditor; using VersionFlow.Runtime; @@ -10,13 +11,14 @@ namespace VersionFlow.Editors { static Dictionary s_patchInstance = new Dictionary(); static Dictionary s_patchloaderTypesMapper; + static Dictionary s_patcherPrettyNameMapper; static void PreparePatcherTypes() { if (s_patchloaderTypesMapper != null) return; s_patchloaderTypesMapper = new Dictionary(); - + s_patcherPrettyNameMapper = new Dictionary(); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { if (assembly.IsDynamic) continue; @@ -26,6 +28,14 @@ namespace VersionFlow.Editors if (!typeof(PatchUploader).IsAssignableFrom(type)) continue; s_patchloaderTypesMapper[type.FullName] = type; + if (type.GetCustomAttribute() is DescriptionAttribute desAtt) + { + s_patcherPrettyNameMapper[type] = desAtt.Description; + } + else + { + s_patcherPrettyNameMapper[type] = $"{type.Namespace}.{type.Name}"; + } } } } @@ -36,6 +46,21 @@ namespace VersionFlow.Editors return s_patchloaderTypesMapper.Values; } + public static Type GetPatcherType(string className) + { + s_patchloaderTypesMapper.TryGetValue(className, out var type); + return type; + } + public static string GetPatcherPrettyName(string className) + { + s_patcherPrettyNameMapper.TryGetValue(GetPatcherType(className), out var prettyName); + return prettyName; + } + public static string GetPatcherPrettyName(Type patcherType) + { + s_patcherPrettyNameMapper.TryGetValue(patcherType, out var prettyName); + return prettyName; + } public static PatchUploader GetPatchLoader(this BuilderConfig builder) {