mirror of https://github.com/tuyoogame/YooAsset
parent
d43d30f72f
commit
a906a84721
|
@ -24,7 +24,7 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
private static void LoadSettingData()
|
||||
{
|
||||
_setting = YooAssetEditorSettingsHelper.LoadSettingData<AssetBundleBuilderSetting>();
|
||||
_setting = EditorHelper.LoadSettingData<AssetBundleBuilderSetting>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -38,12 +38,10 @@ namespace YooAsset.Editor
|
|||
VisualElement root = this.rootVisualElement;
|
||||
|
||||
// 加载布局文件
|
||||
var visualAsset = YooAssetEditorSettingsData.Setting.AssetBundleBuilderUXML;
|
||||
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleBuilderWindow>();
|
||||
if (visualAsset == null)
|
||||
{
|
||||
Debug.LogError($"Not found {nameof(AssetBundleBuilderWindow)}.uxml in settings.");
|
||||
return;
|
||||
}
|
||||
|
||||
visualAsset.CloneTree(root);
|
||||
|
||||
_buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
|
|
|
@ -105,7 +105,7 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
private static void LoadSettingData()
|
||||
{
|
||||
_setting = YooAssetEditorSettingsHelper.LoadSettingData<AssetBundleCollectorSetting>();
|
||||
_setting = EditorHelper.LoadSettingData<AssetBundleCollectorSetting>();
|
||||
|
||||
// IPackRule
|
||||
{
|
||||
|
|
|
@ -54,12 +54,10 @@ namespace YooAsset.Editor
|
|||
VisualElement root = this.rootVisualElement;
|
||||
|
||||
// 加载布局文件
|
||||
var visualAsset = YooAssetEditorSettingsData.Setting.AssetBundleCollectorUXML;
|
||||
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleCollectorWindow>();
|
||||
if (visualAsset == null)
|
||||
{
|
||||
Debug.LogError($"Not found {nameof(AssetBundleCollectorWindow)}.uxml in settings.");
|
||||
return;
|
||||
}
|
||||
|
||||
visualAsset.CloneTree(root);
|
||||
|
||||
// 导入导出按钮
|
||||
|
|
|
@ -53,12 +53,10 @@ namespace YooAsset.Editor
|
|||
VisualElement root = rootVisualElement;
|
||||
|
||||
// 加载布局文件
|
||||
var visualAsset = YooAssetEditorSettingsData.Setting.AssetBundleDebuggerUXML;
|
||||
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleDebuggerWindow>();
|
||||
if (visualAsset == null)
|
||||
{
|
||||
Debug.LogError($"Not found {nameof(AssetBundleDebuggerWindow)}.uxml in settings.");
|
||||
return;
|
||||
}
|
||||
|
||||
visualAsset.CloneTree(root);
|
||||
|
||||
// 采样按钮
|
||||
|
|
|
@ -24,12 +24,10 @@ namespace YooAsset.Editor
|
|||
public void InitViewer()
|
||||
{
|
||||
// 加载布局文件
|
||||
_visualAsset = YooAssetEditorSettingsData.Setting.DebuggerAssetListViewerUXML;
|
||||
_visualAsset = EditorHelper.LoadWindowUXML<DebuggerAssetListViewer>();
|
||||
if (_visualAsset == null)
|
||||
{
|
||||
Debug.LogError($"Not found {nameof(DebuggerAssetListViewer)}.uxml in settings.");
|
||||
return;
|
||||
}
|
||||
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
|
|
|
@ -24,12 +24,10 @@ namespace YooAsset.Editor
|
|||
public void InitViewer()
|
||||
{
|
||||
// 加载布局文件
|
||||
_visualAsset = YooAssetEditorSettingsData.Setting.DebuggerBundleListViewerUXML;
|
||||
_visualAsset = EditorHelper.LoadWindowUXML<DebuggerBundleListViewer>();
|
||||
if (_visualAsset == null)
|
||||
{
|
||||
Debug.LogError($"Not found {nameof(DebuggerBundleListViewer)}.uxml in settings.");
|
||||
return;
|
||||
}
|
||||
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
|
@ -37,12 +35,12 @@ namespace YooAsset.Editor
|
|||
_bundleListView = _root.Q<ListView>("TopListView");
|
||||
_bundleListView.makeItem = MakeAssetListViewItem;
|
||||
_bundleListView.bindItem = BindAssetListViewItem;
|
||||
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
_bundleListView.onSelectionChange += BundleListView_onSelectionChange;
|
||||
#else
|
||||
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange;
|
||||
#endif
|
||||
|
||||
// 使用列表
|
||||
_usingListView = _root.Q<ListView>("BottomListView");
|
||||
_usingListView.makeItem = MakeIncludeListViewItem;
|
||||
|
|
|
@ -55,12 +55,10 @@ namespace YooAsset.Editor
|
|||
VisualElement root = this.rootVisualElement;
|
||||
|
||||
// 加载布局文件
|
||||
var visualAsset = YooAssetEditorSettingsData.Setting.AssetBundleReporterUXML;
|
||||
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleReporterWindow>();
|
||||
if (visualAsset == null)
|
||||
{
|
||||
Debug.LogError($"Not found {nameof(AssetBundleReporterWindow)}.uxml in settings.");
|
||||
return;
|
||||
}
|
||||
|
||||
visualAsset.CloneTree(root);
|
||||
|
||||
// 导入按钮
|
||||
|
|
|
@ -38,46 +38,36 @@ namespace YooAsset.Editor
|
|||
public void InitViewer()
|
||||
{
|
||||
// 加载布局文件
|
||||
_visualAsset = YooAssetEditorSettingsData.Setting.ReporterAssetListViewerUXML;
|
||||
_visualAsset = EditorHelper.LoadWindowUXML<ReporterAssetListViewer>();
|
||||
if (_visualAsset == null)
|
||||
{
|
||||
Debug.LogError($"Not found {nameof(ReporterAssetListViewer)}.uxml in settings.");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 顶部按钮栏
|
||||
_topBar1 = _root.Q<ToolbarButton>("TopBar1");
|
||||
_topBar2 = _root.Q<ToolbarButton>("TopBar2");
|
||||
_topBar1.clicked += TopBar1_clicked;
|
||||
_topBar2.clicked += TopBar2_clicked;
|
||||
// 顶部按钮栏
|
||||
_topBar1 = _root.Q<ToolbarButton>("TopBar1");
|
||||
_topBar2 = _root.Q<ToolbarButton>("TopBar2");
|
||||
_topBar1.clicked += TopBar1_clicked;
|
||||
_topBar2.clicked += TopBar2_clicked;
|
||||
|
||||
// 底部按钮栏
|
||||
_bottomBar1 = _root.Q<ToolbarButton>("BottomBar1");
|
||||
// 底部按钮栏
|
||||
_bottomBar1 = _root.Q<ToolbarButton>("BottomBar1");
|
||||
|
||||
// 资源列表
|
||||
_assetListView = _root.Q<ListView>("TopListView");
|
||||
_assetListView.makeItem = MakeAssetListViewItem;
|
||||
_assetListView.bindItem = BindAssetListViewItem;
|
||||
// 资源列表
|
||||
_assetListView = _root.Q<ListView>("TopListView");
|
||||
_assetListView.makeItem = MakeAssetListViewItem;
|
||||
_assetListView.bindItem = BindAssetListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
_assetListView.onSelectionChange += AssetListView_onSelectionChange;
|
||||
_assetListView.onSelectionChange += AssetListView_onSelectionChange;
|
||||
#else
|
||||
_assetListView.onSelectionChanged += AssetListView_onSelectionChange;
|
||||
_assetListView.onSelectionChanged += AssetListView_onSelectionChange;
|
||||
#endif
|
||||
|
||||
// 依赖列表
|
||||
_dependListView = _root.Q<ListView>("BottomListView");
|
||||
_dependListView.makeItem = MakeDependListViewItem;
|
||||
_dependListView.bindItem = BindDependListViewItem;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
// 依赖列表
|
||||
_dependListView = _root.Q<ListView>("BottomListView");
|
||||
_dependListView.makeItem = MakeDependListViewItem;
|
||||
_dependListView.bindItem = BindDependListViewItem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -42,56 +42,46 @@ namespace YooAsset.Editor
|
|||
public void InitViewer()
|
||||
{
|
||||
// 加载布局文件
|
||||
_visualAsset = YooAssetEditorSettingsData.Setting.ReporterBundleListViewerUXML;
|
||||
_visualAsset = EditorHelper.LoadWindowUXML<ReporterBundleListViewer>();
|
||||
if (_visualAsset == null)
|
||||
{
|
||||
Debug.LogError($"Not found {nameof(ReporterBundleListViewer)}.uxml in settings.");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 顶部按钮栏
|
||||
_topBar1 = _root.Q<ToolbarButton>("TopBar1");
|
||||
_topBar2 = _root.Q<ToolbarButton>("TopBar2");
|
||||
_topBar3 = _root.Q<ToolbarButton>("TopBar3");
|
||||
_topBar4 = _root.Q<ToolbarButton>("TopBar4");
|
||||
_topBar1.clicked += TopBar1_clicked;
|
||||
_topBar2.clicked += TopBar2_clicked;
|
||||
_topBar3.clicked += TopBar3_clicked;
|
||||
_topBar4.clicked += TopBar4_clicked;
|
||||
// 顶部按钮栏
|
||||
_topBar1 = _root.Q<ToolbarButton>("TopBar1");
|
||||
_topBar2 = _root.Q<ToolbarButton>("TopBar2");
|
||||
_topBar3 = _root.Q<ToolbarButton>("TopBar3");
|
||||
_topBar4 = _root.Q<ToolbarButton>("TopBar4");
|
||||
_topBar1.clicked += TopBar1_clicked;
|
||||
_topBar2.clicked += TopBar2_clicked;
|
||||
_topBar3.clicked += TopBar3_clicked;
|
||||
_topBar4.clicked += TopBar4_clicked;
|
||||
|
||||
// 底部按钮栏
|
||||
_bottomBar1 = _root.Q<ToolbarButton>("BottomBar1");
|
||||
// 底部按钮栏
|
||||
_bottomBar1 = _root.Q<ToolbarButton>("BottomBar1");
|
||||
|
||||
// 资源包列表
|
||||
_bundleListView = _root.Q<ListView>("TopListView");
|
||||
_bundleListView.makeItem = MakeBundleListViewItem;
|
||||
_bundleListView.bindItem = BindBundleListViewItem;
|
||||
// 资源包列表
|
||||
_bundleListView = _root.Q<ListView>("TopListView");
|
||||
_bundleListView.makeItem = MakeBundleListViewItem;
|
||||
_bundleListView.bindItem = BindBundleListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
_bundleListView.onSelectionChange += BundleListView_onSelectionChange;
|
||||
_bundleListView.onSelectionChange += BundleListView_onSelectionChange;
|
||||
#else
|
||||
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange;
|
||||
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange;
|
||||
#endif
|
||||
|
||||
// 包含列表
|
||||
_includeListView = _root.Q<ListView>("BottomListView");
|
||||
_includeListView.makeItem = MakeIncludeListViewItem;
|
||||
_includeListView.bindItem = BindIncludeListViewItem;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
// 包含列表
|
||||
_includeListView = _root.Q<ListView>("BottomListView");
|
||||
_includeListView.makeItem = MakeIncludeListViewItem;
|
||||
_includeListView.bindItem = BindIncludeListViewItem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData( BuildReport buildReport, string reprotFilePath, string searchKeyWord)
|
||||
public void FillViewData(BuildReport buildReport, string reprotFilePath, string searchKeyWord)
|
||||
{
|
||||
_buildReport = buildReport;
|
||||
_reportFilePath = reprotFilePath;
|
||||
|
|
|
@ -37,12 +37,10 @@ namespace YooAsset.Editor
|
|||
public void InitViewer()
|
||||
{
|
||||
// 加载布局文件
|
||||
_visualAsset = YooAssetEditorSettingsData.Setting.ReporterSummaryViewerUXML;
|
||||
_visualAsset = EditorHelper.LoadWindowUXML<ReporterSummaryViewer>();
|
||||
if (_visualAsset == null)
|
||||
{
|
||||
Debug.LogError($"Not found {nameof(ReporterSummaryViewer)}.uxml in settings.");
|
||||
return;
|
||||
}
|
||||
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class EditorHelper
|
||||
{
|
||||
private readonly static Dictionary<System.Type, string> _uxmlDic = new Dictionary<System.Type, string>();
|
||||
|
||||
static EditorHelper()
|
||||
{
|
||||
// 资源包收集
|
||||
_uxmlDic.Add(typeof(AssetBundleCollectorWindow), "355c4ac5cdebddc4c8362bed6f17a79e");
|
||||
|
||||
// 资源包构建
|
||||
_uxmlDic.Add(typeof(AssetBundleBuilderWindow), "28ba29adb4949284e8c48893218b0d9a");
|
||||
|
||||
// 资源包调试
|
||||
_uxmlDic.Add(typeof(AssetBundleDebuggerWindow), "790db12999afd334e8fb6ba70ef0a947");
|
||||
_uxmlDic.Add(typeof(DebuggerAssetListViewer), "31c6096c1cb29b4469096b7b4942a322");
|
||||
_uxmlDic.Add(typeof(DebuggerBundleListViewer), "932a25ffd05c13c47994d66e9d73bc37");
|
||||
|
||||
// 构建报告
|
||||
_uxmlDic.Add(typeof(AssetBundleReporterWindow), "9052b72c383e95043a0c7e7f369b1ad7");
|
||||
_uxmlDic.Add(typeof(ReporterSummaryViewer), "f8929271050855e42a1ccc6b14993a04");
|
||||
_uxmlDic.Add(typeof(ReporterAssetListViewer), "5f81bc15a55ee0a49a266f9d71e2372b");
|
||||
_uxmlDic.Add(typeof(ReporterBundleListViewer), "56d6dbe0d65ce334a8996beb19612989");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载窗口的布局文件
|
||||
/// </summary>
|
||||
public static VisualTreeAsset LoadWindowUXML<TWindow>() where TWindow : class
|
||||
{
|
||||
var windowType = typeof(TWindow);
|
||||
if (_uxmlDic.TryGetValue(windowType, out string uxmlGUID))
|
||||
{
|
||||
string assetPath = AssetDatabase.GUIDToAssetPath(uxmlGUID);
|
||||
if (string.IsNullOrEmpty(assetPath))
|
||||
throw new System.Exception($"Invalid YooAsset uxml guid : {uxmlGUID}");
|
||||
var visualTreeAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(assetPath);
|
||||
if (visualTreeAsset == null)
|
||||
throw new System.Exception($"Failed to load {windowType}.uxml");
|
||||
return visualTreeAsset;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.Exception($"Invalid YooAsset window type : {windowType}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <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)
|
||||
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>
|
||||
private static void LoadSettingData()
|
||||
{
|
||||
_setting = YooAssetEditorSettingsHelper.LoadSettingData<ShaderVariantCollectorSetting>();
|
||||
_setting = EditorHelper.LoadSettingData<ShaderVariantCollectorSetting>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4eff45040ac501b4fa978c46f72f2e64, type: 3}
|
||||
m_Name: YooAssetEditorSettings
|
||||
m_EditorClassIdentifier:
|
||||
AssetBundleCollectorUXML: {fileID: 9197481963319205126, guid: 355c4ac5cdebddc4c8362bed6f17a79e,
|
||||
type: 3}
|
||||
AssetBundleBuilderUXML: {fileID: 9197481963319205126, guid: 28ba29adb4949284e8c48893218b0d9a,
|
||||
type: 3}
|
||||
AssetBundleDebuggerUXML: {fileID: 9197481963319205126, guid: 790db12999afd334e8fb6ba70ef0a947,
|
||||
type: 3}
|
||||
DebuggerAssetListViewerUXML: {fileID: 9197481963319205126, guid: 31c6096c1cb29b4469096b7b4942a322,
|
||||
type: 3}
|
||||
DebuggerBundleListViewerUXML: {fileID: 9197481963319205126, guid: 932a25ffd05c13c47994d66e9d73bc37,
|
||||
type: 3}
|
||||
AssetBundleReporterUXML: {fileID: 9197481963319205126, guid: 9052b72c383e95043a0c7e7f369b1ad7,
|
||||
type: 3}
|
||||
ReporterSummaryViewerUXML: {fileID: 9197481963319205126, guid: f8929271050855e42a1ccc6b14993a04,
|
||||
type: 3}
|
||||
ReporterAssetListViewerUXML: {fileID: 9197481963319205126, guid: 5f81bc15a55ee0a49a266f9d71e2372b,
|
||||
type: 3}
|
||||
ReporterBundleListViewerUXML: {fileID: 9197481963319205126, guid: 56d6dbe0d65ce334a8996beb19612989,
|
||||
type: 3}
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b0b43f68477734743a5f2fc507b5bda6
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,25 +0,0 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class YooAssetEditorSettings : ScriptableObject
|
||||
{
|
||||
// 资源包收集
|
||||
public VisualTreeAsset AssetBundleCollectorUXML;
|
||||
|
||||
// 资源包构建
|
||||
public VisualTreeAsset AssetBundleBuilderUXML;
|
||||
|
||||
// 资源包调试
|
||||
public VisualTreeAsset AssetBundleDebuggerUXML;
|
||||
public VisualTreeAsset DebuggerAssetListViewerUXML;
|
||||
public VisualTreeAsset DebuggerBundleListViewerUXML;
|
||||
|
||||
// 构建报告
|
||||
public VisualTreeAsset AssetBundleReporterUXML;
|
||||
public VisualTreeAsset ReporterSummaryViewerUXML;
|
||||
public VisualTreeAsset ReporterAssetListViewerUXML;
|
||||
public VisualTreeAsset ReporterBundleListViewerUXML;
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4eff45040ac501b4fa978c46f72f2e64
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,35 +0,0 @@
|
|||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class YooAssetEditorSettingsData
|
||||
{
|
||||
private static YooAssetEditorSettings _setting = null;
|
||||
public static YooAssetEditorSettings Setting
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_setting == null)
|
||||
LoadEditorSettingData();
|
||||
return _setting;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载配置文件
|
||||
/// </summary>
|
||||
private static void LoadEditorSettingData()
|
||||
{
|
||||
var guids = AssetDatabase.FindAssets($"t:{nameof(YooAssetEditorSettings)}", new[] { "Assets", "Packages" });
|
||||
if (guids.Length == 0)
|
||||
throw new System.Exception($"Not found {nameof(YooAssetEditorSettings)} file !");
|
||||
if (guids.Length != 1)
|
||||
throw new System.Exception($"Found multiple {nameof(YooAssetEditorSettings)} files !");
|
||||
|
||||
string settingFilePath = AssetDatabase.GUIDToAssetPath(guids[0]);
|
||||
_setting = AssetDatabase.LoadAssetAtPath<YooAssetEditorSettings>(settingFilePath);
|
||||
Debug.Log($"Load {nameof(YooAssetEditorSettings)}.asset ok !");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e39f1b67d310bb54e8b1220bcf06afc4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,36 +0,0 @@
|
|||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class YooAssetEditorSettingsHelper
|
||||
{
|
||||
/// <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)
|
||||
throw new System.Exception($"Found multiple {settingType.Name} files !");
|
||||
|
||||
string filePath = AssetDatabase.GUIDToAssetPath(guids[0]);
|
||||
var setting = AssetDatabase.LoadAssetAtPath<TSetting>(filePath);
|
||||
return setting;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue