上传器配置现在切换上传器类型后,也不会丢失配置

This commit is contained in:
ALIENJACK\alien 2025-08-22 11:53:49 +08:00
parent e8c9abd219
commit d165b75f02
3 changed files with 29 additions and 5 deletions

View File

@ -86,6 +86,7 @@ namespace VersionFlow.Editors
} }
} }
Dictionary<PatchUploader, Editor> m_uploaderEditorMapper = new Dictionary<PatchUploader, Editor>();
private void DrawUploader() private void DrawUploader()
{ {
var builder = target as BuilderConfig; var builder = target as BuilderConfig;
@ -107,15 +108,21 @@ namespace VersionFlow.Editors
var patchLoader = builder.GetPatchLoader(); var patchLoader = builder.GetPatchLoader();
if (patchLoader != null) 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(); string json = patchLoader.GetCfgJson();
builder.uploaderCfgJson = json; builder.UploaderCfgDict.SetCfgJson(patchLoader.GetType(), json);
} }
if (GUI.changed) if (GUI.changed)
{ {
EditorUtility.SetDirty(target); EditorUtility.SetDirty(target);
patchLoader.CfgChanged(builder, builder.uploaderCfgJson); patchLoader.CfgChanged(builder, builder.UploaderCfgDict.GetUploaderCfg(patchLoader.GetType()));
} }
} }

View File

@ -80,7 +80,7 @@ namespace VersionFlow.Editors
else //创建patchloader实例 else //创建patchloader实例
{ {
var patchloaderInstance = ScriptableObject.CreateInstance(patchType) as PatchUploader; var patchloaderInstance = ScriptableObject.CreateInstance(patchType) as PatchUploader;
patchloaderInstance.CfgChanged(builder, builder.uploaderCfgJson); patchloaderInstance.CfgChanged(builder, builder.UploaderCfgDict.GetUploaderCfg(patchType));
s_patchInstance[builder] = patchloaderInstance; s_patchInstance[builder] = patchloaderInstance;
return patchloaderInstance; return patchloaderInstance;
} }

View File

@ -1,9 +1,11 @@
#if UNITY_EDITOR #if UNITY_EDITOR
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using UnityEngine.UIElements; using UnityEngine.UIElements;
using VersionFlow.Runtime.Builder;
namespace VersionFlow.Runtime namespace VersionFlow.Runtime
{ {
@ -26,7 +28,7 @@ namespace VersionFlow.Runtime
internal string uploaderClassName; internal string uploaderClassName;
[SerializeField] [SerializeField]
[HideInInspector] [HideInInspector]
internal string uploaderCfgJson; internal UploaderCfgDict UploaderCfgDict;
public BuildAssetBundleOptions Options; public BuildAssetBundleOptions Options;
[HideInInspector] [HideInInspector]
@ -224,6 +226,21 @@ namespace VersionFlow.Runtime
} }
} }
[Serializable]
public class UploaderCfgDict : SerializableDictionary<string, string>
{
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 class BundleExtraInfo
{ {
public string BundleName { get; internal set; } public string BundleName { get; internal set; }