Optimized the loading method of the setting file

优化了配置文件的加载方式和途径。
pull/13/head
hevinci 2022-05-13 23:53:19 +08:00
parent a054740de6
commit 8dc0560537
38 changed files with 308 additions and 265 deletions

View File

@ -24,22 +24,7 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
private static void LoadSettingData() private static void LoadSettingData()
{ {
// 加载配置文件 _setting = YooAssetEditorSettingsHelper.LoadSettingData<AssetBundleBuilderSetting>();
string settingFilePath = $"{EditorTools.GetYooAssetSettingPath()}/{nameof(AssetBundleBuilderSetting)}.asset";
_setting = AssetDatabase.LoadAssetAtPath<AssetBundleBuilderSetting>(settingFilePath);
if (_setting == null)
{
Debug.LogWarning($"Create new {nameof(AssetBundleBuilderSetting)}.asset : {settingFilePath}");
_setting = ScriptableObject.CreateInstance<AssetBundleBuilderSetting>();
EditorTools.CreateFileDirectory(settingFilePath);
AssetDatabase.CreateAsset(Setting, settingFilePath);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
else
{
Debug.Log($"Load {nameof(AssetBundleBuilderSetting)}.asset ok");
}
} }
/// <summary> /// <summary>

View File

@ -31,22 +31,20 @@ namespace YooAsset.Editor
private Toggle _appendExtensionToggle; private Toggle _appendExtensionToggle;
public void CreateGUI() public void CreateGUI()
{
try
{ {
VisualElement root = this.rootVisualElement; VisualElement root = this.rootVisualElement;
// 加载布局文件 // 加载布局文件
string rootPath = EditorTools.GetYooAssetSourcePath(); var visualAsset = YooAssetEditorSettingsData.Setting.AssetBundleBuilderUXML;
string uxml = $"{rootPath}/Editor/AssetBundleBuilder/{nameof(AssetBundleBuilderWindow)}.uxml";
var visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
if (visualAsset == null) if (visualAsset == null)
{ {
Debug.LogError($"Not found {nameof(AssetBundleBuilderWindow)}.uxml : {uxml}"); Debug.LogError($"Not found {nameof(AssetBundleBuilderWindow)}.uxml in settings.");
return; return;
} }
visualAsset.CloneTree(root); visualAsset.CloneTree(root);
try
{
_buildTarget = EditorUserBuildSettings.activeBuildTarget; _buildTarget = EditorUserBuildSettings.activeBuildTarget;
_encryptionServicesClassTypes = GetEncryptionServicesClassTypes(); _encryptionServicesClassTypes = GetEncryptionServicesClassTypes();
_encryptionServicesClassNames = _encryptionServicesClassTypes.Select(t => t.FullName).ToList(); _encryptionServicesClassNames = _encryptionServicesClassTypes.Select(t => t.FullName).ToList();

View File

@ -105,22 +105,7 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
private static void LoadSettingData() private static void LoadSettingData()
{ {
// 加载配置文件 _setting = YooAssetEditorSettingsHelper.LoadSettingData<AssetBundleCollectorSetting>();
string settingFilePath = $"{EditorTools.GetYooAssetSettingPath()}/{nameof(AssetBundleCollectorSetting)}.asset";
_setting = AssetDatabase.LoadAssetAtPath<AssetBundleCollectorSetting>(settingFilePath);
if (_setting == null)
{
Debug.LogWarning($"Create new {nameof(AssetBundleCollectorSetting)}.asset : {settingFilePath}");
_setting = ScriptableObject.CreateInstance<AssetBundleCollectorSetting>();
EditorTools.CreateFileDirectory(settingFilePath);
AssetDatabase.CreateAsset(Setting, settingFilePath);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
else
{
Debug.Log($"Load {nameof(AssetBundleCollectorSetting)}.asset ok");
}
// IPackRule // IPackRule
{ {

View File

@ -37,8 +37,6 @@ namespace YooAsset.Editor
Undo.undoRedoPerformed -= RefreshWindow; Undo.undoRedoPerformed -= RefreshWindow;
Undo.undoRedoPerformed += RefreshWindow; Undo.undoRedoPerformed += RefreshWindow;
VisualElement root = this.rootVisualElement;
_collectorTypeList = new List<string>() _collectorTypeList = new List<string>()
{ {
$"{nameof(ECollectorType.MainAssetCollector)}", $"{nameof(ECollectorType.MainAssetCollector)}",
@ -49,19 +47,19 @@ namespace YooAsset.Editor
_packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames(); _packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames();
_filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames(); _filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames();
try
{
VisualElement root = this.rootVisualElement;
// 加载布局文件 // 加载布局文件
string rootPath = EditorTools.GetYooAssetSourcePath(); var visualAsset = YooAssetEditorSettingsData.Setting.AssetBundleCollectorUXML;
string uxml = $"{rootPath}/Editor/AssetBundleCollector/{nameof(AssetBundleCollectorWindow)}.uxml";
var visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
if (visualAsset == null) if (visualAsset == null)
{ {
Debug.LogError($"Not found {nameof(AssetBundleCollectorWindow)}.uxml : {uxml}"); Debug.LogError($"Not found {nameof(AssetBundleCollectorWindow)}.uxml in settings.");
return; return;
} }
visualAsset.CloneTree(root); visualAsset.CloneTree(root);
try
{
// 导入导出按钮 // 导入导出按钮
var exportBtn = root.Q<Button>("ExportButton"); var exportBtn = root.Q<Button>("ExportButton");
exportBtn.clicked += ExportBtn_clicked; exportBtn.clicked += ExportBtn_clicked;

View File

@ -1,4 +1,5 @@
#if UNITY_2019_4_OR_NEWER #if UNITY_2019_4_OR_NEWER
using System;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using UnityEngine.UIElements; using UnityEngine.UIElements;
@ -37,8 +38,8 @@ namespace YooAsset.Editor
} }
private ToolbarMenu _viewModeMenu; private ToolbarMenu _viewModeMenu;
private AssetListDebuggerViewer _assetListViewer; private DebuggerAssetListViewer _assetListViewer;
private BundleListDebuggerViewer _bundleListViewer; private DebuggerBundleListViewer _bundleListViewer;
private EViewMode _viewMode; private EViewMode _viewMode;
private readonly DebugReport _debugReport = new DebugReport(); private readonly DebugReport _debugReport = new DebugReport();
@ -46,16 +47,16 @@ namespace YooAsset.Editor
public void CreateGUI() public void CreateGUI()
{
try
{ {
VisualElement root = rootVisualElement; VisualElement root = rootVisualElement;
// 加载布局文件 // 加载布局文件
string rootPath = EditorTools.GetYooAssetSourcePath(); var visualAsset = YooAssetEditorSettingsData.Setting.AssetBundleDebuggerUXML;
string uxml = $"{rootPath}/Editor/AssetBundleDebugger/{nameof(AssetBundleDebuggerWindow)}.uxml";
var visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
if (visualAsset == null) if (visualAsset == null)
{ {
Debug.LogError($"Not found {nameof(AssetBundleDebuggerWindow)}.uxml : {uxml}"); Debug.LogError($"Not found {nameof(AssetBundleDebuggerWindow)}.uxml in settings.");
return; return;
} }
visualAsset.CloneTree(root); visualAsset.CloneTree(root);
@ -75,11 +76,11 @@ namespace YooAsset.Editor
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange); searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
// 加载视图 // 加载视图
_assetListViewer = new AssetListDebuggerViewer(); _assetListViewer = new DebuggerAssetListViewer();
_assetListViewer.InitViewer(); _assetListViewer.InitViewer();
// 加载视图 // 加载视图
_bundleListViewer = new BundleListDebuggerViewer(); _bundleListViewer = new DebuggerBundleListViewer();
_bundleListViewer.InitViewer(); _bundleListViewer.InitViewer();
// 显示视图 // 显示视图
@ -87,6 +88,11 @@ namespace YooAsset.Editor
_viewModeMenu.text = EViewMode.AssetView.ToString(); _viewModeMenu.text = EViewMode.AssetView.ToString();
_assetListViewer.AttachParent(root); _assetListViewer.AttachParent(root);
} }
catch(Exception e)
{
Debug.LogError(e.ToString());
}
}
private void SampleBtn_onClick() private void SampleBtn_onClick()
{ {
YooAssets.GetDebugReport(_debugReport); YooAssets.GetDebugReport(_debugReport);

View File

@ -9,7 +9,7 @@ using UnityEngine.UIElements;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
internal class AssetListDebuggerViewer internal class DebuggerAssetListViewer
{ {
private VisualTreeAsset _visualAsset; private VisualTreeAsset _visualAsset;
private TemplateContainer _root; private TemplateContainer _root;
@ -24,12 +24,10 @@ namespace YooAsset.Editor
public void InitViewer() public void InitViewer()
{ {
// 加载布局文件 // 加载布局文件
string rootPath = EditorTools.GetYooAssetSourcePath(); _visualAsset = YooAssetEditorSettingsData.Setting.DebuggerAssetListViewerUXML;
string uxml = $"{rootPath}/Editor/AssetBundleDebugger/VisualViewers/{nameof(AssetListDebuggerViewer)}.uxml";
_visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
if (_visualAsset == null) if (_visualAsset == null)
{ {
Debug.LogError($"Not found {nameof(AssetListDebuggerViewer)}.uxml : {uxml}"); Debug.LogError($"Not found {nameof(DebuggerAssetListViewer)}.uxml in settings.");
return; return;
} }
_root = _visualAsset.CloneTree(); _root = _visualAsset.CloneTree();

View File

@ -9,7 +9,7 @@ using UnityEngine.UIElements;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
internal class BundleListDebuggerViewer internal class DebuggerBundleListViewer
{ {
private VisualTreeAsset _visualAsset; private VisualTreeAsset _visualAsset;
private TemplateContainer _root; private TemplateContainer _root;
@ -24,12 +24,10 @@ namespace YooAsset.Editor
public void InitViewer() public void InitViewer()
{ {
// 加载布局文件 // 加载布局文件
string rootPath = EditorTools.GetYooAssetSourcePath(); _visualAsset = YooAssetEditorSettingsData.Setting.DebuggerBundleListViewerUXML;
string uxml = $"{rootPath}/Editor/AssetBundleDebugger/VisualViewers/{nameof(BundleListDebuggerViewer)}.uxml";
_visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
if (_visualAsset == null) if (_visualAsset == null)
{ {
Debug.LogError($"Not found {nameof(BundleListDebuggerViewer)}.uxml : {uxml}"); Debug.LogError($"Not found {nameof(DebuggerBundleListViewer)}.uxml in settings.");
return; return;
} }
_root = _visualAsset.CloneTree(); _root = _visualAsset.CloneTree();

View File

@ -1,4 +1,5 @@
#if UNITY_2019_4_OR_NEWER #if UNITY_2019_4_OR_NEWER
using System;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using UnityEditor.UIElements; using UnityEditor.UIElements;
@ -37,9 +38,9 @@ namespace YooAsset.Editor
} }
private ToolbarMenu _viewModeMenu; private ToolbarMenu _viewModeMenu;
private SummaryReporterViewer _summaryViewer; private ReporterSummaryViewer _summaryViewer;
private AssetListReporterViewer _assetListViewer; private ReporterAssetListViewer _assetListViewer;
private BundleListReporterViewer _bundleListViewer; private ReporterBundleListViewer _bundleListViewer;
private EViewMode _viewMode; private EViewMode _viewMode;
private BuildReport _buildReport; private BuildReport _buildReport;
@ -48,16 +49,16 @@ namespace YooAsset.Editor
public void CreateGUI() public void CreateGUI()
{
try
{ {
VisualElement root = this.rootVisualElement; VisualElement root = this.rootVisualElement;
// 加载布局文件 // 加载布局文件
string rootPath = EditorTools.GetYooAssetSourcePath(); var visualAsset = YooAssetEditorSettingsData.Setting.AssetBundleReporterUXML;
string uxml = $"{rootPath}/Editor/AssetBundleReporter/{nameof(AssetBundleReporterWindow)}.uxml";
var visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
if (visualAsset == null) if (visualAsset == null)
{ {
Debug.LogError($"Not found {nameof(AssetBundleReporterWindow)}.uxml : {uxml}"); Debug.LogError($"Not found {nameof(AssetBundleReporterWindow)}.uxml in settings.");
return; return;
} }
visualAsset.CloneTree(root); visualAsset.CloneTree(root);
@ -77,15 +78,15 @@ namespace YooAsset.Editor
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange); searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
// 加载视图 // 加载视图
_summaryViewer = new SummaryReporterViewer(); _summaryViewer = new ReporterSummaryViewer();
_summaryViewer.InitViewer(); _summaryViewer.InitViewer();
// 加载视图 // 加载视图
_assetListViewer = new AssetListReporterViewer(); _assetListViewer = new ReporterAssetListViewer();
_assetListViewer.InitViewer(); _assetListViewer.InitViewer();
// 加载视图 // 加载视图
_bundleListViewer = new BundleListReporterViewer(); _bundleListViewer = new ReporterBundleListViewer();
_bundleListViewer.InitViewer(); _bundleListViewer.InitViewer();
// 显示视图 // 显示视图
@ -93,6 +94,11 @@ namespace YooAsset.Editor
_viewModeMenu.text = EViewMode.Summary.ToString(); _viewModeMenu.text = EViewMode.Summary.ToString();
_summaryViewer.AttachParent(root); _summaryViewer.AttachParent(root);
} }
catch (Exception e)
{
Debug.LogError(e.ToString());
}
}
public void OnDestroy() public void OnDestroy()
{ {
AssetBundleRecorder.UnloadAll(); AssetBundleRecorder.UnloadAll();

View File

@ -9,7 +9,7 @@ using UnityEngine.UIElements;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
internal class AssetListReporterViewer internal class ReporterAssetListViewer
{ {
private enum ESortMode private enum ESortMode
{ {
@ -38,12 +38,10 @@ namespace YooAsset.Editor
public void InitViewer() public void InitViewer()
{ {
// 加载布局文件 // 加载布局文件
string rootPath = EditorTools.GetYooAssetSourcePath(); _visualAsset = YooAssetEditorSettingsData.Setting.ReporterAssetListViewerUXML;
string uxml = $"{rootPath}/Editor/AssetBundleReporter/VisualViewers/{nameof(AssetListReporterViewer)}.uxml";
_visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
if (_visualAsset == null) if (_visualAsset == null)
{ {
Debug.LogError($"Not found {nameof(AssetListReporterViewer)}.uxml : {uxml}"); Debug.LogError($"Not found {nameof(ReporterAssetListViewer)}.uxml in settings.");
return; return;
} }

View File

@ -10,7 +10,7 @@ using UnityEngine.UIElements;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
internal class BundleListReporterViewer internal class ReporterBundleListViewer
{ {
private enum ESortMode private enum ESortMode
{ {
@ -42,12 +42,10 @@ namespace YooAsset.Editor
public void InitViewer() public void InitViewer()
{ {
// 加载布局文件 // 加载布局文件
string rootPath = EditorTools.GetYooAssetSourcePath(); _visualAsset = YooAssetEditorSettingsData.Setting.ReporterBundleListViewerUXML;
string uxml = $"{rootPath}/Editor/AssetBundleReporter/VisualViewers/{nameof(BundleListReporterViewer)}.uxml";
_visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
if (_visualAsset == null) if (_visualAsset == null)
{ {
Debug.LogError($"Not found {nameof(BundleListReporterViewer)}.uxml : {uxml}"); Debug.LogError($"Not found {nameof(ReporterBundleListViewer)}.uxml in settings.");
return; return;
} }

View File

@ -9,7 +9,7 @@ using UnityEngine.UIElements;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
internal class SummaryReporterViewer internal class ReporterSummaryViewer
{ {
private class ItemWrapper private class ItemWrapper
{ {
@ -37,12 +37,10 @@ namespace YooAsset.Editor
public void InitViewer() public void InitViewer()
{ {
// 加载布局文件 // 加载布局文件
string rootPath = EditorTools.GetYooAssetSourcePath(); _visualAsset = YooAssetEditorSettingsData.Setting.ReporterSummaryViewerUXML;
string uxml = $"{rootPath}/Editor/AssetBundleReporter/VisualViewers/{nameof(SummaryReporterViewer)}.uxml";
_visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
if (_visualAsset == null) if (_visualAsset == null)
{ {
Debug.LogError($"Not found {nameof(SummaryReporterViewer)}.uxml : {uxml}"); Debug.LogError($"Not found {nameof(ReporterSummaryViewer)}.uxml in settings.");
return; return;
} }
_root = _visualAsset.CloneTree(); _root = _visualAsset.CloneTree();

View File

@ -1,6 +1,7 @@
 
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
#if UNITY_2019 #if UNITY_2019
public static partial class UnityEngine_UIElements_ListView_Extension public static partial class UnityEngine_UIElements_ListView_Extension
{ {
@ -20,4 +21,5 @@ namespace YooAsset.Editor
} }
} }
#endif #endif
} }

View File

@ -462,9 +462,6 @@ namespace YooAsset.Editor
#endregion #endregion
#region 路径 #region 路径
private static string YooAssetSourcePath;
private static string YooAssetSettingPath;
/// <summary> /// <summary>
/// 获取规范的路径 /// 获取规范的路径
/// </summary> /// </summary>
@ -473,83 +470,6 @@ namespace YooAsset.Editor
return path.Replace('\\', '/').Replace("\\", "/"); //替换为Linux路径格式 return path.Replace('\\', '/').Replace("\\", "/"); //替换为Linux路径格式
} }
/// <summary>
/// 获取资源框架源码路径
/// </summary>
public static string GetYooAssetSourcePath()
{
if (string.IsNullOrEmpty(YooAssetSourcePath) == false)
{
if (Directory.Exists(YooAssetSourcePath))
return YooAssetSourcePath;
}
// 从Pakcages目录下搜索
string packagesPath = "Packages/com.tuyoogame.yooasset/README.md";
var obj = AssetDatabase.LoadAssetAtPath(packagesPath, typeof(TextAsset));
if (obj != null)
{
YooAssetSourcePath = "Packages/com.tuyoogame.yooasset/";
return YooAssetSourcePath;
}
// 从Assets目录下搜索
string[] allDirectorys = Directory.GetDirectories(Application.dataPath, "YooAsset", SearchOption.AllDirectories);
if (allDirectorys.Length == 0)
{
Debug.LogError("Not found YooAsset package !");
return string.Empty;
}
string targetDirectory = string.Empty;
foreach (var directory in allDirectorys)
{
string asmdefFilePath = $"{directory}/Editor/YooAsset.Editor.asmdef";
if (File.Exists(asmdefFilePath))
{
targetDirectory = directory;
break;
}
}
if (string.IsNullOrEmpty(targetDirectory))
{
Debug.LogError("Should never get here !");
return string.Empty;
}
YooAssetSourcePath = AbsolutePathToAssetPath(targetDirectory);
return YooAssetSourcePath;
}
/// <summary>
/// 获取资源框架配置路径
/// </summary>
public static string GetYooAssetSettingPath()
{
if (string.IsNullOrEmpty(YooAssetSettingPath) == false)
{
if (Directory.Exists(YooAssetSettingPath))
return YooAssetSettingPath;
}
// 从Assets目录下搜索
string[] allDirectorys = Directory.GetDirectories(Application.dataPath, "YooAssetSetting", SearchOption.AllDirectories);
if (allDirectorys.Length == 0)
{
YooAssetSettingPath = "Assets/YooAssetSetting";
return YooAssetSettingPath;
}
string targetDirectory = allDirectorys[0];
if (allDirectorys.Length != 1)
{
Debug.LogError("Found multiple YooAssetSetting folder !");
}
YooAssetSettingPath = AbsolutePathToAssetPath(targetDirectory);
return YooAssetSettingPath;
}
/// <summary> /// <summary>
/// 获取项目工程路径 /// 获取项目工程路径
/// </summary> /// </summary>
@ -630,7 +550,6 @@ namespace YooAsset.Editor
else else
return content.Substring(startIndex + key.Length); return content.Substring(startIndex + key.Length);
} }
#endregion #endregion
} }
} }

View File

@ -25,22 +25,7 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
private static void LoadSettingData() private static void LoadSettingData()
{ {
// 加载配置文件 _setting = YooAssetEditorSettingsHelper.LoadSettingData<ShaderVariantCollectorSetting>();
string settingFilePath = $"{EditorTools.GetYooAssetSettingPath()}/{nameof(ShaderVariantCollectorSetting)}.asset";
_setting = AssetDatabase.LoadAssetAtPath<ShaderVariantCollectorSetting>(settingFilePath);
if (_setting == null)
{
Debug.LogWarning($"Create new {nameof(ShaderVariantCollectorSetting)}.asset : {settingFilePath}");
_setting = ScriptableObject.CreateInstance<ShaderVariantCollectorSetting>();
EditorTools.CreateFileDirectory(settingFilePath);
AssetDatabase.CreateAsset(Setting, settingFilePath);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
else
{
Debug.Log($"Load {nameof(ShaderVariantCollectorSetting)}.asset ok");
}
} }
/// <summary> /// <summary>

View File

@ -0,0 +1,32 @@
%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}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b0b43f68477734743a5f2fc507b5bda6
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,25 @@
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;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4eff45040ac501b4fa978c46f72f2e64
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,35 @@
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 !");
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e39f1b67d310bb54e8b1220bcf06afc4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,36 @@
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;
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d2d701e695ac3fe4cbe25d43dde05944
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -28,7 +28,7 @@ namespace YooAsset
} }
else else
{ {
YooLogger.Log("YooAsset use custom settings."); YooLogger.Log("YooAsset use user settings.");
} }
} }