diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSetting.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSetting.cs
new file mode 100644
index 0000000..a902fba
--- /dev/null
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSetting.cs
@@ -0,0 +1,38 @@
+using System;
+using UnityEngine;
+
+namespace YooAsset.Editor
+{
+ public class AssetBundleBuilderSetting : ScriptableObject
+ {
+ ///
+ /// 构建版本号
+ ///
+ public int BuildVersion = 0;
+
+ ///
+ /// 压缩方式
+ ///
+ public ECompressOption CompressOption = ECompressOption.LZ4;
+
+ ///
+ /// 加密类名称
+ ///
+ public string EncyptionClassName = string.Empty;
+
+ ///
+ /// 附加后缀格式
+ ///
+ public bool AppendExtension = false;
+
+ ///
+ /// 强制构建
+ ///
+ public bool ForceRebuild = false;
+
+ ///
+ /// 内置标签
+ ///
+ public string BuildTags = string.Empty;
+ }
+}
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSetting.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSetting.cs.meta
new file mode 100644
index 0000000..a8a559c
--- /dev/null
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSetting.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 09788b4733bab2d4792fdd5d28e7653c
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSettingData.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSettingData.cs
new file mode 100644
index 0000000..31e51f9
--- /dev/null
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSettingData.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEditor;
+
+namespace YooAsset.Editor
+{
+ public class AssetBundleBuilderSettingData
+ {
+ private static AssetBundleBuilderSetting _setting = null;
+ public static AssetBundleBuilderSetting Setting
+ {
+ get
+ {
+ if (_setting == null)
+ LoadSettingData();
+ return _setting;
+ }
+ }
+
+ ///
+ /// 加载配置文件
+ ///
+ private static void LoadSettingData()
+ {
+ // 加载配置文件
+ _setting = AssetDatabase.LoadAssetAtPath(EditorDefine.AssetBundleBuilderSettingFilePath);
+ if (_setting == null)
+ {
+ Debug.LogWarning($"Create new {nameof(AssetBundleBuilderSetting)}.asset : {EditorDefine.AssetBundleBuilderSettingFilePath}");
+ _setting = ScriptableObject.CreateInstance();
+ EditorTools.CreateFileDirectory(EditorDefine.AssetBundleBuilderSettingFilePath);
+ AssetDatabase.CreateAsset(Setting, EditorDefine.AssetBundleBuilderSettingFilePath);
+ AssetDatabase.SaveAssets();
+ AssetDatabase.Refresh();
+ }
+ else
+ {
+ Debug.Log($"Load {nameof(AssetBundleBuilderSetting)}.asset ok");
+ }
+ }
+
+ ///
+ /// 存储文件
+ ///
+ public static void SaveFile()
+ {
+ if (Setting != null)
+ {
+ EditorUtility.SetDirty(Setting);
+ AssetDatabase.SaveAssets();
+ Debug.Log($"{nameof(AssetBundleBuilderSetting)}.asset is saved!");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSettingData.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSettingData.cs.meta
new file mode 100644
index 0000000..4d7c62e
--- /dev/null
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderSettingData.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 24698266f028e4a47bb88f091fd64547
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs
index 2f9a638..b1af25d 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs
@@ -61,23 +61,43 @@ namespace YooAsset.Editor
_buildOutputTxt.SetEnabled(false);
// 构建版本
- var appVersion = new Version(Application.version);
_buildVersionField = root.Q("BuildVersion");
- _buildVersionField.SetValueWithoutNotify(appVersion.Revision);
+ _buildVersionField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildVersion);
+ _buildVersionField.RegisterValueChangedCallback(evt =>
+ {
+ AssetBundleBuilderSettingData.Setting.BuildVersion = _buildVersionField.value;
+ });
// 压缩方式
_compressionField = root.Q("Compression");
- _compressionField.Init(ECompressOption.LZ4);
- _compressionField.SetValueWithoutNotify(ECompressOption.LZ4);
+ _compressionField.Init(AssetBundleBuilderSettingData.Setting.CompressOption);
+ _compressionField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.CompressOption);
_compressionField.style.width = 300;
+ _compressionField.RegisterValueChangedCallback(evt =>
+ {
+ AssetBundleBuilderSettingData.Setting.CompressOption = (ECompressOption)_compressionField.value;
+ });
// 加密方法
var encryptionContainer = root.Q("EncryptionContainer");
if (_encryptionServicesClassNames.Count > 0)
{
- _encryptionField = new PopupField(_encryptionServicesClassNames, 0);
+ int defaultIndex = 0;
+ for (int index = 0; index < _encryptionServicesClassNames.Count; index++)
+ {
+ if (_encryptionServicesClassNames[index] == AssetBundleBuilderSettingData.Setting.EncyptionClassName)
+ {
+ defaultIndex = index;
+ break;
+ }
+ }
+ _encryptionField = new PopupField(_encryptionServicesClassNames, defaultIndex);
_encryptionField.label = "Encryption";
_encryptionField.style.width = 300;
+ _encryptionField.RegisterValueChangedCallback(evt =>
+ {
+ AssetBundleBuilderSettingData.Setting.EncyptionClassName = _encryptionField.value;
+ });
encryptionContainer.Add(_encryptionField);
}
else
@@ -90,18 +110,29 @@ namespace YooAsset.Editor
// 附加后缀格式
_appendExtensionToggle = root.Q("AppendExtension");
+ _appendExtensionToggle.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.AppendExtension);
+ _appendExtensionToggle.RegisterValueChangedCallback(evt =>
+ {
+ AssetBundleBuilderSettingData.Setting.AppendExtension = _appendExtensionToggle.value;
+ });
// 强制构建
_forceRebuildToggle = root.Q("ForceRebuild");
- _forceRebuildToggle.SetValueWithoutNotify(true);
+ _forceRebuildToggle.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.ForceRebuild);
_forceRebuildToggle.RegisterValueChangedCallback(evt =>
{
+ AssetBundleBuilderSettingData.Setting.ForceRebuild = _forceRebuildToggle.value;
_buildTagsTxt.SetEnabled(_forceRebuildToggle.value);
});
// 内置标签
_buildTagsTxt = root.Q("BuildinTags");
_buildTagsTxt.SetEnabled(_forceRebuildToggle.value);
+ _buildTagsTxt.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildTags);
+ _buildTagsTxt.RegisterValueChangedCallback(evt =>
+ {
+ AssetBundleBuilderSettingData.Setting.BuildTags = _buildTagsTxt.value;
+ });
// 构建按钮
var buildButton = root.Q