From 8dc0560537bb776d4bc49129805bde03b9887c4b Mon Sep 17 00:00:00 2001 From: hevinci Date: Fri, 13 May 2022 23:53:19 +0800 Subject: [PATCH] Optimized the loading method of the setting file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化了配置文件的加载方式和途径。 --- .../AssetBundleBuilderSettingData.cs | 17 +--- .../AssetBundleBuilderWindow.cs | 24 +++-- .../AssetBundleCollectorSettingData.cs | 17 +--- .../AssetBundleCollectorWindow.cs | 24 +++-- .../AssetBundleDebuggerWindow.cs | 84 +++++++++-------- ...erViewer.cs => DebuggerAssetListViewer.cs} | 10 +- ...s.meta => DebuggerAssetListViewer.cs.meta} | 0 ...ewer.uxml => DebuggerAssetListViewer.uxml} | 0 ...meta => DebuggerAssetListViewer.uxml.meta} | 0 ...rViewer.cs => DebuggerBundleListViewer.cs} | 8 +- ....meta => DebuggerBundleListViewer.cs.meta} | 0 ...wer.uxml => DebuggerBundleListViewer.uxml} | 0 ...eta => DebuggerBundleListViewer.uxml.meta} | 0 .../AssetBundleReporterWindow.cs | 94 ++++++++++--------- ...erViewer.cs => ReporterAssetListViewer.cs} | 8 +- ...s.meta => ReporterAssetListViewer.cs.meta} | 0 ...ewer.uxml => ReporterAssetListViewer.uxml} | 0 ...meta => ReporterAssetListViewer.uxml.meta} | 0 ...rViewer.cs => ReporterBundleListViewer.cs} | 8 +- ....meta => ReporterBundleListViewer.cs.meta} | 0 ...wer.uxml => ReporterBundleListViewer.uxml} | 0 ...eta => ReporterBundleListViewer.uxml.meta} | 0 ...rterViewer.cs => ReporterSummaryViewer.cs} | 8 +- ....cs.meta => ReporterSummaryViewer.cs.meta} | 0 ...Viewer.uxml => ReporterSummaryViewer.uxml} | 0 ...l.meta => ReporterSummaryViewer.uxml.meta} | 0 Assets/YooAsset/Editor/EditorExtension.cs | 2 + Assets/YooAsset/Editor/EditorTools.cs | 81 ---------------- .../ShaderVariantCollectorSettingData.cs | 17 +--- .../Editor/YooAssetEditorSettings.asset | 32 +++++++ .../Editor/YooAssetEditorSettings.asset.meta | 8 ++ .../YooAsset/Editor/YooAssetEditorSettings.cs | 25 +++++ .../Editor/YooAssetEditorSettings.cs.meta | 11 +++ .../Editor/YooAssetEditorSettingsData.cs | 35 +++++++ .../Editor/YooAssetEditorSettingsData.cs.meta | 11 +++ .../Editor/YooAssetEditorSettingsHelper.cs | 36 +++++++ .../YooAssetEditorSettingsHelper.cs.meta | 11 +++ .../Runtime/Settings/YooAssetSettingsData.cs | 2 +- 38 files changed, 308 insertions(+), 265 deletions(-) rename Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/{AssetListDebuggerViewer.cs => DebuggerAssetListViewer.cs} (94%) rename Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/{AssetListDebuggerViewer.cs.meta => DebuggerAssetListViewer.cs.meta} (100%) rename Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/{AssetListDebuggerViewer.uxml => DebuggerAssetListViewer.uxml} (100%) rename Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/{AssetListDebuggerViewer.uxml.meta => DebuggerAssetListViewer.uxml.meta} (100%) rename Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/{BundleListDebuggerViewer.cs => DebuggerBundleListViewer.cs} (94%) rename Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/{BundleListDebuggerViewer.cs.meta => DebuggerBundleListViewer.cs.meta} (100%) rename Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/{BundleListDebuggerViewer.uxml => DebuggerBundleListViewer.uxml} (100%) rename Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/{BundleListDebuggerViewer.uxml.meta => DebuggerBundleListViewer.uxml.meta} (100%) rename Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/{AssetListReporterViewer.cs => ReporterAssetListViewer.cs} (95%) rename Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/{AssetListReporterViewer.cs.meta => ReporterAssetListViewer.cs.meta} (100%) rename Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/{AssetListReporterViewer.uxml => ReporterAssetListViewer.uxml} (100%) rename Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/{AssetListReporterViewer.uxml.meta => ReporterAssetListViewer.uxml.meta} (100%) rename Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/{BundleListReporterViewer.cs => ReporterBundleListViewer.cs} (96%) rename Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/{BundleListReporterViewer.cs.meta => ReporterBundleListViewer.cs.meta} (100%) rename Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/{BundleListReporterViewer.uxml => ReporterBundleListViewer.uxml} (100%) rename Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/{BundleListReporterViewer.uxml.meta => ReporterBundleListViewer.uxml.meta} (100%) rename Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/{SummaryReporterViewer.cs => ReporterSummaryViewer.cs} (93%) rename Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/{SummaryReporterViewer.cs.meta => ReporterSummaryViewer.cs.meta} (100%) rename Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/{SummaryReporterViewer.uxml => ReporterSummaryViewer.uxml} (100%) rename Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/{SummaryReporterViewer.uxml.meta => ReporterSummaryViewer.uxml.meta} (100%) create mode 100644 Assets/YooAsset/Editor/YooAssetEditorSettings.asset create mode 100644 Assets/YooAsset/Editor/YooAssetEditorSettings.asset.meta create mode 100644 Assets/YooAsset/Editor/YooAssetEditorSettings.cs create mode 100644 Assets/YooAsset/Editor/YooAssetEditorSettings.cs.meta create mode 100644 Assets/YooAsset/Editor/YooAssetEditorSettingsData.cs create mode 100644 Assets/YooAsset/Editor/YooAssetEditorSettingsData.cs.meta create mode 100644 Assets/YooAsset/Editor/YooAssetEditorSettingsHelper.cs create mode 100644 Assets/YooAsset/Editor/YooAssetEditorSettingsHelper.cs.meta diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSettingData.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSettingData.cs index b1ca04c..4e20257 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSettingData.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSettingData.cs @@ -24,22 +24,7 @@ namespace YooAsset.Editor /// private static void LoadSettingData() { - // 加载配置文件 - string settingFilePath = $"{EditorTools.GetYooAssetSettingPath()}/{nameof(AssetBundleBuilderSetting)}.asset"; - _setting = AssetDatabase.LoadAssetAtPath(settingFilePath); - if (_setting == null) - { - Debug.LogWarning($"Create new {nameof(AssetBundleBuilderSetting)}.asset : {settingFilePath}"); - _setting = ScriptableObject.CreateInstance(); - EditorTools.CreateFileDirectory(settingFilePath); - AssetDatabase.CreateAsset(Setting, settingFilePath); - AssetDatabase.SaveAssets(); - AssetDatabase.Refresh(); - } - else - { - Debug.Log($"Load {nameof(AssetBundleBuilderSetting)}.asset ok"); - } + _setting = YooAssetEditorSettingsHelper.LoadSettingData(); } /// diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs index a8fe46e..eade0ec 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs @@ -32,21 +32,19 @@ namespace YooAsset.Editor public void CreateGUI() { - VisualElement root = this.rootVisualElement; - - // 加载布局文件 - string rootPath = EditorTools.GetYooAssetSourcePath(); - string uxml = $"{rootPath}/Editor/AssetBundleBuilder/{nameof(AssetBundleBuilderWindow)}.uxml"; - var visualAsset = AssetDatabase.LoadAssetAtPath(uxml); - if (visualAsset == null) - { - Debug.LogError($"Not found {nameof(AssetBundleBuilderWindow)}.uxml : {uxml}"); - return; - } - visualAsset.CloneTree(root); - try { + VisualElement root = this.rootVisualElement; + + // 加载布局文件 + var visualAsset = YooAssetEditorSettingsData.Setting.AssetBundleBuilderUXML; + if (visualAsset == null) + { + Debug.LogError($"Not found {nameof(AssetBundleBuilderWindow)}.uxml in settings."); + return; + } + visualAsset.CloneTree(root); + _buildTarget = EditorUserBuildSettings.activeBuildTarget; _encryptionServicesClassTypes = GetEncryptionServicesClassTypes(); _encryptionServicesClassNames = _encryptionServicesClassTypes.Select(t => t.FullName).ToList(); diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs index 96ecea2..26c664a 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs @@ -105,22 +105,7 @@ namespace YooAsset.Editor /// private static void LoadSettingData() { - // 加载配置文件 - string settingFilePath = $"{EditorTools.GetYooAssetSettingPath()}/{nameof(AssetBundleCollectorSetting)}.asset"; - _setting = AssetDatabase.LoadAssetAtPath(settingFilePath); - if (_setting == null) - { - Debug.LogWarning($"Create new {nameof(AssetBundleCollectorSetting)}.asset : {settingFilePath}"); - _setting = ScriptableObject.CreateInstance(); - EditorTools.CreateFileDirectory(settingFilePath); - AssetDatabase.CreateAsset(Setting, settingFilePath); - AssetDatabase.SaveAssets(); - AssetDatabase.Refresh(); - } - else - { - Debug.Log($"Load {nameof(AssetBundleCollectorSetting)}.asset ok"); - } + _setting = YooAssetEditorSettingsHelper.LoadSettingData(); // IPackRule { diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs index b7afdba..b379771 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs @@ -37,8 +37,6 @@ namespace YooAsset.Editor Undo.undoRedoPerformed -= RefreshWindow; Undo.undoRedoPerformed += RefreshWindow; - VisualElement root = this.rootVisualElement; - _collectorTypeList = new List() { $"{nameof(ECollectorType.MainAssetCollector)}", @@ -49,19 +47,19 @@ namespace YooAsset.Editor _packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames(); _filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames(); - // 加载布局文件 - string rootPath = EditorTools.GetYooAssetSourcePath(); - string uxml = $"{rootPath}/Editor/AssetBundleCollector/{nameof(AssetBundleCollectorWindow)}.uxml"; - var visualAsset = AssetDatabase.LoadAssetAtPath(uxml); - if (visualAsset == null) - { - Debug.LogError($"Not found {nameof(AssetBundleCollectorWindow)}.uxml : {uxml}"); - return; - } - visualAsset.CloneTree(root); - try { + VisualElement root = this.rootVisualElement; + + // 加载布局文件 + var visualAsset = YooAssetEditorSettingsData.Setting.AssetBundleCollectorUXML; + if (visualAsset == null) + { + Debug.LogError($"Not found {nameof(AssetBundleCollectorWindow)}.uxml in settings."); + return; + } + visualAsset.CloneTree(root); + // 导入导出按钮 var exportBtn = root.Q