mirror of https://github.com/tuyoogame/YooAsset
parent
3943850bc1
commit
16e3001e51
|
@ -29,7 +29,7 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static void LoadSettingData()
|
private static void LoadSettingData()
|
||||||
{
|
{
|
||||||
_setting = EditorHelper.LoadSettingData<AssetBundleBuilderSetting>();
|
_setting = SettingLoader.LoadSettingData<AssetBundleBuilderSetting>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace YooAsset.Editor
|
||||||
[MenuItem("YooAsset/AssetBundle Builder", false, 102)]
|
[MenuItem("YooAsset/AssetBundle Builder", false, 102)]
|
||||||
public static void ShowExample()
|
public static void ShowExample()
|
||||||
{
|
{
|
||||||
AssetBundleBuilderWindow window = GetWindow<AssetBundleBuilderWindow>("资源包构建工具", true, EditorDefine.DockedWindowTypes);
|
AssetBundleBuilderWindow window = GetWindow<AssetBundleBuilderWindow>("资源包构建工具", true, WindowsDefine.DockedWindowTypes);
|
||||||
window.minSize = new Vector2(800, 600);
|
window.minSize = new Vector2(800, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ namespace YooAsset.Editor
|
||||||
VisualElement root = this.rootVisualElement;
|
VisualElement root = this.rootVisualElement;
|
||||||
|
|
||||||
// 加载布局文件
|
// 加载布局文件
|
||||||
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleBuilderWindow>();
|
var visualAsset = UxmlLoader.LoadWindowUXML<AssetBundleBuilderWindow>();
|
||||||
if (visualAsset == null)
|
if (visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static void LoadSettingData()
|
private static void LoadSettingData()
|
||||||
{
|
{
|
||||||
_setting = EditorHelper.LoadSettingData<AssetBundleCollectorSetting>();
|
_setting = SettingLoader.LoadSettingData<AssetBundleCollectorSetting>();
|
||||||
|
|
||||||
// IPackRule
|
// IPackRule
|
||||||
{
|
{
|
||||||
|
@ -244,7 +244,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
private static string GetRuleDisplayName(string name, Type type)
|
private static string GetRuleDisplayName(string name, Type type)
|
||||||
{
|
{
|
||||||
var attribute = EditorAttribute.GetAttribute<DisplayNameAttribute>(type);
|
var attribute = DisplayNameAttributeHelper.GetAttribute<DisplayNameAttribute>(type);
|
||||||
if (attribute != null && string.IsNullOrEmpty(attribute.DisplayName) == false)
|
if (attribute != null && string.IsNullOrEmpty(attribute.DisplayName) == false)
|
||||||
return attribute.DisplayName;
|
return attribute.DisplayName;
|
||||||
else
|
else
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace YooAsset.Editor
|
||||||
[MenuItem("YooAsset/AssetBundle Collector", false, 101)]
|
[MenuItem("YooAsset/AssetBundle Collector", false, 101)]
|
||||||
public static void ShowExample()
|
public static void ShowExample()
|
||||||
{
|
{
|
||||||
AssetBundleCollectorWindow window = GetWindow<AssetBundleCollectorWindow>("资源包收集工具", true, EditorDefine.DockedWindowTypes);
|
AssetBundleCollectorWindow window = GetWindow<AssetBundleCollectorWindow>("资源包收集工具", true, WindowsDefine.DockedWindowTypes);
|
||||||
window.minSize = new Vector2(800, 600);
|
window.minSize = new Vector2(800, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ namespace YooAsset.Editor
|
||||||
VisualElement root = this.rootVisualElement;
|
VisualElement root = this.rootVisualElement;
|
||||||
|
|
||||||
// 加载布局文件
|
// 加载布局文件
|
||||||
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleCollectorWindow>();
|
var visualAsset = UxmlLoader.LoadWindowUXML<AssetBundleCollectorWindow>();
|
||||||
if (visualAsset == null)
|
if (visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class EditorAttribute
|
public static class DisplayNameAttributeHelper
|
||||||
{
|
{
|
||||||
internal static T GetAttribute<T>(Type type) where T : Attribute
|
internal static T GetAttribute<T>(Type type) where T : Attribute
|
||||||
{
|
{
|
|
@ -15,7 +15,7 @@ namespace YooAsset.Editor
|
||||||
[MenuItem("YooAsset/AssetBundle Debugger", false, 104)]
|
[MenuItem("YooAsset/AssetBundle Debugger", false, 104)]
|
||||||
public static void ShowExample()
|
public static void ShowExample()
|
||||||
{
|
{
|
||||||
AssetBundleDebuggerWindow wnd = GetWindow<AssetBundleDebuggerWindow>("资源包调试工具", true, EditorDefine.DockedWindowTypes);
|
AssetBundleDebuggerWindow wnd = GetWindow<AssetBundleDebuggerWindow>("资源包调试工具", true, WindowsDefine.DockedWindowTypes);
|
||||||
wnd.minSize = new Vector2(800, 600);
|
wnd.minSize = new Vector2(800, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ namespace YooAsset.Editor
|
||||||
VisualElement root = rootVisualElement;
|
VisualElement root = rootVisualElement;
|
||||||
|
|
||||||
// 加载布局文件
|
// 加载布局文件
|
||||||
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleDebuggerWindow>();
|
var visualAsset = UxmlLoader.LoadWindowUXML<AssetBundleDebuggerWindow>();
|
||||||
if (visualAsset == null)
|
if (visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace YooAsset.Editor
|
||||||
public void InitViewer()
|
public void InitViewer()
|
||||||
{
|
{
|
||||||
// 加载布局文件
|
// 加载布局文件
|
||||||
_visualAsset = EditorHelper.LoadWindowUXML<DebuggerAssetListViewer>();
|
_visualAsset = UxmlLoader.LoadWindowUXML<DebuggerAssetListViewer>();
|
||||||
if (_visualAsset == null)
|
if (_visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -45,6 +45,10 @@ namespace YooAsset.Editor
|
||||||
_dependListView = _root.Q<ListView>("BottomListView");
|
_dependListView = _root.Q<ListView>("BottomListView");
|
||||||
_dependListView.makeItem = MakeDependListViewItem;
|
_dependListView.makeItem = MakeDependListViewItem;
|
||||||
_dependListView.bindItem = BindDependListViewItem;
|
_dependListView.bindItem = BindDependListViewItem;
|
||||||
|
|
||||||
|
#if UNITY_2020_3_OR_NEWER
|
||||||
|
SplitView.Adjuster(_root);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace YooAsset.Editor
|
||||||
public void InitViewer()
|
public void InitViewer()
|
||||||
{
|
{
|
||||||
// 加载布局文件
|
// 加载布局文件
|
||||||
_visualAsset = EditorHelper.LoadWindowUXML<DebuggerBundleListViewer>();
|
_visualAsset = UxmlLoader.LoadWindowUXML<DebuggerBundleListViewer>();
|
||||||
if (_visualAsset == null)
|
if (_visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -45,6 +45,10 @@ namespace YooAsset.Editor
|
||||||
_usingListView = _root.Q<ListView>("BottomListView");
|
_usingListView = _root.Q<ListView>("BottomListView");
|
||||||
_usingListView.makeItem = MakeIncludeListViewItem;
|
_usingListView.makeItem = MakeIncludeListViewItem;
|
||||||
_usingListView.bindItem = BindIncludeListViewItem;
|
_usingListView.bindItem = BindIncludeListViewItem;
|
||||||
|
|
||||||
|
#if UNITY_2020_3_OR_NEWER
|
||||||
|
SplitView.Adjuster(_root);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace YooAsset.Editor
|
||||||
[MenuItem("YooAsset/AssetBundle Reporter", false, 103)]
|
[MenuItem("YooAsset/AssetBundle Reporter", false, 103)]
|
||||||
public static void ShowExample()
|
public static void ShowExample()
|
||||||
{
|
{
|
||||||
AssetBundleReporterWindow window = GetWindow<AssetBundleReporterWindow>("资源包报告工具", true, EditorDefine.DockedWindowTypes);
|
AssetBundleReporterWindow window = GetWindow<AssetBundleReporterWindow>("资源包报告工具", true, WindowsDefine.DockedWindowTypes);
|
||||||
window.minSize = new Vector2(800, 600);
|
window.minSize = new Vector2(800, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ namespace YooAsset.Editor
|
||||||
VisualElement root = this.rootVisualElement;
|
VisualElement root = this.rootVisualElement;
|
||||||
|
|
||||||
// 加载布局文件
|
// 加载布局文件
|
||||||
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleReporterWindow>();
|
var visualAsset = UxmlLoader.LoadWindowUXML<AssetBundleReporterWindow>();
|
||||||
if (visualAsset == null)
|
if (visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace YooAsset.Editor
|
||||||
public void InitViewer()
|
public void InitViewer()
|
||||||
{
|
{
|
||||||
// 加载布局文件
|
// 加载布局文件
|
||||||
_visualAsset = EditorHelper.LoadWindowUXML<ReporterAssetListViewer>();
|
_visualAsset = UxmlLoader.LoadWindowUXML<ReporterAssetListViewer>();
|
||||||
if (_visualAsset == null)
|
if (_visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -68,6 +68,10 @@ namespace YooAsset.Editor
|
||||||
_dependListView = _root.Q<ListView>("BottomListView");
|
_dependListView = _root.Q<ListView>("BottomListView");
|
||||||
_dependListView.makeItem = MakeDependListViewItem;
|
_dependListView.makeItem = MakeDependListViewItem;
|
||||||
_dependListView.bindItem = BindDependListViewItem;
|
_dependListView.bindItem = BindDependListViewItem;
|
||||||
|
|
||||||
|
#if UNITY_2020_3_OR_NEWER
|
||||||
|
SplitView.Adjuster(_root);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace YooAsset.Editor
|
||||||
public void InitViewer()
|
public void InitViewer()
|
||||||
{
|
{
|
||||||
// 加载布局文件
|
// 加载布局文件
|
||||||
_visualAsset = EditorHelper.LoadWindowUXML<ReporterBundleListViewer>();
|
_visualAsset = UxmlLoader.LoadWindowUXML<ReporterBundleListViewer>();
|
||||||
if (_visualAsset == null)
|
if (_visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -76,6 +76,10 @@ namespace YooAsset.Editor
|
||||||
_includeListView = _root.Q<ListView>("BottomListView");
|
_includeListView = _root.Q<ListView>("BottomListView");
|
||||||
_includeListView.makeItem = MakeIncludeListViewItem;
|
_includeListView.makeItem = MakeIncludeListViewItem;
|
||||||
_includeListView.bindItem = BindIncludeListViewItem;
|
_includeListView.bindItem = BindIncludeListViewItem;
|
||||||
|
|
||||||
|
#if UNITY_2020_3_OR_NEWER
|
||||||
|
SplitView.Adjuster(_root);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||||
<ui:VisualElement name="Viewer" style="flex-grow: 1; display: flex;">
|
|
||||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||||
<uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
<uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||||
|
@ -17,5 +16,4 @@
|
||||||
</uie:Toolbar>
|
</uie:Toolbar>
|
||||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
<ui:ListView focusable="true" name="BottomListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
</ui:VisualElement>
|
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace YooAsset.Editor
|
||||||
public void InitViewer()
|
public void InitViewer()
|
||||||
{
|
{
|
||||||
// 加载布局文件
|
// 加载布局文件
|
||||||
_visualAsset = EditorHelper.LoadWindowUXML<ReporterSummaryViewer>();
|
_visualAsset = UxmlLoader.LoadWindowUXML<ReporterSummaryViewer>();
|
||||||
if (_visualAsset == null)
|
if (_visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class EditorDefine
|
public class WindowsDefine
|
||||||
{
|
{
|
||||||
#if UNITY_2019_4_OR_NEWER
|
#if UNITY_2019_4_OR_NEWER
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class SettingLoader
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 加载相关的配置文件
|
||||||
|
/// </summary>
|
||||||
|
public static TSetting LoadSettingData<TSetting>() 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<TSetting>();
|
||||||
|
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<TSetting>(filePath);
|
||||||
|
return setting;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,7 +25,7 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static void LoadSettingData()
|
private static void LoadSettingData()
|
||||||
{
|
{
|
||||||
_setting = EditorHelper.LoadSettingData<ShaderVariantCollectorSetting>();
|
_setting = SettingLoader.LoadSettingData<ShaderVariantCollectorSetting>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace YooAsset.Editor
|
||||||
[MenuItem("YooAsset/ShaderVariant Collector", false, 201)]
|
[MenuItem("YooAsset/ShaderVariant Collector", false, 201)]
|
||||||
public static void ShowExample()
|
public static void ShowExample()
|
||||||
{
|
{
|
||||||
ShaderVariantCollectorWindow window = GetWindow<ShaderVariantCollectorWindow>("着色器变种收集工具", true, EditorDefine.DockedWindowTypes);
|
ShaderVariantCollectorWindow window = GetWindow<ShaderVariantCollectorWindow>("着色器变种收集工具", true, WindowsDefine.DockedWindowTypes);
|
||||||
window.minSize = new Vector2(800, 600);
|
window.minSize = new Vector2(800, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ namespace YooAsset.Editor
|
||||||
VisualElement root = this.rootVisualElement;
|
VisualElement root = this.rootVisualElement;
|
||||||
|
|
||||||
// 加载布局文件
|
// 加载布局文件
|
||||||
var visualAsset = EditorHelper.LoadWindowUXML<ShaderVariantCollectorWindow>();
|
var visualAsset = UxmlLoader.LoadWindowUXML<ShaderVariantCollectorWindow>();
|
||||||
if (visualAsset == null)
|
if (visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 分屏控件
|
||||||
|
/// </summary>
|
||||||
|
public class SplitView : TwoPaneSplitView
|
||||||
|
{
|
||||||
|
public new class UxmlFactory : UxmlFactory<SplitView, TwoPaneSplitView.UxmlTraits>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 窗口分屏适配
|
||||||
|
/// </summary>
|
||||||
|
public static void Adjuster(VisualElement root)
|
||||||
|
{
|
||||||
|
var topGroup = root.Q<VisualElement>("TopGroup");
|
||||||
|
var bottomGroup = root.Q<VisualElement>("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
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0c3f4136cf7142346ae33e8a82cbdb27
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -1,13 +1,15 @@
|
||||||
using System.Collections;
|
#if UNITY_2019_4_OR_NEWER
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor.UIElements;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class EditorHelper
|
public class UxmlLoader
|
||||||
{
|
{
|
||||||
#if UNITY_2019_4_OR_NEWER
|
|
||||||
private readonly static Dictionary<System.Type, string> _uxmlDic = new Dictionary<System.Type, string>();
|
private readonly static Dictionary<System.Type, string> _uxmlDic = new Dictionary<System.Type, string>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -48,41 +50,6 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
throw new System.Exception($"Not found UXML file : {windowType.Name}");
|
throw new System.Exception($"Not found UXML file : {windowType.Name}");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 加载相关的配置文件
|
|
||||||
/// </summary>
|
|
||||||
public static TSetting LoadSettingData<TSetting>() 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<TSetting>();
|
|
||||||
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<TSetting>(filePath);
|
|
||||||
return setting;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ed843f102c2467845b34fdce5d537e47
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue