diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSettingData.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSettingData.cs index 9412292..353931b 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSettingData.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSettingData.cs @@ -29,7 +29,7 @@ namespace YooAsset.Editor /// private static void LoadSettingData() { - _setting = EditorHelper.LoadSettingData(); + _setting = SettingLoader.LoadSettingData(); } /// diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs index d688887..9e4b8ea 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs @@ -14,7 +14,7 @@ namespace YooAsset.Editor [MenuItem("YooAsset/AssetBundle Builder", false, 102)] public static void ShowExample() { - AssetBundleBuilderWindow window = GetWindow("资源包构建工具", true, EditorDefine.DockedWindowTypes); + AssetBundleBuilderWindow window = GetWindow("资源包构建工具", true, WindowsDefine.DockedWindowTypes); window.minSize = new Vector2(800, 600); } @@ -42,7 +42,7 @@ namespace YooAsset.Editor VisualElement root = this.rootVisualElement; // 加载布局文件 - var visualAsset = EditorHelper.LoadWindowUXML(); + var visualAsset = UxmlLoader.LoadWindowUXML(); if (visualAsset == null) return; diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs index 40728c2..5152534 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSettingData.cs @@ -43,7 +43,7 @@ namespace YooAsset.Editor /// private static void LoadSettingData() { - _setting = EditorHelper.LoadSettingData(); + _setting = SettingLoader.LoadSettingData(); // IPackRule { @@ -244,7 +244,7 @@ namespace YooAsset.Editor } private static string GetRuleDisplayName(string name, Type type) { - var attribute = EditorAttribute.GetAttribute(type); + var attribute = DisplayNameAttributeHelper.GetAttribute(type); if (attribute != null && string.IsNullOrEmpty(attribute.DisplayName) == false) return attribute.DisplayName; else diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs index bbad609..094e9a8 100644 --- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs @@ -14,7 +14,7 @@ namespace YooAsset.Editor [MenuItem("YooAsset/AssetBundle Collector", false, 101)] public static void ShowExample() { - AssetBundleCollectorWindow window = GetWindow("资源包收集工具", true, EditorDefine.DockedWindowTypes); + AssetBundleCollectorWindow window = GetWindow("资源包收集工具", true, WindowsDefine.DockedWindowTypes); window.minSize = new Vector2(800, 600); } @@ -70,7 +70,7 @@ namespace YooAsset.Editor VisualElement root = this.rootVisualElement; // 加载布局文件 - var visualAsset = EditorHelper.LoadWindowUXML(); + var visualAsset = UxmlLoader.LoadWindowUXML(); if (visualAsset == null) return; diff --git a/Assets/YooAsset/Editor/EditorAttribute.cs b/Assets/YooAsset/Editor/AssetBundleCollector/DisplayNameAttribute.cs similarity index 93% rename from Assets/YooAsset/Editor/EditorAttribute.cs rename to Assets/YooAsset/Editor/AssetBundleCollector/DisplayNameAttribute.cs index beecd80..8e001ed 100644 --- a/Assets/YooAsset/Editor/EditorAttribute.cs +++ b/Assets/YooAsset/Editor/AssetBundleCollector/DisplayNameAttribute.cs @@ -16,7 +16,7 @@ namespace YooAsset.Editor } } - public static class EditorAttribute + public static class DisplayNameAttributeHelper { internal static T GetAttribute(Type type) where T : Attribute { diff --git a/Assets/YooAsset/Editor/EditorAttribute.cs.meta b/Assets/YooAsset/Editor/AssetBundleCollector/DisplayNameAttribute.cs.meta similarity index 100% rename from Assets/YooAsset/Editor/EditorAttribute.cs.meta rename to Assets/YooAsset/Editor/AssetBundleCollector/DisplayNameAttribute.cs.meta diff --git a/Assets/YooAsset/Editor/AssetBundleDebugger/AssetBundleDebuggerWindow.cs b/Assets/YooAsset/Editor/AssetBundleDebugger/AssetBundleDebuggerWindow.cs index adda79d..19a3012 100644 --- a/Assets/YooAsset/Editor/AssetBundleDebugger/AssetBundleDebuggerWindow.cs +++ b/Assets/YooAsset/Editor/AssetBundleDebugger/AssetBundleDebuggerWindow.cs @@ -15,7 +15,7 @@ namespace YooAsset.Editor [MenuItem("YooAsset/AssetBundle Debugger", false, 104)] public static void ShowExample() { - AssetBundleDebuggerWindow wnd = GetWindow("资源包调试工具", true, EditorDefine.DockedWindowTypes); + AssetBundleDebuggerWindow wnd = GetWindow("资源包调试工具", true, WindowsDefine.DockedWindowTypes); wnd.minSize = new Vector2(800, 600); } @@ -63,7 +63,7 @@ namespace YooAsset.Editor VisualElement root = rootVisualElement; // 加载布局文件 - var visualAsset = EditorHelper.LoadWindowUXML(); + var visualAsset = UxmlLoader.LoadWindowUXML(); if (visualAsset == null) return; diff --git a/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerAssetListViewer.cs b/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerAssetListViewer.cs index 389f9bb..edc150b 100644 --- a/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerAssetListViewer.cs +++ b/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerAssetListViewer.cs @@ -24,7 +24,7 @@ namespace YooAsset.Editor public void InitViewer() { // 加载布局文件 - _visualAsset = EditorHelper.LoadWindowUXML(); + _visualAsset = UxmlLoader.LoadWindowUXML(); if (_visualAsset == null) return; @@ -45,6 +45,10 @@ namespace YooAsset.Editor _dependListView = _root.Q("BottomListView"); _dependListView.makeItem = MakeDependListViewItem; _dependListView.bindItem = BindDependListViewItem; + +#if UNITY_2020_3_OR_NEWER + SplitView.Adjuster(_root); +#endif } /// diff --git a/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerBundleListViewer.cs b/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerBundleListViewer.cs index cb68f3a..c4a2e6d 100644 --- a/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerBundleListViewer.cs +++ b/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerBundleListViewer.cs @@ -24,7 +24,7 @@ namespace YooAsset.Editor public void InitViewer() { // 加载布局文件 - _visualAsset = EditorHelper.LoadWindowUXML(); + _visualAsset = UxmlLoader.LoadWindowUXML(); if (_visualAsset == null) return; @@ -45,6 +45,10 @@ namespace YooAsset.Editor _usingListView = _root.Q("BottomListView"); _usingListView.makeItem = MakeIncludeListViewItem; _usingListView.bindItem = BindIncludeListViewItem; + +#if UNITY_2020_3_OR_NEWER + SplitView.Adjuster(_root); +#endif } /// diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/AssetBundleReporterWindow.cs b/Assets/YooAsset/Editor/AssetBundleReporter/AssetBundleReporterWindow.cs index 5cc2dd4..15009da 100644 --- a/Assets/YooAsset/Editor/AssetBundleReporter/AssetBundleReporterWindow.cs +++ b/Assets/YooAsset/Editor/AssetBundleReporter/AssetBundleReporterWindow.cs @@ -12,7 +12,7 @@ namespace YooAsset.Editor [MenuItem("YooAsset/AssetBundle Reporter", false, 103)] public static void ShowExample() { - AssetBundleReporterWindow window = GetWindow("资源包报告工具", true, EditorDefine.DockedWindowTypes); + AssetBundleReporterWindow window = GetWindow("资源包报告工具", true, WindowsDefine.DockedWindowTypes); window.minSize = new Vector2(800, 600); } @@ -55,7 +55,7 @@ namespace YooAsset.Editor VisualElement root = this.rootVisualElement; // 加载布局文件 - var visualAsset = EditorHelper.LoadWindowUXML(); + var visualAsset = UxmlLoader.LoadWindowUXML(); if (visualAsset == null) return; diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterAssetListViewer.cs b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterAssetListViewer.cs index 7830871..9417146 100644 --- a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterAssetListViewer.cs +++ b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterAssetListViewer.cs @@ -38,7 +38,7 @@ namespace YooAsset.Editor public void InitViewer() { // 加载布局文件 - _visualAsset = EditorHelper.LoadWindowUXML(); + _visualAsset = UxmlLoader.LoadWindowUXML(); if (_visualAsset == null) return; @@ -68,6 +68,10 @@ namespace YooAsset.Editor _dependListView = _root.Q("BottomListView"); _dependListView.makeItem = MakeDependListViewItem; _dependListView.bindItem = BindDependListViewItem; + +#if UNITY_2020_3_OR_NEWER + SplitView.Adjuster(_root); +#endif } /// diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterBundleListViewer.cs b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterBundleListViewer.cs index 35d800e..18ddfcc 100644 --- a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterBundleListViewer.cs +++ b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterBundleListViewer.cs @@ -42,7 +42,7 @@ namespace YooAsset.Editor public void InitViewer() { // 加载布局文件 - _visualAsset = EditorHelper.LoadWindowUXML(); + _visualAsset = UxmlLoader.LoadWindowUXML(); if (_visualAsset == null) return; @@ -76,6 +76,10 @@ namespace YooAsset.Editor _includeListView = _root.Q("BottomListView"); _includeListView.makeItem = MakeIncludeListViewItem; _includeListView.bindItem = BindIncludeListViewItem; + +#if UNITY_2020_3_OR_NEWER + SplitView.Adjuster(_root); +#endif } /// diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterBundleListViewer.uxml b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterBundleListViewer.uxml index d7434a8..460124c 100644 --- a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterBundleListViewer.uxml +++ b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterBundleListViewer.uxml @@ -1,21 +1,19 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterSummaryViewer.cs b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterSummaryViewer.cs index 5cc61bd..a12b53b 100644 --- a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterSummaryViewer.cs +++ b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterSummaryViewer.cs @@ -36,7 +36,7 @@ namespace YooAsset.Editor public void InitViewer() { // 加载布局文件 - _visualAsset = EditorHelper.LoadWindowUXML(); + _visualAsset = UxmlLoader.LoadWindowUXML(); if (_visualAsset == null) return; diff --git a/Assets/YooAsset/Editor/EditorDefine.cs b/Assets/YooAsset/Editor/EditorDefine.cs index cbb03fc..1cff7da 100644 --- a/Assets/YooAsset/Editor/EditorDefine.cs +++ b/Assets/YooAsset/Editor/EditorDefine.cs @@ -2,13 +2,13 @@ namespace YooAsset.Editor { - public class EditorDefine + public class WindowsDefine { #if UNITY_2019_4_OR_NEWER /// /// 停靠窗口类型集合 /// - public static readonly Type[] DockedWindowTypes = + public static readonly Type[] DockedWindowTypes = { typeof(AssetBundleBuilderWindow), typeof(AssetBundleCollectorWindow), diff --git a/Assets/YooAsset/Editor/SettingLoader.cs b/Assets/YooAsset/Editor/SettingLoader.cs new file mode 100644 index 0000000..2aaf434 --- /dev/null +++ b/Assets/YooAsset/Editor/SettingLoader.cs @@ -0,0 +1,45 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace YooAsset.Editor +{ + public class SettingLoader + { + /// + /// 加载相关的配置文件 + /// + public static TSetting LoadSettingData() where TSetting : ScriptableObject + { + var settingType = typeof(TSetting); + var guids = AssetDatabase.FindAssets($"t:{settingType.Name}"); + if (guids.Length == 0) + { + Debug.LogWarning($"Create new {settingType.Name}.asset"); + var setting = ScriptableObject.CreateInstance(); + string filePath = $"Assets/{settingType.Name}.asset"; + AssetDatabase.CreateAsset(setting, filePath); + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + return setting; + } + else + { + if (guids.Length != 1) + { + foreach (var guid in guids) + { + string path = AssetDatabase.GUIDToAssetPath(guid); + Debug.LogWarning($"Found multiple file : {path}"); + } + throw new System.Exception($"Found multiple {settingType.Name} files !"); + } + + string filePath = AssetDatabase.GUIDToAssetPath(guids[0]); + var setting = AssetDatabase.LoadAssetAtPath(filePath); + return setting; + } + } + } +} \ No newline at end of file diff --git a/Assets/YooAsset/Editor/EditorHelper.cs.meta b/Assets/YooAsset/Editor/SettingLoader.cs.meta similarity index 100% rename from Assets/YooAsset/Editor/EditorHelper.cs.meta rename to Assets/YooAsset/Editor/SettingLoader.cs.meta diff --git a/Assets/YooAsset/Editor/ShaderVariantCollector/ShaderVariantCollectorSettingData.cs b/Assets/YooAsset/Editor/ShaderVariantCollector/ShaderVariantCollectorSettingData.cs index 465add8..34a5374 100644 --- a/Assets/YooAsset/Editor/ShaderVariantCollector/ShaderVariantCollectorSettingData.cs +++ b/Assets/YooAsset/Editor/ShaderVariantCollector/ShaderVariantCollectorSettingData.cs @@ -25,7 +25,7 @@ namespace YooAsset.Editor /// private static void LoadSettingData() { - _setting = EditorHelper.LoadSettingData(); + _setting = SettingLoader.LoadSettingData(); } /// diff --git a/Assets/YooAsset/Editor/ShaderVariantCollector/ShaderVariantCollectorWindow.cs b/Assets/YooAsset/Editor/ShaderVariantCollector/ShaderVariantCollectorWindow.cs index 4da2565..da6204b 100644 --- a/Assets/YooAsset/Editor/ShaderVariantCollector/ShaderVariantCollectorWindow.cs +++ b/Assets/YooAsset/Editor/ShaderVariantCollector/ShaderVariantCollectorWindow.cs @@ -14,7 +14,7 @@ namespace YooAsset.Editor [MenuItem("YooAsset/ShaderVariant Collector", false, 201)] public static void ShowExample() { - ShaderVariantCollectorWindow window = GetWindow("着色器变种收集工具", true, EditorDefine.DockedWindowTypes); + ShaderVariantCollectorWindow window = GetWindow("着色器变种收集工具", true, WindowsDefine.DockedWindowTypes); window.minSize = new Vector2(800, 600); } @@ -34,7 +34,7 @@ namespace YooAsset.Editor VisualElement root = this.rootVisualElement; // 加载布局文件 - var visualAsset = EditorHelper.LoadWindowUXML(); + var visualAsset = UxmlLoader.LoadWindowUXML(); if (visualAsset == null) return; diff --git a/Assets/YooAsset/Editor/UxmlDefine.cs b/Assets/YooAsset/Editor/UxmlDefine.cs new file mode 100644 index 0000000..ecd618c --- /dev/null +++ b/Assets/YooAsset/Editor/UxmlDefine.cs @@ -0,0 +1,39 @@ +#if UNITY_2020_3_OR_NEWER +using System; +using UnityEditor; +using UnityEngine; +using UnityEditor.UIElements; +using UnityEngine.UIElements; + +namespace YooAsset.Editor +{ + /// + /// 分屏控件 + /// + public class SplitView : TwoPaneSplitView + { + public new class UxmlFactory : UxmlFactory + { + } + + /// + /// 窗口分屏适配 + /// + public static void Adjuster(VisualElement root) + { + var topGroup = root.Q("TopGroup"); + var bottomGroup = root.Q("BottomGroup"); + topGroup.style.minHeight = 100f; + bottomGroup.style.minHeight = 100f; + root.Remove(topGroup); + root.Remove(bottomGroup); + var spliteView = new SplitView(); + spliteView.fixedPaneInitialDimension = 300; + spliteView.orientation = TwoPaneSplitViewOrientation.Vertical; + spliteView.contentContainer.Add(topGroup); + spliteView.contentContainer.Add(bottomGroup); + root.Add(spliteView); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/YooAsset/Editor/UxmlDefine.cs.meta b/Assets/YooAsset/Editor/UxmlDefine.cs.meta new file mode 100644 index 0000000..abfbfc1 --- /dev/null +++ b/Assets/YooAsset/Editor/UxmlDefine.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0c3f4136cf7142346ae33e8a82cbdb27 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/YooAsset/Editor/EditorExtension.cs b/Assets/YooAsset/Editor/UxmlExtension.cs similarity index 100% rename from Assets/YooAsset/Editor/EditorExtension.cs rename to Assets/YooAsset/Editor/UxmlExtension.cs diff --git a/Assets/YooAsset/Editor/EditorExtension.cs.meta b/Assets/YooAsset/Editor/UxmlExtension.cs.meta similarity index 100% rename from Assets/YooAsset/Editor/EditorExtension.cs.meta rename to Assets/YooAsset/Editor/UxmlExtension.cs.meta diff --git a/Assets/YooAsset/Editor/EditorHelper.cs b/Assets/YooAsset/Editor/UxmlLoader.cs similarity index 58% rename from Assets/YooAsset/Editor/EditorHelper.cs rename to Assets/YooAsset/Editor/UxmlLoader.cs index c90b01d..3f36ce6 100644 --- a/Assets/YooAsset/Editor/EditorHelper.cs +++ b/Assets/YooAsset/Editor/UxmlLoader.cs @@ -1,13 +1,15 @@ -using System.Collections; +#if UNITY_2019_4_OR_NEWER +using System.Collections; using System.Collections.Generic; -using UnityEngine; using UnityEditor; +using UnityEngine; +using UnityEditor.UIElements; +using UnityEngine.UIElements; namespace YooAsset.Editor { - public class EditorHelper + public class UxmlLoader { -#if UNITY_2019_4_OR_NEWER private readonly static Dictionary _uxmlDic = new Dictionary(); /// @@ -48,41 +50,6 @@ namespace YooAsset.Editor } throw new System.Exception($"Not found UXML file : {windowType.Name}"); } -#endif - - /// - /// 加载相关的配置文件 - /// - public static TSetting LoadSettingData() where TSetting : ScriptableObject - { - var settingType = typeof(TSetting); - var guids = AssetDatabase.FindAssets($"t:{settingType.Name}"); - if (guids.Length == 0) - { - Debug.LogWarning($"Create new {settingType.Name}.asset"); - var setting = ScriptableObject.CreateInstance(); - string filePath = $"Assets/{settingType.Name}.asset"; - AssetDatabase.CreateAsset(setting, filePath); - AssetDatabase.SaveAssets(); - AssetDatabase.Refresh(); - return setting; - } - else - { - if (guids.Length != 1) - { - foreach (var guid in guids) - { - string path = AssetDatabase.GUIDToAssetPath(guid); - Debug.LogWarning($"Found multiple file : {path}"); - } - throw new System.Exception($"Found multiple {settingType.Name} files !"); - } - - string filePath = AssetDatabase.GUIDToAssetPath(guids[0]); - var setting = AssetDatabase.LoadAssetAtPath(filePath); - return setting; - } - } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Assets/YooAsset/Editor/UxmlLoader.cs.meta b/Assets/YooAsset/Editor/UxmlLoader.cs.meta new file mode 100644 index 0000000..b641537 --- /dev/null +++ b/Assets/YooAsset/Editor/UxmlLoader.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ed843f102c2467845b34fdce5d537e47 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: