mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-24 17:50:15 +00:00
Update AssetBundleBuilder
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
@@ -27,11 +28,21 @@ namespace YooAsset.Editor
|
||||
// 构建参数
|
||||
private int _buildVersion;
|
||||
private BuildTarget _buildTarget;
|
||||
private ECompressOption _compressOption = ECompressOption.Uncompressed;
|
||||
private ECompressOption _compressOption;
|
||||
private bool _appendExtension = false;
|
||||
private bool _forceRebuild = false;
|
||||
private string _buildinTags = string.Empty;
|
||||
|
||||
// 加密类相关
|
||||
private List<Type> _encryptionServicesClassTypes;
|
||||
private string[] _encryptionServicesClassNames;
|
||||
private int _encryptionServicesSelectIndex = -1;
|
||||
|
||||
// 冗余类相关
|
||||
private List<Type> _redundancyServicesClassTypes;
|
||||
private string[] _redundancyServicesClassNames;
|
||||
private int _redundancyServicesSelectIndex = -1;
|
||||
|
||||
// GUI相关
|
||||
private bool _isInit = false;
|
||||
private GUIStyle _centerStyle;
|
||||
@@ -52,8 +63,12 @@ namespace YooAsset.Editor
|
||||
EditorGUILayout.LabelField("Build Output", pipelineOutputDirectory);
|
||||
|
||||
// 构建参数
|
||||
_buildVersion = EditorGUILayout.IntField("Build Version", _buildVersion, GUILayout.MaxWidth(250));
|
||||
_compressOption = (ECompressOption)EditorGUILayout.EnumPopup("Compression", _compressOption, GUILayout.MaxWidth(250));
|
||||
_buildVersion = EditorGUILayout.IntField("Build Version", _buildVersion, GUILayout.MaxWidth(300));
|
||||
_compressOption = (ECompressOption)EditorGUILayout.EnumPopup("Compression", _compressOption, GUILayout.MaxWidth(300));
|
||||
if (_encryptionServicesClassNames.Length > 0)
|
||||
_encryptionServicesSelectIndex = EditorGUILayout.Popup("Encryption Services", _encryptionServicesSelectIndex, _encryptionServicesClassNames, GUILayout.MaxWidth(300));
|
||||
if (_redundancyServicesClassNames.Length > 0)
|
||||
_redundancyServicesSelectIndex = EditorGUILayout.Popup("Redundancy Services", _redundancyServicesSelectIndex, _redundancyServicesClassNames, GUILayout.MaxWidth(300));
|
||||
_appendExtension = GUILayout.Toggle(_appendExtension, "Append Extension", GUILayout.MaxWidth(120));
|
||||
_forceRebuild = GUILayout.Toggle(_forceRebuild, "Force Rebuild", GUILayout.MaxWidth(120));
|
||||
if (_forceRebuild)
|
||||
@@ -104,6 +119,12 @@ namespace YooAsset.Editor
|
||||
_buildVersion = appVersion.Revision;
|
||||
_buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
|
||||
_encryptionServicesClassTypes = GetEncryptionServicesClassTypes();
|
||||
_encryptionServicesClassNames = _encryptionServicesClassTypes.Select(t => t.FullName).ToArray();
|
||||
|
||||
_redundancyServicesClassTypes = GetRedundancyServicesClassTypes();
|
||||
_redundancyServicesClassNames = _redundancyServicesClassTypes.Select(t => t.FullName).ToArray();
|
||||
|
||||
// 读取配置
|
||||
LoadSettingsFromPlayerPrefs();
|
||||
}
|
||||
@@ -119,6 +140,8 @@ namespace YooAsset.Editor
|
||||
buildParameters.OutputRoot = defaultOutputRoot;
|
||||
buildParameters.BuildTarget = _buildTarget;
|
||||
buildParameters.BuildVersion = _buildVersion;
|
||||
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
||||
buildParameters.RedundancyServices = CreateRedundancyServicesInstance();
|
||||
buildParameters.CompressOption = _compressOption;
|
||||
buildParameters.AppendFileExtension = _appendExtension;
|
||||
buildParameters.ForceRebuild = _forceRebuild;
|
||||
@@ -126,6 +149,32 @@ namespace YooAsset.Editor
|
||||
_assetBuilder.Run(buildParameters);
|
||||
}
|
||||
|
||||
private List<Type> GetEncryptionServicesClassTypes()
|
||||
{
|
||||
List<Type> classTypes = AssemblyUtility.GetAssignableTypes(AssemblyUtility.UnityDefaultAssemblyEditorName, typeof(IEncryptionServices));
|
||||
return classTypes;
|
||||
}
|
||||
private IEncryptionServices CreateEncryptionServicesInstance()
|
||||
{
|
||||
if (_encryptionServicesSelectIndex < 0)
|
||||
return null;
|
||||
var classType = _encryptionServicesClassTypes[_encryptionServicesSelectIndex];
|
||||
return (IEncryptionServices)Activator.CreateInstance(classType);
|
||||
}
|
||||
|
||||
private List<Type> GetRedundancyServicesClassTypes()
|
||||
{
|
||||
List<Type> classTypes = AssemblyUtility.GetAssignableTypes(AssemblyUtility.UnityDefaultAssemblyEditorName, typeof(IRedundancyServices));
|
||||
return classTypes;
|
||||
}
|
||||
private IRedundancyServices CreateRedundancyServicesInstance()
|
||||
{
|
||||
if (_redundancyServicesSelectIndex < 0)
|
||||
return null;
|
||||
var classType = _redundancyServicesClassTypes[_redundancyServicesSelectIndex];
|
||||
return (IRedundancyServices)Activator.CreateInstance(classType);
|
||||
}
|
||||
|
||||
#region 配置相关
|
||||
private const string StrEditorCompressOption = "StrEditorCompressOption";
|
||||
private const string StrEditorAppendExtension = "StrEditorAppendExtension";
|
||||
|
||||
Reference in New Issue
Block a user