diff --git a/Assets/VersionFlow/Editor/BuilderConfigEditor.cs b/Assets/VersionFlow/Editor/BuilderConfigEditor.cs index 43d33b7..72af93e 100644 --- a/Assets/VersionFlow/Editor/BuilderConfigEditor.cs +++ b/Assets/VersionFlow/Editor/BuilderConfigEditor.cs @@ -86,6 +86,7 @@ namespace VersionFlow.Editors } } + Dictionary m_uploaderEditorMapper = new Dictionary(); private void DrawUploader() { var builder = target as BuilderConfig; @@ -107,15 +108,21 @@ namespace VersionFlow.Editors var patchLoader = builder.GetPatchLoader(); if (patchLoader != null) { - Editor.CreateEditor(patchLoader).OnInspectorGUI(); + if (!m_uploaderEditorMapper.TryGetValue(patchLoader, out Editor editor)) + { + editor = Editor.CreateEditor(patchLoader); + m_uploaderEditorMapper[patchLoader] = editor; + } + editor.OnInspectorGUI(); + string json = patchLoader.GetCfgJson(); - builder.uploaderCfgJson = json; + builder.UploaderCfgDict.SetCfgJson(patchLoader.GetType(), json); } if (GUI.changed) { EditorUtility.SetDirty(target); - patchLoader.CfgChanged(builder, builder.uploaderCfgJson); + patchLoader.CfgChanged(builder, builder.UploaderCfgDict.GetUploaderCfg(patchLoader.GetType())); } } diff --git a/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderUtility.cs b/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderUtility.cs index 95ee6ea..bd9d428 100644 --- a/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderUtility.cs +++ b/Assets/VersionFlow/Editor/PatchUploader/PatchUploaderUtility.cs @@ -80,7 +80,7 @@ namespace VersionFlow.Editors else //创建patchloader实例 { var patchloaderInstance = ScriptableObject.CreateInstance(patchType) as PatchUploader; - patchloaderInstance.CfgChanged(builder, builder.uploaderCfgJson); + patchloaderInstance.CfgChanged(builder, builder.UploaderCfgDict.GetUploaderCfg(patchType)); s_patchInstance[builder] = patchloaderInstance; return patchloaderInstance; } diff --git a/Assets/VersionFlow/Runtime/BuilderConfig.cs b/Assets/VersionFlow/Runtime/BuilderConfig.cs index 71dd48f..403adda 100644 --- a/Assets/VersionFlow/Runtime/BuilderConfig.cs +++ b/Assets/VersionFlow/Runtime/BuilderConfig.cs @@ -1,9 +1,11 @@ #if UNITY_EDITOR +using System; using System.Collections.Generic; using System.IO; using UnityEditor; using UnityEngine; using UnityEngine.UIElements; +using VersionFlow.Runtime.Builder; namespace VersionFlow.Runtime { @@ -26,7 +28,7 @@ namespace VersionFlow.Runtime internal string uploaderClassName; [SerializeField] [HideInInspector] - internal string uploaderCfgJson; + internal UploaderCfgDict UploaderCfgDict; public BuildAssetBundleOptions Options; [HideInInspector] @@ -224,6 +226,21 @@ namespace VersionFlow.Runtime } } + [Serializable] + public class UploaderCfgDict : SerializableDictionary + { + public string GetUploaderCfg(Type uploaderCfg) + { + TryGetValue(uploaderCfg.FullName, out var json); + return json; + } + + public void SetCfgJson(Type type, string json) + { + this[type.FullName] = json; + } + } + public class BundleExtraInfo { public string BundleName { get; internal set; }