Compare commits

..

5 Commits

Author SHA1 Message Date
hevinci 19c46a2f60 update runtime code
1. 移除了LoadSceneAsync方法里的activateOnLoad参数
2023-06-27 15:04:47 +08:00
hevinci f54c8d6da4 update editor code
1. 移除了BuildParameters.AutoAnalyzeRedundancy字段
2. 移除了DefaultShareAssetPackRule
3. 新增了ZeroRedundancySharedPackRule
4. 新增了FullRedundancySharedPackRule
2023-06-27 14:18:54 +08:00
hevinci 84f9d1985e update editor code
1. IShareAssetPackRule重命名为ISharedPackRule
2. DefaultShareAssetPackRule重命名为DefaultSharedPackRule
2023-06-27 11:00:01 +08:00
hevinci 0b2a2bf97d update AssetBundleCollector 2023-06-27 10:40:09 +08:00
hevinci 561cf411ef update asset system 2023-06-27 10:28:16 +08:00
45 changed files with 161 additions and 159 deletions

View File

@ -275,8 +275,7 @@ namespace YooAsset.Editor
buildParameters.PackageName = AssetBundleBuilderSettingData.Setting.BuildPackage; buildParameters.PackageName = AssetBundleBuilderSettingData.Setting.BuildPackage;
buildParameters.PackageVersion = _buildVersionField.value; buildParameters.PackageVersion = _buildVersionField.value;
buildParameters.VerifyBuildingResult = true; buildParameters.VerifyBuildingResult = true;
buildParameters.AutoAnalyzeRedundancy = true; buildParameters.SharedPackRule = new ZeroRedundancySharedPackRule();
buildParameters.ShareAssetPackRule = new DefaultShareAssetPackRule();
buildParameters.EncryptionServices = CreateEncryptionServicesInstance(); buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption; buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption;
buildParameters.OutputNameStyle = AssetBundleBuilderSettingData.Setting.OutputNameStyle; buildParameters.OutputNameStyle = AssetBundleBuilderSettingData.Setting.OutputNameStyle;

View File

@ -164,7 +164,7 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 计算共享资源包的完整包名 /// 计算共享资源包的完整包名
/// </summary> /// </summary>
public void CalculateShareBundleName(IShareAssetPackRule packRule, bool uniqueBundleName, string packageName, string shadersBundleName) public void CalculateShareBundleName(ISharedPackRule sharedPackRule, bool uniqueBundleName, string packageName, string shadersBundleName)
{ {
if (CollectorType != ECollectorType.None) if (CollectorType != ECollectorType.None)
return; return;
@ -180,7 +180,7 @@ namespace YooAsset.Editor
{ {
if (_referenceBundleNames.Count > 1) if (_referenceBundleNames.Count > 1)
{ {
PackRuleResult packRuleResult = packRule.GetPackRuleResult(AssetPath); PackRuleResult packRuleResult = sharedPackRule.GetPackRuleResult(AssetPath);
BundleName = packRuleResult.GetShareBundleName(packageName, uniqueBundleName); BundleName = packRuleResult.GetShareBundleName(packageName, uniqueBundleName);
} }
else else
@ -196,12 +196,9 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public bool IsRedundancyAsset() public bool IsRedundancyAsset()
{ {
if (CollectorType != ECollectorType.None) if (HasBundleName())
return false; return false;
if (IsRawAsset)
throw new Exception("Should never get here !");
return _referenceBundleNames.Count > 1; return _referenceBundleNames.Count > 1;
} }

View File

@ -49,7 +49,7 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 参与构建的资源列表 /// 参与构建的资源列表
/// 注意:不包含零依赖资源 /// 注意:不包含零依赖资源和冗余资源
/// </summary> /// </summary>
public readonly List<BuildAssetInfo> AllMainAssets = new List<BuildAssetInfo>(); public readonly List<BuildAssetInfo> AllMainAssets = new List<BuildAssetInfo>();
@ -149,7 +149,15 @@ namespace YooAsset.Editor
} }
/// <summary> /// <summary>
/// 获取该资源包内的所有资源(包括零依赖资源) /// 获取构建的资源路径列表
/// </summary>
public string[] GetAllMainAssetPaths()
{
return AllMainAssets.Select(t => t.AssetPath).ToArray();
}
/// <summary>
/// 获取该资源包内的所有资源(包括零依赖资源和冗余资源)
/// </summary> /// </summary>
public List<string> GetAllBuiltinAssetPaths() public List<string> GetAllBuiltinAssetPaths()
{ {
@ -161,6 +169,7 @@ namespace YooAsset.Editor
continue; continue;
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos) foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
{ {
// 注意:依赖资源里只添加零依赖资源和冗余资源
if (dependAssetInfo.HasBundleName() == false) if (dependAssetInfo.HasBundleName() == false)
{ {
if (result.Contains(dependAssetInfo.AssetPath) == false) if (result.Contains(dependAssetInfo.AssetPath) == false)
@ -171,22 +180,6 @@ namespace YooAsset.Editor
return result; return result;
} }
/// <summary>
/// 获取构建的资源路径列表
/// </summary>
public string[] GetAllMainAssetPaths()
{
return AllMainAssets.Select(t => t.AssetPath).ToArray();
}
/// <summary>
/// 获取所有写入补丁清单的资源
/// </summary>
public BuildAssetInfo[] GetAllMainAssetInfos()
{
return AllMainAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
}
/// <summary> /// <summary>
/// 创建AssetBundleBuild类 /// 创建AssetBundleBuild类
/// </summary> /// </summary>
@ -200,6 +193,14 @@ namespace YooAsset.Editor
return build; return build;
} }
/// <summary>
/// 获取所有写入补丁清单的资源
/// </summary>
public BuildAssetInfo[] GetAllManifestAssetInfos()
{
return AllMainAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
}
/// <summary> /// <summary>
/// 创建PackageBundle类 /// 创建PackageBundle类
/// </summary> /// </summary>

View File

@ -77,15 +77,10 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public bool VerifyBuildingResult = false; public bool VerifyBuildingResult = false;
/// <summary>
/// 自动分析冗余资源
/// </summary>
public bool AutoAnalyzeRedundancy = true;
/// <summary> /// <summary>
/// 共享资源的打包规则 /// 共享资源的打包规则
/// </summary> /// </summary>
public IShareAssetPackRule ShareAssetPackRule = null; public ISharedPackRule SharedPackRule = null;
/// <summary> /// <summary>
/// 资源的加密接口 /// 资源的加密接口

View File

@ -74,14 +74,9 @@ namespace YooAsset.Editor
public bool UniqueBundleName; public bool UniqueBundleName;
/// <summary> /// <summary>
/// 自动分析冗余 /// 共享资源的打包规则类名
/// </summary> /// </summary>
public bool AutoAnalyzeRedundancy; public string SharedPackRuleClassName;
/// <summary>
/// 共享资源的打包类名称
/// </summary>
public string ShareAssetPackRuleClassName;
/// <summary> /// <summary>
/// 加密服务类名称 /// 加密服务类名称

View File

@ -139,7 +139,7 @@ namespace YooAsset.Editor
List<PackageAsset> result = new List<PackageAsset>(1000); List<PackageAsset> result = new List<PackageAsset>(1000);
foreach (var bundleInfo in buildMapContext.Collection) foreach (var bundleInfo in buildMapContext.Collection)
{ {
var assetInfos = bundleInfo.GetAllMainAssetInfos(); var assetInfos = bundleInfo.GetAllManifestAssetInfos();
foreach (var assetInfo in assetInfos) foreach (var assetInfo in assetInfos)
{ {
PackageAsset packageAsset = new PackageAsset(); PackageAsset packageAsset = new PackageAsset();

View File

@ -49,9 +49,8 @@ namespace YooAsset.Editor
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower; buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID; buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName; buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
buildReport.Summary.AutoAnalyzeRedundancy = buildParameters.AutoAnalyzeRedundancy; buildReport.Summary.SharedPackRuleClassName = buildParameters.SharedPackRule == null ?
buildReport.Summary.ShareAssetPackRuleClassName = buildParameters.ShareAssetPackRule == null ? "null" : buildParameters.SharedPackRule.GetType().FullName;
"null" : buildParameters.ShareAssetPackRule.GetType().FullName;
buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ? buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ?
"null" : buildParameters.EncryptionServices.GetType().FullName; "null" : buildParameters.EncryptionServices.GetType().FullName;
@ -161,7 +160,7 @@ namespace YooAsset.Editor
} }
/// <summary> /// <summary>
/// 获取该资源包内的所有资源(包括零依赖资源) /// 获取该资源包内的所有资源
/// </summary> /// </summary>
private List<string> GetAllBuiltinAssets(BuildMapContext buildMapContext, string bundleName) private List<string> GetAllBuiltinAssets(BuildMapContext buildMapContext, string bundleName)
{ {

View File

@ -26,10 +26,9 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public BuildMapContext CreateBuildMap(BuildParameters buildParameters) public BuildMapContext CreateBuildMap(BuildParameters buildParameters)
{ {
EBuildMode buildMode = buildParameters.BuildMode; var buildMode = buildParameters.BuildMode;
string packageName = buildParameters.PackageName; var packageName = buildParameters.PackageName;
IShareAssetPackRule sharePackRule = buildParameters.ShareAssetPackRule; var sharedPackRule = buildParameters.SharedPackRule;
bool autoAnalyzeRedundancy = buildParameters.AutoAnalyzeRedundancy;
Dictionary<string, BuildAssetInfo> allBuildAssetInfoDic = new Dictionary<string, BuildAssetInfo>(1000); Dictionary<string, BuildAssetInfo> allBuildAssetInfoDic = new Dictionary<string, BuildAssetInfo>(1000);
@ -100,34 +99,29 @@ namespace YooAsset.Editor
context.AssetFileCount = allBuildAssetInfoDic.Count; context.AssetFileCount = allBuildAssetInfoDic.Count;
context.Command = collectResult.Command; context.Command = collectResult.Command;
// 8. 计算共享的资源包名 // 8. 计算共享资源的包名
if (autoAnalyzeRedundancy) var command = collectResult.Command;
foreach (var buildAssetInfo in allBuildAssetInfoDic.Values)
{ {
var command = collectResult.Command; buildAssetInfo.CalculateShareBundleName(sharedPackRule, command.UniqueBundleName, command.PackageName, command.ShadersBundleName);
foreach (var buildAssetInfo in allBuildAssetInfoDic.Values)
{
buildAssetInfo.CalculateShareBundleName(sharePackRule, command.UniqueBundleName, command.PackageName, command.ShadersBundleName);
}
} }
else
// 9. 记录冗余资源
foreach (var buildAssetInfo in allBuildAssetInfoDic.Values)
{ {
// 记录冗余资源 if (buildAssetInfo.IsRedundancyAsset())
foreach (var buildAssetInfo in allBuildAssetInfoDic.Values)
{ {
if (buildAssetInfo.IsRedundancyAsset()) var redundancyInfo = new ReportRedundancyInfo();
{ redundancyInfo.AssetPath = buildAssetInfo.AssetPath;
var redundancyInfo = new ReportRedundancyInfo(); redundancyInfo.AssetType = AssetDatabase.GetMainAssetTypeAtPath(buildAssetInfo.AssetPath).Name;
redundancyInfo.AssetPath = buildAssetInfo.AssetPath; redundancyInfo.AssetGUID = AssetDatabase.AssetPathToGUID(buildAssetInfo.AssetPath);
redundancyInfo.AssetType = AssetDatabase.GetMainAssetTypeAtPath(buildAssetInfo.AssetPath).Name; redundancyInfo.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetPath);
redundancyInfo.AssetGUID = AssetDatabase.AssetPathToGUID(buildAssetInfo.AssetPath); redundancyInfo.Number = buildAssetInfo.GetReferenceBundleCount();
redundancyInfo.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetPath); context.RedundancyInfos.Add(redundancyInfo);
redundancyInfo.Number = buildAssetInfo.GetReferenceBundleCount();
context.RedundancyInfos.Add(redundancyInfo);
}
} }
} }
// 9. 移除不参与构建的资源 // 10. 移除不参与构建的资源
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>(); List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
foreach (var buildAssetInfo in allBuildAssetInfoDic.Values) foreach (var buildAssetInfo in allBuildAssetInfoDic.Values)
{ {
@ -139,7 +133,7 @@ namespace YooAsset.Editor
allBuildAssetInfoDic.Remove(removeValue.AssetPath); allBuildAssetInfoDic.Remove(removeValue.AssetPath);
} }
// 10. 构建资源包 // 11. 构建资源列表
var allPackAssets = allBuildAssetInfoDic.Values.ToList(); var allPackAssets = allBuildAssetInfoDic.Values.ToList();
if (allPackAssets.Count == 0) if (allPackAssets.Count == 0)
throw new Exception("构建的资源列表不能为空"); throw new Exception("构建的资源列表不能为空");
@ -147,6 +141,7 @@ namespace YooAsset.Editor
{ {
context.PackAsset(assetInfo); context.PackAsset(assetInfo);
} }
return context; return context;
} }
private void RemoveZeroReferenceAssets(List<CollectAssetInfo> allCollectAssetInfos) private void RemoveZeroReferenceAssets(List<CollectAssetInfo> allCollectAssetInfos)

View File

@ -48,7 +48,7 @@ namespace YooAsset.Editor
} }
// 检测共享资源打包规则 // 检测共享资源打包规则
if (buildParameters.ShareAssetPackRule == null) if (buildParameters.SharedPackRule == null)
throw new Exception("共享资源打包规则不能为空!"); throw new Exception("共享资源打包规则不能为空!");
#if UNITY_WEBGL #if UNITY_WEBGL

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 28c5def11c9035443b6251933ffa6a30
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -54,6 +54,10 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public string GetShareBundleName(string packageName, bool uniqueBundleName) public string GetShareBundleName(string packageName, bool uniqueBundleName)
{ {
// 注意:冗余的共享资源包名返回空
if (string.IsNullOrEmpty(_bundleName) && string.IsNullOrEmpty(_bundleExtension))
return string.Empty;
string fullName; string fullName;
string bundleName = EditorTools.GetRegularPath(_bundleName).Replace('/', '_').Replace('.', '_').ToLower(); string bundleName = EditorTools.GetRegularPath(_bundleName).Replace('/', '_').Replace('.', '_').ToLower();
if (uniqueBundleName) if (uniqueBundleName)

View File

@ -4,7 +4,7 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 共享资源的打包规则 /// 共享资源的打包规则
/// </summary> /// </summary>
public interface IShareAssetPackRule public interface ISharedPackRule
{ {
/// <summary> /// <summary>
/// 获取打包规则结果 /// 获取打包规则结果

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a44aabee880cce943b52fe806464be0d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -20,7 +20,7 @@ namespace YooAsset.Editor
} }
} }
[DisplayName("定位地址: 分组名+文件名")] [DisplayName("定位地址: 分组名_文件名")]
public class AddressByGroupAndFileName : IAddressRule public class AddressByGroupAndFileName : IAddressRule
{ {
string IAddressRule.GetAssetAddress(AddressRuleData data) string IAddressRule.GetAssetAddress(AddressRuleData data)
@ -30,7 +30,7 @@ namespace YooAsset.Editor
} }
} }
[DisplayName("定位地址: 文件夹名+文件名")] [DisplayName("定位地址: 文件夹名_文件名")]
public class AddressByFolderAndFileName : IAddressRule public class AddressByFolderAndFileName : IAddressRule
{ {
string IAddressRule.GetAssetAddress(AddressRuleData data) string IAddressRule.GetAssetAddress(AddressRuleData data)

View File

@ -0,0 +1,31 @@
using System;
using System.IO;
using UnityEditor;
namespace YooAsset.Editor
{
/// <summary>
/// 零冗余的共享资源打包规则
/// </summary>
public class ZeroRedundancySharedPackRule : ISharedPackRule
{
public PackRuleResult GetPackRuleResult(string assetPath)
{
string bundleName = Path.GetDirectoryName(assetPath);
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
return result;
}
}
/// <summary>
/// 全部冗余的共享资源打包规则
/// </summary>
public class FullRedundancySharedPackRule : ISharedPackRule
{
public PackRuleResult GetPackRuleResult(string assetPath)
{
PackRuleResult result = new PackRuleResult(string.Empty, string.Empty);
return result;
}
}
}

View File

@ -1,16 +0,0 @@
using System;
using System.IO;
using UnityEditor;
namespace YooAsset.Editor
{
public class DefaultShareAssetPackRule : IShareAssetPackRule
{
public PackRuleResult GetPackRuleResult(string assetPath)
{
string bundleName = Path.GetDirectoryName(assetPath);
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
return result;
}
}
}

View File

@ -66,13 +66,13 @@ namespace YooAsset.Editor
_items.Add(new ItemWrapper("包裹名称", buildReport.Summary.BuildPackageName)); _items.Add(new ItemWrapper("包裹名称", buildReport.Summary.BuildPackageName));
_items.Add(new ItemWrapper("包裹版本", buildReport.Summary.BuildPackageVersion)); _items.Add(new ItemWrapper("包裹版本", buildReport.Summary.BuildPackageVersion));
_items.Add(new ItemWrapper(string.Empty, string.Empty));
_items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}")); _items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}"));
_items.Add(new ItemWrapper("资源定位地址大小写不敏感", $"{buildReport.Summary.LocationToLower}")); _items.Add(new ItemWrapper("资源定位地址大小写不敏感", $"{buildReport.Summary.LocationToLower}"));
_items.Add(new ItemWrapper("包含资源GUID数据", $"{buildReport.Summary.IncludeAssetGUID}")); _items.Add(new ItemWrapper("包含资源GUID数据", $"{buildReport.Summary.IncludeAssetGUID}"));
_items.Add(new ItemWrapper("资源包名唯一化", $"{buildReport.Summary.UniqueBundleName}")); _items.Add(new ItemWrapper("资源包名唯一化", $"{buildReport.Summary.UniqueBundleName}"));
_items.Add(new ItemWrapper("自动分析冗余资源", $"{buildReport.Summary.AutoAnalyzeRedundancy}")); _items.Add(new ItemWrapper("共享资源打包规则", buildReport.Summary.SharedPackRuleClassName));
_items.Add(new ItemWrapper("共享资源的打包类名称", buildReport.Summary.ShareAssetPackRuleClassName)); _items.Add(new ItemWrapper("资源加密服务类", buildReport.Summary.EncryptionServicesClassName));
_items.Add(new ItemWrapper("加密服务类名称", buildReport.Summary.EncryptionServicesClassName));
_items.Add(new ItemWrapper(string.Empty, string.Empty)); _items.Add(new ItemWrapper(string.Empty, string.Empty));
_items.Add(new ItemWrapper("构建参数", string.Empty)); _items.Add(new ItemWrapper("构建参数", string.Empty));

View File

@ -169,7 +169,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 加载场景 /// 加载场景
/// </summary> /// </summary>
public SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode, bool activateOnLoad, int priority) public SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode, int priority)
{ {
if (assetInfo.IsInvalid) if (assetInfo.IsInvalid)
{ {
@ -190,9 +190,9 @@ namespace YooAsset
ProviderBase provider; ProviderBase provider;
{ {
if (_simulationOnEditor) if (_simulationOnEditor)
provider = new DatabaseSceneProvider(this, providerGUID, assetInfo, sceneMode, activateOnLoad, priority); provider = new DatabaseSceneProvider(this, providerGUID, assetInfo, sceneMode, priority);
else else
provider = new BundledSceneProvider(this, providerGUID, assetInfo, sceneMode, activateOnLoad, priority); provider = new BundledSceneProvider(this, providerGUID, assetInfo, sceneMode, priority);
provider.InitSpawnDebugInfo(); provider.InitSpawnDebugInfo();
_providerList.Add(provider); _providerList.Add(provider);
_providerDic.Add(providerGUID, provider); _providerDic.Add(providerGUID, provider);

View File

@ -51,7 +51,7 @@ namespace YooAsset
} }
/// <summary> /// <summary>
/// 激活场景 /// 激活场景(当同时存在多个场景时用于切换激活场景)
/// </summary> /// </summary>
public bool ActivateScene() public bool ActivateScene()
{ {

View File

@ -4,17 +4,17 @@ using System.Collections.Generic;
namespace YooAsset namespace YooAsset
{ {
internal class DependAssetBundleGroup internal class DependAssetBundles
{ {
/// <summary> /// <summary>
/// 依赖的资源包加载器列表 /// 依赖的资源包加载器列表
/// </summary> /// </summary>
internal readonly List<BundleLoaderBase> DependBundles; internal readonly List<BundleLoaderBase> DependList;
public DependAssetBundleGroup(List<BundleLoaderBase> dpendBundles) public DependAssetBundles(List<BundleLoaderBase> dpendList)
{ {
DependBundles = dpendBundles; DependList = dpendList;
} }
/// <summary> /// <summary>
@ -22,7 +22,7 @@ namespace YooAsset
/// </summary> /// </summary>
public bool IsDone() public bool IsDone()
{ {
foreach (var loader in DependBundles) foreach (var loader in DependList)
{ {
if (loader.IsDone() == false) if (loader.IsDone() == false)
return false; return false;
@ -35,7 +35,7 @@ namespace YooAsset
/// </summary> /// </summary>
public bool IsSucceed() public bool IsSucceed()
{ {
foreach (var loader in DependBundles) foreach (var loader in DependList)
{ {
if (loader.Status != BundleLoaderBase.EStatus.Succeed) if (loader.Status != BundleLoaderBase.EStatus.Succeed)
{ {
@ -50,7 +50,7 @@ namespace YooAsset
/// </summary> /// </summary>
public string GetLastError() public string GetLastError()
{ {
foreach (var loader in DependBundles) foreach (var loader in DependList)
{ {
if (loader.Status != BundleLoaderBase.EStatus.Succeed) if (loader.Status != BundleLoaderBase.EStatus.Succeed)
{ {
@ -65,7 +65,7 @@ namespace YooAsset
/// </summary> /// </summary>
public void WaitForAsyncComplete() public void WaitForAsyncComplete()
{ {
foreach (var loader in DependBundles) foreach (var loader in DependList)
{ {
if (loader.IsDone() == false) if (loader.IsDone() == false)
loader.WaitForAsyncComplete(); loader.WaitForAsyncComplete();
@ -77,7 +77,7 @@ namespace YooAsset
/// </summary> /// </summary>
public void Reference() public void Reference()
{ {
foreach (var loader in DependBundles) foreach (var loader in DependList)
{ {
loader.Reference(); loader.Reference();
} }
@ -88,7 +88,7 @@ namespace YooAsset
/// </summary> /// </summary>
public void Release() public void Release()
{ {
foreach (var loader in DependBundles) foreach (var loader in DependList)
{ {
loader.Release(); loader.Release();
} }
@ -99,7 +99,7 @@ namespace YooAsset
/// </summary> /// </summary>
internal void GetBundleDebugInfos(List<DebugBundleInfo> output) internal void GetBundleDebugInfos(List<DebugBundleInfo> output)
{ {
foreach (var loader in DependBundles) foreach (var loader in DependList)
{ {
var bundleInfo = new DebugBundleInfo(); var bundleInfo = new DebugBundleInfo();
bundleInfo.BundleName = loader.MainBundleInfo.Bundle.BundleName; bundleInfo.BundleName = loader.MainBundleInfo.Bundle.BundleName;

View File

@ -28,19 +28,19 @@ namespace YooAsset
{ {
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
{ {
DependBundleGroup.WaitForAsyncComplete(); DependBundles.WaitForAsyncComplete();
OwnerBundle.WaitForAsyncComplete(); OwnerBundle.WaitForAsyncComplete();
} }
if (DependBundleGroup.IsDone() == false) if (DependBundles.IsDone() == false)
return; return;
if (OwnerBundle.IsDone() == false) if (OwnerBundle.IsDone() == false)
return; return;
if (DependBundleGroup.IsSucceed() == false) if (DependBundles.IsSucceed() == false)
{ {
Status = EStatus.Failed; Status = EStatus.Failed;
LastError = DependBundleGroup.GetLastError(); LastError = DependBundles.GetLastError();
InvokeCompletion(); InvokeCompletion();
return; return;
} }

View File

@ -28,19 +28,19 @@ namespace YooAsset
{ {
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
{ {
DependBundleGroup.WaitForAsyncComplete(); DependBundles.WaitForAsyncComplete();
OwnerBundle.WaitForAsyncComplete(); OwnerBundle.WaitForAsyncComplete();
} }
if (DependBundleGroup.IsDone() == false) if (DependBundles.IsDone() == false)
return; return;
if (OwnerBundle.IsDone() == false) if (OwnerBundle.IsDone() == false)
return; return;
if (DependBundleGroup.IsSucceed() == false) if (DependBundles.IsSucceed() == false)
{ {
Status = EStatus.Failed; Status = EStatus.Failed;
LastError = DependBundleGroup.GetLastError(); LastError = DependBundles.GetLastError();
InvokeCompletion(); InvokeCompletion();
return; return;
} }

View File

@ -10,15 +10,13 @@ namespace YooAsset
{ {
public readonly LoadSceneMode SceneMode; public readonly LoadSceneMode SceneMode;
private readonly string _sceneName; private readonly string _sceneName;
private readonly bool _activateOnLoad;
private readonly int _priority; private readonly int _priority;
private AsyncOperation _asyncOp; private AsyncOperation _asyncOp;
public BundledSceneProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, bool activateOnLoad, int priority) : base(impl, providerGUID, assetInfo) public BundledSceneProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, int priority) : base(impl, providerGUID, assetInfo)
{ {
SceneMode = sceneMode; SceneMode = sceneMode;
_sceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath); _sceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath);
_activateOnLoad = activateOnLoad;
_priority = priority; _priority = priority;
} }
public override void Update() public override void Update()
@ -36,15 +34,15 @@ namespace YooAsset
// 1. 检测资源包 // 1. 检测资源包
if (Status == EStatus.CheckBundle) if (Status == EStatus.CheckBundle)
{ {
if (DependBundleGroup.IsDone() == false) if (DependBundles.IsDone() == false)
return; return;
if (OwnerBundle.IsDone() == false) if (OwnerBundle.IsDone() == false)
return; return;
if (DependBundleGroup.IsSucceed() == false) if (DependBundles.IsSucceed() == false)
{ {
Status = EStatus.Failed; Status = EStatus.Failed;
LastError = DependBundleGroup.GetLastError(); LastError = DependBundles.GetLastError();
InvokeCompletion(); InvokeCompletion();
return; return;
} }
@ -87,9 +85,6 @@ namespace YooAsset
Progress = _asyncOp.progress; Progress = _asyncOp.progress;
if (_asyncOp.isDone) if (_asyncOp.isDone)
{ {
if (SceneObject.IsValid() && _activateOnLoad)
SceneManager.SetActiveScene(SceneObject);
Status = SceneObject.IsValid() ? EStatus.Succeed : EStatus.Failed; Status = SceneObject.IsValid() ? EStatus.Succeed : EStatus.Failed;
if (Status == EStatus.Failed) if (Status == EStatus.Failed)
{ {

View File

@ -28,19 +28,19 @@ namespace YooAsset
{ {
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
{ {
DependBundleGroup.WaitForAsyncComplete(); DependBundles.WaitForAsyncComplete();
OwnerBundle.WaitForAsyncComplete(); OwnerBundle.WaitForAsyncComplete();
} }
if (DependBundleGroup.IsDone() == false) if (DependBundles.IsDone() == false)
return; return;
if (OwnerBundle.IsDone() == false) if (OwnerBundle.IsDone() == false)
return; return;
if (DependBundleGroup.IsSucceed() == false) if (DependBundles.IsSucceed() == false)
{ {
Status = EStatus.Failed; Status = EStatus.Failed;
LastError = DependBundleGroup.GetLastError(); LastError = DependBundles.GetLastError();
InvokeCompletion(); InvokeCompletion();
return; return;
} }

View File

@ -6,14 +6,12 @@ namespace YooAsset
internal sealed class DatabaseSceneProvider : ProviderBase internal sealed class DatabaseSceneProvider : ProviderBase
{ {
public readonly LoadSceneMode SceneMode; public readonly LoadSceneMode SceneMode;
private readonly bool _activateOnLoad;
private readonly int _priority; private readonly int _priority;
private AsyncOperation _asyncOp; private AsyncOperation _asyncOp;
public DatabaseSceneProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, bool activateOnLoad, int priority) : base(impl, providerGUID, assetInfo) public DatabaseSceneProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, int priority) : base(impl, providerGUID, assetInfo)
{ {
SceneMode = sceneMode; SceneMode = sceneMode;
_activateOnLoad = activateOnLoad;
_priority = priority; _priority = priority;
} }
public override void Update() public override void Update()
@ -77,9 +75,6 @@ namespace YooAsset
Progress = _asyncOp.progress; Progress = _asyncOp.progress;
if (_asyncOp.isDone) if (_asyncOp.isDone)
{ {
if (SceneObject.IsValid() && _activateOnLoad)
SceneManager.SetActiveScene(SceneObject);
Status = SceneObject.IsValid() ? EStatus.Succeed : EStatus.Failed; Status = SceneObject.IsValid() ? EStatus.Succeed : EStatus.Failed;
if (Status == EStatus.Failed) if (Status == EStatus.Failed)
{ {

View File

@ -91,7 +91,7 @@ namespace YooAsset
protected BundleLoaderBase OwnerBundle { private set; get; } protected BundleLoaderBase OwnerBundle { private set; get; }
protected DependAssetBundleGroup DependBundleGroup { private set; get; } protected DependAssetBundles DependBundles { private set; get; }
protected bool IsWaitForAsyncComplete { private set; get; } = false; protected bool IsWaitForAsyncComplete { private set; get; } = false;
private readonly List<OperationHandleBase> _handles = new List<OperationHandleBase>(); private readonly List<OperationHandleBase> _handles = new List<OperationHandleBase>();
@ -109,9 +109,9 @@ namespace YooAsset
OwnerBundle.Reference(); OwnerBundle.Reference();
OwnerBundle.AddProvider(this); OwnerBundle.AddProvider(this);
var dependBundles = impl.CreateDependAssetBundleLoaders(assetInfo); var dependList = impl.CreateDependAssetBundleLoaders(assetInfo);
DependBundleGroup = new DependAssetBundleGroup(dependBundles); DependBundles = new DependAssetBundles(dependList);
DependBundleGroup.Reference(); DependBundles.Reference();
} }
} }
@ -133,10 +133,10 @@ namespace YooAsset
OwnerBundle.Release(); OwnerBundle.Release();
OwnerBundle = null; OwnerBundle = null;
} }
if (DependBundleGroup != null) if (DependBundles != null)
{ {
DependBundleGroup.Release(); DependBundles.Release();
DependBundleGroup = null; DependBundles = null;
} }
} }
@ -322,7 +322,7 @@ namespace YooAsset
DownloadReport result = new DownloadReport(); DownloadReport result = new DownloadReport();
result.TotalSize = (ulong)OwnerBundle.MainBundleInfo.Bundle.FileSize; result.TotalSize = (ulong)OwnerBundle.MainBundleInfo.Bundle.FileSize;
result.DownloadedBytes = OwnerBundle.DownloadedBytes; result.DownloadedBytes = OwnerBundle.DownloadedBytes;
foreach (var dependBundle in DependBundleGroup.DependBundles) foreach (var dependBundle in DependBundles.DependList)
{ {
result.TotalSize += (ulong)dependBundle.MainBundleInfo.Bundle.FileSize; result.TotalSize += (ulong)dependBundle.MainBundleInfo.Bundle.FileSize;
result.DownloadedBytes += dependBundle.DownloadedBytes; result.DownloadedBytes += dependBundle.DownloadedBytes;
@ -342,7 +342,7 @@ namespace YooAsset
bundleInfo.Status = OwnerBundle.Status.ToString(); bundleInfo.Status = OwnerBundle.Status.ToString();
output.Add(bundleInfo); output.Add(bundleInfo);
DependBundleGroup.GetBundleDebugInfos(output); DependBundles.GetBundleDebugInfos(output);
} }
#endregion #endregion
} }

View File

@ -455,13 +455,12 @@ namespace YooAsset
/// </summary> /// </summary>
/// <param name="location">场景的定位地址</param> /// <param name="location">场景的定位地址</param>
/// <param name="sceneMode">场景加载模式</param> /// <param name="sceneMode">场景加载模式</param>
/// <param name="activateOnLoad">加载完毕时是否主动激活</param>
/// <param name="priority">优先级</param> /// <param name="priority">优先级</param>
public SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100) public SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, int priority = 100)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null); AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
var handle = _assetSystemImpl.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority); var handle = _assetSystemImpl.LoadSceneAsync(assetInfo, sceneMode, priority);
return handle; return handle;
} }
@ -470,12 +469,11 @@ namespace YooAsset
/// </summary> /// </summary>
/// <param name="assetInfo">场景的资源信息</param> /// <param name="assetInfo">场景的资源信息</param>
/// <param name="sceneMode">场景加载模式</param> /// <param name="sceneMode">场景加载模式</param>
/// <param name="activateOnLoad">加载完毕时是否主动激活</param>
/// <param name="priority">优先级</param> /// <param name="priority">优先级</param>
public SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100) public SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, int priority = 100)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
var handle = _assetSystemImpl.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority); var handle = _assetSystemImpl.LoadSceneAsync(assetInfo, sceneMode, priority);
return handle; return handle;
} }
#endregion #endregion

View File

@ -128,12 +128,11 @@ namespace YooAsset
/// </summary> /// </summary>
/// <param name="location">场景的定位地址</param> /// <param name="location">场景的定位地址</param>
/// <param name="sceneMode">场景加载模式</param> /// <param name="sceneMode">场景加载模式</param>
/// <param name="activateOnLoad">加载完毕时是否主动激活</param>
/// <param name="priority">优先级</param> /// <param name="priority">优先级</param>
public static SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100) public static SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, int priority = 100)
{ {
DebugCheckDefaultPackageValid(); DebugCheckDefaultPackageValid();
return _defaultPackage.LoadSceneAsync(location, sceneMode, activateOnLoad, priority); return _defaultPackage.LoadSceneAsync(location, sceneMode, priority);
} }
/// <summary> /// <summary>
@ -141,12 +140,11 @@ namespace YooAsset
/// </summary> /// </summary>
/// <param name="assetInfo">场景的资源信息</param> /// <param name="assetInfo">场景的资源信息</param>
/// <param name="sceneMode">场景加载模式</param> /// <param name="sceneMode">场景加载模式</param>
/// <param name="activateOnLoad">加载完毕时是否主动激活</param>
/// <param name="priority">优先级</param> /// <param name="priority">优先级</param>
public static SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100) public static SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, int priority = 100)
{ {
DebugCheckDefaultPackageValid(); DebugCheckDefaultPackageValid();
return _defaultPackage.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority); return _defaultPackage.LoadSceneAsync(assetInfo, sceneMode, priority);
} }
#endregion #endregion