mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-14 19:40:47 +00:00
Compare commits
34 Commits
2.0.0-prev
...
2.0.3-prev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
506612527d | ||
|
|
74f9f2b0e6 | ||
|
|
4119f02c60 | ||
|
|
bc9a4e07e2 | ||
|
|
9418544264 | ||
|
|
460ea091bd | ||
|
|
64681db027 | ||
|
|
992957e1e9 | ||
|
|
ce62dbc27f | ||
|
|
e2df967aa9 | ||
|
|
5b4a188c0b | ||
|
|
e8b5a58a90 | ||
|
|
c3d5c13a80 | ||
|
|
d30a8aefa4 | ||
|
|
194afe435a | ||
|
|
82ef993d83 | ||
|
|
6d7177a3b5 | ||
|
|
205dd58afd | ||
|
|
d5d5063453 | ||
|
|
f63fcf1227 | ||
|
|
0c70f27560 | ||
|
|
db889366ac | ||
|
|
9476bbe562 | ||
|
|
1313e05d5d | ||
|
|
8817b35517 | ||
|
|
cfe8a77dd5 | ||
|
|
a874d17798 | ||
|
|
5d9ef12577 | ||
|
|
b3a135e1a2 | ||
|
|
a25d03f073 | ||
|
|
589c0d3ce5 | ||
|
|
8457705807 | ||
|
|
ce7aefb744 | ||
|
|
499d7766db |
@@ -2,6 +2,75 @@
|
||||
|
||||
All notable changes to this package will be documented in this file.
|
||||
|
||||
## [2.0.3-preview] - 2023-10-27
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#180) Fixed an issue with invalid encryption task in the build pipeline.
|
||||
- (#185) Fixed subscene unload error when the scene is not loaded.
|
||||
- (#190) Fixed webgl platform compile error.
|
||||
|
||||
### Improvements
|
||||
|
||||
- The asset load method add the priority parameter.
|
||||
- The async operation class add the priority field.
|
||||
|
||||
### Added
|
||||
|
||||
- The InitializeParameters calss add new parameter : AutoDestroyAssetProvider
|
||||
|
||||
```c#
|
||||
/// <summary>
|
||||
/// 自动销毁不再使用的资源提供者
|
||||
/// </summary>
|
||||
public bool AutoDestroyAssetProvider = false;
|
||||
```
|
||||
|
||||
- Resource package add TryUnloadUnusedAsset function.
|
||||
|
||||
```c#
|
||||
/// <summary>
|
||||
/// 尝试卸载指定资源的资源包(包括依赖资源)
|
||||
/// </summary>
|
||||
public void TryUnloadUnusedAsset(AssetInfo assetInfo)
|
||||
```
|
||||
|
||||
### Removed
|
||||
|
||||
- The InitializeParameters calss remove the parameter : LoadingMaxTimeSlice
|
||||
|
||||
## [2.0.2-preview] - 2023-10-17
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed the mistaken code in the build window.
|
||||
- Fixed an issue where auto collect shaders was not effective for dependent resources.
|
||||
|
||||
### Improvements
|
||||
|
||||
- Add error code for exception output during package building.
|
||||
|
||||
## [2.0.1-preview] - 2023-10-11
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#175) Fixed a bug where the url path of mac platform contains spaces, which would cause the request error.
|
||||
- (#177) Fixed the inability to load main asset object after loading the sub asset.
|
||||
- (#178) Fixed the error when initializing resource package that prompted not initialized.
|
||||
- (#179) Fixed issue with SBP build pipeline packaging reporting errors.
|
||||
|
||||
### Added
|
||||
|
||||
- Resource downloader add combine function.
|
||||
|
||||
```c#
|
||||
/// <summary>
|
||||
/// 合并其它下载器
|
||||
/// </summary>
|
||||
/// <param name="downloader">合并的下载器</param>
|
||||
public void Combine(DownloaderOperation downloader);
|
||||
```
|
||||
|
||||
## [2.0.0-preview] - 2023-10-07
|
||||
|
||||
This is the preview version.
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 检测构建参数是否为空
|
||||
if (buildPipeline.Count == 0)
|
||||
throw new Exception($"Build pipeline is empty !");
|
||||
throw new Exception($"Build pipeline is empty !");
|
||||
|
||||
// 清空旧数据
|
||||
_buildContext.ClearAllContext();
|
||||
@@ -41,12 +41,12 @@ namespace YooAsset.Editor
|
||||
if (buildResult.Success)
|
||||
{
|
||||
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
BuildLogger.Log($"{buildParameters.BuildMode} pipeline build succeed !");
|
||||
BuildLogger.Log("Resource pipeline build success");
|
||||
}
|
||||
else
|
||||
{
|
||||
BuildLogger.Warning($"{buildParameters.BuildMode} pipeline build failed !");
|
||||
BuildLogger.Error($"Build task failed : {buildResult.FailedTask}");
|
||||
BuildLogger.Error($"{buildParameters.BuildPipeline} build failed !");
|
||||
BuildLogger.Error($"An error occurred in build task {buildResult.FailedTask}");
|
||||
BuildLogger.Error(buildResult.ErrorInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace YooAsset.Editor
|
||||
[MenuItem("YooAsset/AssetBundle Builder", false, 102)]
|
||||
public static void OpenWindow()
|
||||
{
|
||||
AssetBundleBuilderWindow window = GetWindow<AssetBundleBuilderWindow>("资源包构建工具", true, WindowsDefine.DockedWindowTypes);
|
||||
AssetBundleBuilderWindow window = GetWindow<AssetBundleBuilderWindow>("AssetBundle Builder", true, WindowsDefine.DockedWindowTypes);
|
||||
window.minSize = new Vector2(800, 600);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace YooAsset.Editor
|
||||
if (packageNames.Count == 0)
|
||||
{
|
||||
var label = new Label();
|
||||
label.text = "没有发现可构建的资源包";
|
||||
label.text = "Not found any package";
|
||||
label.style.width = 100;
|
||||
_toolbar.Add(label);
|
||||
return;
|
||||
|
||||
@@ -65,6 +65,7 @@ namespace YooAsset.Editor
|
||||
public BuildAssetInfo(string assetPath)
|
||||
{
|
||||
CollectorType = ECollectorType.None;
|
||||
BundleName = string.Empty;
|
||||
Address = string.Empty;
|
||||
AssetPath = assetPath;
|
||||
|
||||
@@ -84,6 +85,16 @@ namespace YooAsset.Editor
|
||||
AllDependAssetInfos = dependAssetInfos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置为统一的着色器包名
|
||||
/// </summary>
|
||||
public void SetShaderBundleName(string packageName, bool uniqueBundleName)
|
||||
{
|
||||
// 获取着色器打包规则结果
|
||||
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||
BundleName = shaderPackRuleResult.GetBundleName(packageName, uniqueBundleName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加资源的分类标签
|
||||
/// 说明:原始定义的资源分类标签
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace YooAsset.Editor
|
||||
public void PackAsset(BuildAssetInfo assetInfo)
|
||||
{
|
||||
if (IsContainsAsset(assetInfo.AssetPath))
|
||||
throw new System.Exception($"Asset is existed : {assetInfo.AssetPath}");
|
||||
throw new System.Exception($"Should never get here ! Asset is existed : {assetInfo.AssetPath}");
|
||||
|
||||
MainAssets.Add(assetInfo);
|
||||
}
|
||||
@@ -165,10 +165,10 @@ namespace YooAsset.Editor
|
||||
{
|
||||
PackageBundle packageBundle = new PackageBundle();
|
||||
packageBundle.BundleName = BundleName;
|
||||
packageBundle.UnityCRC = PackageUnityCRC;
|
||||
packageBundle.FileHash = PackageFileHash;
|
||||
packageBundle.FileCRC = PackageFileCRC;
|
||||
packageBundle.FileSize = PackageFileSize;
|
||||
packageBundle.UnityCRC = PackageUnityCRC;
|
||||
packageBundle.Encrypted = Encrypted;
|
||||
return packageBundle;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
return result;
|
||||
}
|
||||
throw new Exception($"Not found bundle : {bundleName}");
|
||||
throw new Exception($"Should never get here ! Not found bundle : {bundleName}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -71,14 +71,13 @@ namespace YooAsset.Editor
|
||||
/// 资源包加密服务类
|
||||
/// </summary>
|
||||
public IEncryptionServices EncryptionServices;
|
||||
|
||||
|
||||
|
||||
private string _pipelineOutputDirectory = string.Empty;
|
||||
private string _packageOutputDirectory = string.Empty;
|
||||
private string _packageRootDirectory = string.Empty;
|
||||
private string _buildinRootDirectory = string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 检测构建参数是否合法
|
||||
/// </summary>
|
||||
@@ -86,25 +85,46 @@ namespace YooAsset.Editor
|
||||
{
|
||||
// 检测当前是否正在构建资源包
|
||||
if (UnityEditor.BuildPipeline.isBuildingPlayer)
|
||||
throw new Exception("当前正在构建资源包,请结束后再试");
|
||||
|
||||
// 检测构建参数合法性
|
||||
if (BuildTarget == BuildTarget.NoTarget)
|
||||
throw new Exception("请选择目标平台!");
|
||||
if (string.IsNullOrEmpty(PackageName))
|
||||
throw new Exception("包裹名称不能为空!");
|
||||
if (string.IsNullOrEmpty(PackageVersion))
|
||||
throw new Exception("包裹版本不能为空!");
|
||||
if (string.IsNullOrEmpty(BuildOutputRoot))
|
||||
throw new Exception("构建输出的根目录为空!");
|
||||
if (string.IsNullOrEmpty(BuildinFileRoot))
|
||||
throw new Exception("内置资源根目录为空!");
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.ThePipelineIsBuiding, "The pipeline is buiding, please try again after finish !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
// 检测是否有未保存场景
|
||||
if (BuildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
if (EditorTools.HasDirtyScenes())
|
||||
throw new Exception("检测到未保存的场景文件");
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.FoundUnsavedScene, "Found unsaved scene !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
|
||||
// 检测构建参数合法性
|
||||
if (BuildTarget == BuildTarget.NoTarget)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NoBuildTarget, "Please select the build target platform !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (string.IsNullOrEmpty(PackageName))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageNameIsNullOrEmpty, "Package name is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (string.IsNullOrEmpty(PackageVersion))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageVersionIsNullOrEmpty, "Package version is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (string.IsNullOrEmpty(BuildOutputRoot))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildOutputRootIsNullOrEmpty, "Build output root is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (string.IsNullOrEmpty(BuildinFileRoot))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildinFileRootIsNullOrEmpty, "Buildin file root is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
// 强制构建删除包裹目录
|
||||
@@ -113,7 +133,7 @@ namespace YooAsset.Editor
|
||||
string packageRootDirectory = GetPackageRootDirectory();
|
||||
if (EditorTools.DeleteDirectory(packageRootDirectory))
|
||||
{
|
||||
BuildLogger.Log($"删除包裹目录:{packageRootDirectory}");
|
||||
BuildLogger.Log($"Delete package root directory: {packageRootDirectory}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,14 +142,17 @@ namespace YooAsset.Editor
|
||||
{
|
||||
string packageOutputDirectory = GetPackageOutputDirectory();
|
||||
if (Directory.Exists(packageOutputDirectory))
|
||||
throw new Exception($"本次构建的补丁目录已经存在:{packageOutputDirectory}");
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageOutputDirectoryExists, $"Package outout directory exists: {packageOutputDirectory}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果输出目录不存在
|
||||
string pipelineOutputDirectory = GetPipelineOutputDirectory();
|
||||
if (EditorTools.CreateDirectory(pipelineOutputDirectory))
|
||||
{
|
||||
BuildLogger.Log($"创建输出目录:{pipelineOutputDirectory}");
|
||||
BuildLogger.Log($"Create pipeline output directory: {pipelineOutputDirectory}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 刷新目录
|
||||
AssetDatabase.Refresh();
|
||||
BuildLogger.Log($"内置文件拷贝完成:{buildinRootDirectory}");
|
||||
BuildLogger.Log($"Buildin files copy complete: {buildinRootDirectory}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,6 @@ using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEditor.Build.Pipeline;
|
||||
using UnityEditor.Build.Pipeline.Interfaces;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class ManifestContext : IContextObject
|
||||
@@ -16,6 +13,7 @@ namespace YooAsset.Editor
|
||||
public abstract class TaskCreateManifest
|
||||
{
|
||||
private readonly Dictionary<string, int> _cachedBundleID = new Dictionary<string, int>(10000);
|
||||
private readonly Dictionary<int, HashSet<string>> _cacheBundleTags = new Dictionary<int, HashSet<string>>(10000);
|
||||
|
||||
/// <summary>
|
||||
/// 创建补丁清单文件到输出目录
|
||||
@@ -54,7 +52,7 @@ namespace YooAsset.Editor
|
||||
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
ManifestTools.SerializeToJson(filePath, manifest);
|
||||
BuildLogger.Log($"创建补丁清单文件:{filePath}");
|
||||
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||
}
|
||||
|
||||
// 创建补丁清单二进制文件
|
||||
@@ -64,7 +62,7 @@ namespace YooAsset.Editor
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
ManifestTools.SerializeToBinary(filePath, manifest);
|
||||
packageHash = HashUtility.FileMD5(filePath);
|
||||
BuildLogger.Log($"创建补丁清单文件:{filePath}");
|
||||
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||
|
||||
ManifestContext manifestContext = new ManifestContext();
|
||||
byte[] bytesData = FileUtility.ReadAllBytes(filePath);
|
||||
@@ -77,7 +75,7 @@ namespace YooAsset.Editor
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
FileUtility.WriteAllText(filePath, packageHash);
|
||||
BuildLogger.Log($"创建补丁清单哈希文件:{filePath}");
|
||||
BuildLogger.Log($"Create package manifest hash file: {filePath}");
|
||||
}
|
||||
|
||||
// 创建补丁清单版本文件
|
||||
@@ -85,7 +83,7 @@ namespace YooAsset.Editor
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildParameters.PackageName);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
FileUtility.WriteAllText(filePath, buildParameters.PackageVersion);
|
||||
BuildLogger.Log($"创建补丁清单版本文件:{filePath}");
|
||||
BuildLogger.Log($"Create package manifest version file: {filePath}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,36 +163,44 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
private void ProcessBundleTags(PackageManifest manifest)
|
||||
{
|
||||
Dictionary<int, HashSet<string>> cacheBundleTags = new Dictionary<int, HashSet<string>>(10000);
|
||||
|
||||
// 将主资源的标签信息传染给其依赖的资源包集合
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
// 主资源包
|
||||
var assetTags = packageAsset.AssetTags;
|
||||
int bundleID = packageAsset.BundleID;
|
||||
CacheBundleTags(cacheBundleTags, bundleID, packageAsset.AssetTags);
|
||||
CacheBundleTags(bundleID, assetTags);
|
||||
|
||||
// 依赖资源包
|
||||
var packageBundle = manifest.BundleList[bundleID];
|
||||
foreach (var dependBundleID in packageBundle.DependIDs)
|
||||
{
|
||||
CacheBundleTags(cacheBundleTags, dependBundleID, packageAsset.AssetTags);
|
||||
CacheBundleTags(dependBundleID, assetTags);
|
||||
}
|
||||
}
|
||||
|
||||
for (int index = 0; index < manifest.BundleList.Count; index++)
|
||||
{
|
||||
manifest.BundleList[index].Tags = cacheBundleTags[index].ToArray();
|
||||
var packageBundle = manifest.BundleList[index];
|
||||
if (_cacheBundleTags.ContainsKey(index))
|
||||
{
|
||||
packageBundle.Tags = _cacheBundleTags[index].ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 注意:SBP构建管线会自动剔除一些冗余资源的引用关系,导致游离资源包没有被任何主资源包引用。
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundStrayBundle, $"Found stray bundle ! Bundle ID : {index} Bundle name : {packageBundle.BundleName}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void CacheBundleTags(Dictionary<int, HashSet<string>> cacheBundleTags, int bundleID, string[] assetTags)
|
||||
private void CacheBundleTags(int bundleID, string[] assetTags)
|
||||
{
|
||||
if (cacheBundleTags.ContainsKey(bundleID) == false)
|
||||
cacheBundleTags.Add(bundleID, new HashSet<string>());
|
||||
if (_cacheBundleTags.ContainsKey(bundleID) == false)
|
||||
_cacheBundleTags.Add(bundleID, new HashSet<string>());
|
||||
|
||||
foreach (var assetTag in assetTags)
|
||||
{
|
||||
if (cacheBundleTags[bundleID].Contains(assetTag) == false)
|
||||
cacheBundleTags[bundleID].Add(assetTag);
|
||||
if (_cacheBundleTags[bundleID].Contains(assetTag) == false)
|
||||
_cacheBundleTags[bundleID].Add(assetTag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +211,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
if (_cachedBundleID.TryGetValue(bundleName, out int value) == false)
|
||||
{
|
||||
throw new Exception($"Not found cached bundle ID : {bundleName}");
|
||||
throw new Exception($"Should never get here ! Not found bundle ID : {bundleName}");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -31,11 +31,13 @@ namespace YooAsset.Editor
|
||||
buildReport.Summary.BuildMode = buildParameters.BuildMode;
|
||||
buildReport.Summary.BuildPackageName = buildParameters.PackageName;
|
||||
buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion;
|
||||
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
|
||||
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
|
||||
buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ?
|
||||
buildReport.Summary.IgnoreDefaultType = buildMapContext.Command.IgnoreDefaultType;
|
||||
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
|
||||
buildReport.Summary.EncryptionClassName = buildParameters.EncryptionServices == null ?
|
||||
"null" : buildParameters.EncryptionServices.GetType().FullName;
|
||||
|
||||
// 构建参数
|
||||
@@ -112,7 +114,7 @@ namespace YooAsset.Editor
|
||||
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
BuildReport.Serialize(filePath, buildReport);
|
||||
BuildLogger.Log($"资源构建报告文件创建完成:{filePath}");
|
||||
BuildLogger.Log($"Create build report file: {filePath}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -148,7 +150,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
if (findAssetInfo == null)
|
||||
{
|
||||
throw new Exception($"Not found asset {assetPath} in bunlde {bundleName}");
|
||||
throw new Exception($"Should never get here ! Not found asset {assetPath} in bunlde {bundleName}");
|
||||
}
|
||||
foreach (var dependAssetInfo in findAssetInfo.AllDependAssetInfos)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace YooAsset.Editor
|
||||
EncryptFileInfo fileInfo = new EncryptFileInfo();
|
||||
fileInfo.BundleName = bundleInfo.BundleName;
|
||||
fileInfo.FilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
|
||||
var encryptResult = encryptionServices.Encrypt(fileInfo);
|
||||
if (encryptResult.Encrypted)
|
||||
{
|
||||
@@ -35,7 +34,7 @@ namespace YooAsset.Editor
|
||||
FileUtility.WriteAllBytes(filePath, encryptResult.EncryptedData);
|
||||
bundleInfo.EncryptedFilePath = filePath;
|
||||
bundleInfo.Encrypted = true;
|
||||
BuildLogger.Log($"Bundle文件加密完成:{filePath}");
|
||||
BuildLogger.Log($"Bundle file encryption complete: {filePath}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -43,7 +42,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
// 进度条
|
||||
EditorTools.DisplayProgressBar("加密资源包", ++progressValue, buildMapContext.Collection.Count);
|
||||
EditorTools.DisplayProgressBar("Encrypting bundle", ++progressValue, buildMapContext.Collection.Count);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace YooAsset.Editor
|
||||
// 2. 剔除未被引用的依赖项资源
|
||||
RemoveZeroReferenceAssets(allCollectAssetInfos);
|
||||
|
||||
// 3. 录入所有收集器收集的资源
|
||||
// 3. 录入所有收集器主动收集的资源
|
||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
||||
{
|
||||
if (allBuildAssetInfos.ContainsKey(collectAssetInfo.AssetPath) == false)
|
||||
@@ -36,7 +36,8 @@ namespace YooAsset.Editor
|
||||
if (collectAssetInfo.AssetTags.Count > 0)
|
||||
{
|
||||
collectAssetInfo.AssetTags.Clear();
|
||||
BuildLogger.Warning($"The tags has been cleared ! {collectAssetInfo.AssetPath} ");
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.RemoveInvalidTags, $"Remove asset tags that don't work, see the asset collector type : {collectAssetInfo.AssetPath}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +51,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 录入所有收集资源的依赖资源
|
||||
// 4. 录入所有收集资源依赖的其它资源
|
||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
||||
{
|
||||
string bundleName = collectAssetInfo.BundleName;
|
||||
@@ -83,12 +84,27 @@ namespace YooAsset.Editor
|
||||
allBuildAssetInfos[collectAssetInfo.AssetPath].SetDependAssetInfos(dependAssetInfos);
|
||||
}
|
||||
|
||||
// 6. 记录关键信息
|
||||
// 6. 自动收集所有依赖的着色器
|
||||
if (collectResult.Command.AutoCollectShaders)
|
||||
{
|
||||
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||
{
|
||||
if (buildAssetInfo.CollectorType == ECollectorType.None)
|
||||
{
|
||||
if (buildAssetInfo.AssetType == typeof(UnityEngine.Shader) || buildAssetInfo.AssetType == typeof(UnityEngine.ShaderVariantCollection))
|
||||
{
|
||||
buildAssetInfo.SetShaderBundleName(collectResult.Command.PackageName, collectResult.Command.UniqueBundleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 7. 记录关键信息
|
||||
BuildMapContext context = new BuildMapContext();
|
||||
context.AssetFileCount = allBuildAssetInfos.Count;
|
||||
context.Command = collectResult.Command;
|
||||
|
||||
// 7. 记录冗余资源
|
||||
// 8. 记录冗余资源
|
||||
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||
{
|
||||
if (buildAssetInfo.IsRedundancyAsset())
|
||||
@@ -103,7 +119,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
}
|
||||
|
||||
// 8. 移除不参与构建的资源
|
||||
// 9. 移除不参与构建的资源
|
||||
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
||||
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||
{
|
||||
@@ -115,10 +131,13 @@ namespace YooAsset.Editor
|
||||
allBuildAssetInfos.Remove(removeValue.AssetPath);
|
||||
}
|
||||
|
||||
// 9. 构建资源列表
|
||||
// 10. 构建资源列表
|
||||
var allPackAssets = allBuildAssetInfos.Values.ToList();
|
||||
if (allPackAssets.Count == 0)
|
||||
throw new Exception("构建的资源列表不能为空");
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackAssetListIsEmpty, "The pack asset info is empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
foreach (var assetInfo in allPackAssets)
|
||||
{
|
||||
context.PackAsset(assetInfo);
|
||||
@@ -162,7 +181,8 @@ namespace YooAsset.Editor
|
||||
// 4. 移除所有零引用的依赖资源
|
||||
foreach (var removeValue in removeList)
|
||||
{
|
||||
BuildLogger.Log($"发现未被依赖的资源并自动移除 : {removeValue.AssetPath}");
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundUndependedAsset, $"Found undepended asset and remove it : {removeValue.AssetPath}");
|
||||
BuildLogger.Warning(warning);
|
||||
allCollectAssetInfos.Remove(removeValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,10 @@ namespace YooAsset.Editor
|
||||
// NOTE:检测文件名长度不要超过260字符。
|
||||
string fileName = bundleInfo.BundleName;
|
||||
if (fileName.Length >= 260)
|
||||
throw new Exception($"The output bundle name is too long {fileName.Length} chars : {fileName}");
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.CharactersOverTheLimit, $"Bundle file name character count exceeds limit : {fileName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
|
||||
// 2.更新构建输出的文件路径
|
||||
|
||||
@@ -7,7 +7,6 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("资源构建内容打包")]
|
||||
public class TaskBuilding_BBP : IBuildTask
|
||||
{
|
||||
public class BuildResultContext : IContextObject
|
||||
@@ -29,22 +28,26 @@ namespace YooAsset.Editor
|
||||
// 开始构建
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
BuildAssetBundleOptions buildOptions = builtinBuildParameters.GetBundleBuildOptions();
|
||||
AssetBundleManifest buildResults = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), buildOptions, buildParametersContext.Parameters.BuildTarget);
|
||||
if (buildResults == null)
|
||||
AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), buildOptions, buildParametersContext.Parameters.BuildTarget);
|
||||
if (unityManifest == null)
|
||||
{
|
||||
throw new Exception("构建过程中发生错误!");
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, "UnityEngine build failed !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
string unityOutputManifestFilePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||
if (System.IO.File.Exists(unityOutputManifestFilePath) == false)
|
||||
throw new Exception("构建过程中发生严重错误!请查阅上下文日志!");
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFatal, $"Not found output {nameof(AssetBundleManifest)} file : {unityOutputManifestFilePath}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
|
||||
BuildLogger.Log("Unity引擎打包成功!");
|
||||
BuildLogger.Log("UnityEngine build success !");
|
||||
BuildResultContext buildResultContext = new BuildResultContext();
|
||||
buildResultContext.UnityManifest = buildResults;
|
||||
buildResultContext.UnityManifest = unityManifest;
|
||||
context.SetContextObject(buildResultContext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("拷贝内置文件")]
|
||||
public class TaskCopyBuildinFiles_BBP : TaskCopyBuildinFiles, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("创建清单文件")]
|
||||
public class TaskCreateManifest_BBP : TaskCreateManifest, IBuildTask
|
||||
{
|
||||
private TaskBuilding_BBP.BuildResultContext _buildResultContext = null;
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("制作包裹")]
|
||||
public class TaskCreatePackage_BBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
@@ -13,18 +12,18 @@ namespace YooAsset.Editor
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode != EBuildMode.SimulateBuild && buildMode != EBuildMode.DryRunBuild)
|
||||
{
|
||||
CopyPackageFiles(buildParameters, buildMapContext);
|
||||
CreatePackageCatalog(buildParameters, buildMapContext);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝补丁文件到补丁包目录
|
||||
/// </summary>
|
||||
private void CopyPackageFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
{
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
BuildLogger.Log($"开始拷贝补丁文件到补丁包目录:{packageOutputDirectory}");
|
||||
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
||||
|
||||
// 拷贝UnityManifest序列化文件
|
||||
{
|
||||
@@ -46,7 +45,7 @@ namespace YooAsset.Editor
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
|
||||
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, fileTotalCount);
|
||||
EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("创建构建报告文件")]
|
||||
public class TaskCreateReport_BBP : TaskCreateReport, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
|
||||
@@ -6,7 +6,6 @@ using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("资源包加密")]
|
||||
public class TaskEncryption_BBP : TaskEncryption, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
|
||||
@@ -7,7 +7,6 @@ using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("获取资源构建内容")]
|
||||
public class TaskGetBuildMap_BBP : TaskGetBuildMap, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
|
||||
@@ -6,7 +6,6 @@ using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("资源构建准备工作")]
|
||||
public class TaskPrepare_BBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
@@ -22,7 +21,8 @@ namespace YooAsset.Editor
|
||||
#if UNITY_2021_3_OR_NEWER
|
||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
BuildLogger.Warning("Unity2021版本开始内置构建管线不再维护,推荐使用可编程构建管线(SBP)!");
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.RecommendScriptBuildPipeline, $"Starting with UnityEngine2021, recommend use script build pipeline (SBP) !");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("更新资源包信息")]
|
||||
public class TaskUpdateBundleInfo_BBP : TaskUpdateBundleInfo, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
@@ -28,9 +27,14 @@ namespace YooAsset.Editor
|
||||
var buildResult = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>();
|
||||
var hash = buildResult.UnityManifest.GetAssetBundleHash(bundleInfo.BundleName);
|
||||
if (hash.isValid)
|
||||
{
|
||||
return hash.ToString();
|
||||
}
|
||||
else
|
||||
throw new Exception($"Not found bundle hash in build result : {bundleInfo.BundleName}");
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleHash, $"Not found unity bundle hash : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
@@ -46,9 +50,14 @@ namespace YooAsset.Editor
|
||||
{
|
||||
string filePath = bundleInfo.BuildOutputFilePath;
|
||||
if (BuildPipeline.GetCRCForAssetBundle(filePath, out uint crc))
|
||||
{
|
||||
return crc;
|
||||
}
|
||||
else
|
||||
throw new Exception($"Not found bundle crc in build result : {bundleInfo.BundleName}");
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleCRC, $"Not found unity bundle crc : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override string GetBundleFileHash(string filePath, BuildParametersContext buildParametersContext)
|
||||
|
||||
@@ -8,7 +8,6 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("验证构建结果")]
|
||||
public class TaskVerifyBuildResult_BBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
@@ -46,9 +45,12 @@ namespace YooAsset.Editor
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList1)
|
||||
{
|
||||
BuildLogger.Warning($"差异资源包: {exceptBundle}");
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
||||
|
||||
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||
throw new Exception(exception);
|
||||
}
|
||||
|
||||
// 3. 验证Bundle
|
||||
@@ -57,12 +59,15 @@ namespace YooAsset.Editor
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList2)
|
||||
{
|
||||
BuildLogger.Warning($"差异资源包: {exceptBundle}");
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
||||
|
||||
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||
throw new Exception(exception);
|
||||
}
|
||||
|
||||
BuildLogger.Log("构建结果验证成功!");
|
||||
BuildLogger.Log("Build results verify success!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
@@ -22,15 +19,16 @@ namespace YooAsset.Editor
|
||||
{
|
||||
List<IBuildTask> pipeline = new List<IBuildTask>
|
||||
{
|
||||
new TaskPrepare_BBP(), //前期准备工作
|
||||
new TaskGetBuildMap_BBP(), //获取构建列表
|
||||
new TaskBuilding_BBP(), //开始执行构建
|
||||
new TaskVerifyBuildResult_BBP(), //验证构建结果
|
||||
new TaskUpdateBundleInfo_BBP(), //更新资源包信息
|
||||
new TaskCreateManifest_BBP(), //创建清单文件
|
||||
new TaskCreateReport_BBP(), //创建报告文件
|
||||
new TaskCreatePackage_BBP(), //制作包裹
|
||||
new TaskCopyBuildinFiles_BBP(), //拷贝内置文件
|
||||
new TaskPrepare_BBP(),
|
||||
new TaskGetBuildMap_BBP(),
|
||||
new TaskBuilding_BBP(),
|
||||
new TaskVerifyBuildResult_BBP(),
|
||||
new TaskEncryption_BBP(),
|
||||
new TaskUpdateBundleInfo_BBP(),
|
||||
new TaskCreateManifest_BBP(),
|
||||
new TaskCreateReport_BBP(),
|
||||
new TaskCreatePackage_BBP(),
|
||||
new TaskCopyBuildinFiles_BBP(),
|
||||
};
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("资源构建内容打包")]
|
||||
public class TaskBuilding_RFBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
|
||||
@@ -6,7 +6,6 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("拷贝内置文件")]
|
||||
public class TaskCopyBuildinFiles_RFBP : TaskCopyBuildinFiles, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("创建清单文件")]
|
||||
public class TaskCreateManifest_RFBP : TaskCreateManifest, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("制作包裹")]
|
||||
public class TaskCreatePackage_RFBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
@@ -13,19 +12,17 @@ namespace YooAsset.Editor
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
CopyPackageFiles(buildParameters, buildMapContext);
|
||||
CreatePackageCatalog(buildParameters, buildMapContext);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝补丁文件到补丁包目录
|
||||
/// </summary>
|
||||
private void CopyPackageFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
{
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
BuildLogger.Log($"开始拷贝补丁文件到补丁包目录:{packageOutputDirectory}");
|
||||
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
||||
|
||||
// 拷贝所有补丁文件
|
||||
int progressValue = 0;
|
||||
@@ -33,7 +30,7 @@ namespace YooAsset.Editor
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
|
||||
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, fileTotalCount);
|
||||
EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("创建构建报告文件")]
|
||||
public class TaskCreateReport_RFBP : TaskCreateReport, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
|
||||
@@ -7,7 +7,6 @@ using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("获取资源构建内容")]
|
||||
public class TaskGetBuildMap_RFBP : TaskGetBuildMap, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
@@ -29,7 +28,10 @@ namespace YooAsset.Editor
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
if (bundleInfo.MainAssets.Count != 1)
|
||||
throw new Exception($"The bundle does not support multiple raw asset : {bundleInfo.BundleName}");
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotSupportMultipleRawAsset, $"The bundle does not support multiple raw asset : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("资源构建准备工作")]
|
||||
public class TaskPrepare_RFBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
@@ -19,9 +18,15 @@ namespace YooAsset.Editor
|
||||
|
||||
// 检测不被支持的构建模式
|
||||
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
||||
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.RawFileBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
||||
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.IncrementalBuild)} build mode !");
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.RawFileBuildPipeline)} not support {nameof(EBuildMode.IncrementalBuild)} build mode !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("更新资源包信息")]
|
||||
public class TaskUpdateBundleInfo_RFBP : TaskUpdateBundleInfo, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
|
||||
@@ -22,14 +22,14 @@ namespace YooAsset.Editor
|
||||
{
|
||||
List<IBuildTask> pipeline = new List<IBuildTask>
|
||||
{
|
||||
new TaskPrepare_RFBP(), //前期准备工作
|
||||
new TaskGetBuildMap_RFBP(), //获取构建列表
|
||||
new TaskBuilding_RFBP(), //开始执行构建
|
||||
new TaskUpdateBundleInfo_RFBP(), //更新资源包信息
|
||||
new TaskCreateManifest_RFBP(), //创建清单文件
|
||||
new TaskCreateReport_RFBP(), //创建报告文件
|
||||
new TaskCreatePackage_RFBP(), //制作包裹
|
||||
new TaskCopyBuildinFiles_RFBP(), //拷贝内置文件
|
||||
new TaskPrepare_RFBP(),
|
||||
new TaskGetBuildMap_RFBP(),
|
||||
new TaskBuilding_RFBP(),
|
||||
new TaskUpdateBundleInfo_RFBP(),
|
||||
new TaskCreateManifest_RFBP(),
|
||||
new TaskCreateReport_RFBP(),
|
||||
new TaskCreatePackage_RFBP(),
|
||||
new TaskCopyBuildinFiles_RFBP(),
|
||||
};
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ using UnityEditor.Build.Pipeline.Tasks;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("资源构建内容打包")]
|
||||
public class TaskBuilding_SBP : IBuildTask
|
||||
{
|
||||
public class BuildResultContext : IContextObject
|
||||
@@ -37,7 +36,8 @@ namespace YooAsset.Editor
|
||||
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
|
||||
if (exitCode < 0)
|
||||
{
|
||||
throw new Exception($"构建过程中发生错误 : {exitCode}");
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, $"UnityEngine build failed ! ReturnCode : {exitCode}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
// 创建着色器信息
|
||||
@@ -49,7 +49,7 @@ namespace YooAsset.Editor
|
||||
buildMapContext.CreateShadersBundleInfo(shadersBundleName);
|
||||
}
|
||||
|
||||
BuildLogger.Log("Unity引擎打包成功!");
|
||||
BuildLogger.Log("UnityEngine build success!");
|
||||
BuildResultContext buildResultContext = new BuildResultContext();
|
||||
buildResultContext.Results = buildResults;
|
||||
context.SetContextObject(buildResultContext);
|
||||
|
||||
@@ -6,7 +6,6 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("拷贝内置文件")]
|
||||
public class TaskCopyBuildinFiles_SBP : TaskCopyBuildinFiles, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
|
||||
@@ -7,7 +7,6 @@ using UnityEditor.Build.Pipeline.Interfaces;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("创建清单文件")]
|
||||
public class TaskCreateManifest_SBP : TaskCreateManifest, IBuildTask
|
||||
{
|
||||
private TaskBuilding_SBP.BuildResultContext _buildResultContext = null;
|
||||
@@ -23,7 +22,10 @@ namespace YooAsset.Editor
|
||||
_buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
|
||||
if (_buildResultContext.Results.BundleInfos.ContainsKey(bundleName) == false)
|
||||
throw new Exception($"Not found bundle in SBP build results : {bundleName}");
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleInBuildResult, $"Not found bundle in engine build result : {bundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
return _buildResultContext.Results.BundleInfos[bundleName].Dependencies;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("制作包裹")]
|
||||
public class TaskCreatePackage_SBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
@@ -13,19 +12,19 @@ namespace YooAsset.Editor
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
CopyPackageFiles(buildParameters, buildMapContext);
|
||||
CreatePackageCatalog(buildParameters, buildMapContext);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝补丁文件到补丁包目录
|
||||
/// </summary>
|
||||
private void CopyPackageFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
{
|
||||
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
BuildLogger.Log($"开始拷贝补丁文件到补丁包目录:{packageOutputDirectory}");
|
||||
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
||||
|
||||
// 拷贝构建日志
|
||||
{
|
||||
@@ -48,7 +47,7 @@ namespace YooAsset.Editor
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
|
||||
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, fileTotalCount);
|
||||
EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("创建构建报告文件")]
|
||||
public class TaskCreateReport_SBP : TaskCreateReport, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
|
||||
@@ -6,7 +6,6 @@ using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("资源包加密")]
|
||||
public class TaskEncryption_SBP : TaskEncryption, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
|
||||
@@ -7,7 +7,6 @@ using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("获取资源构建内容")]
|
||||
public class TaskGetBuildMap_SBP : TaskGetBuildMap, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
|
||||
@@ -6,7 +6,6 @@ using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("资源构建准备工作")]
|
||||
public class TaskPrepare_SBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
@@ -19,9 +18,15 @@ namespace YooAsset.Editor
|
||||
|
||||
// 检测不被支持的构建模式
|
||||
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
||||
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (buildParameters.BuildMode == EBuildMode.ForceRebuild)
|
||||
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.ForceRebuild)} build mode !");
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.ForceRebuild)} build mode !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("更新资源包信息")]
|
||||
public class TaskUpdateBundleInfo_SBP : TaskUpdateBundleInfo, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
@@ -28,9 +27,14 @@ namespace YooAsset.Editor
|
||||
// 注意:当资源包的依赖列表发生变化的时候,ContentHash也会发生变化!
|
||||
var buildResult = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
if (buildResult.Results.BundleInfos.TryGetValue(bundleInfo.BundleName, out var value))
|
||||
{
|
||||
return value.Hash.ToString();
|
||||
}
|
||||
else
|
||||
throw new Exception($"Not found bundle hash in build result : {bundleInfo.BundleName}");
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleHash, $"Not found unity bundle hash : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
@@ -46,9 +50,14 @@ namespace YooAsset.Editor
|
||||
{
|
||||
var buildResult = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
if (buildResult.Results.BundleInfos.TryGetValue(bundleInfo.BundleName, out var value))
|
||||
{
|
||||
return value.Crc;
|
||||
}
|
||||
else
|
||||
throw new Exception($"Not found bundle crc in build result : {bundleInfo.BundleName}");
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleCRC, $"Not found unity bundle crc : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override string GetBundleFileHash(string filePath, BuildParametersContext buildParametersContext)
|
||||
|
||||
@@ -9,7 +9,6 @@ using UnityEditor.Build.Pipeline.Interfaces;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("验证构建结果")]
|
||||
public class TaskVerifyBuildResult_SBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
@@ -47,9 +46,12 @@ namespace YooAsset.Editor
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList1)
|
||||
{
|
||||
BuildLogger.Warning($"差异资源包: {exceptBundle}");
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
||||
|
||||
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||
throw new Exception(exception);
|
||||
}
|
||||
|
||||
// 3. 验证Bundle
|
||||
@@ -58,12 +60,15 @@ namespace YooAsset.Editor
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList2)
|
||||
{
|
||||
BuildLogger.Warning($"差异资源包: {exceptBundle}");
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
||||
|
||||
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||
throw new Exception(exception);
|
||||
}
|
||||
|
||||
BuildLogger.Log("构建结果验证成功!");
|
||||
BuildLogger.Log("Build results verify success!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,67 +4,64 @@ using UnityEngine.U2D;
|
||||
using UnityEditor.Build.Pipeline.Injector;
|
||||
using UnityEditor.Build.Pipeline.Interfaces;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
namespace UnityEditor.Build.Pipeline.Tasks
|
||||
{
|
||||
/// <summary>
|
||||
/// Ref https://zhuanlan.zhihu.com/p/586918159
|
||||
/// </summary>
|
||||
public class RemoveSpriteAtlasRedundancy : IBuildTask
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public int Version => 1;
|
||||
/// <summary>
|
||||
/// Ref https://zhuanlan.zhihu.com/p/586918159
|
||||
/// </summary>
|
||||
public class RemoveSpriteAtlasRedundancy : IBuildTask
|
||||
{
|
||||
public int Version => 1;
|
||||
|
||||
[InjectContext]
|
||||
IBundleWriteData writeDataParam;
|
||||
[InjectContext]
|
||||
IBundleWriteData writeDataParam;
|
||||
|
||||
/// <inheritdoc />
|
||||
public ReturnCode Run()
|
||||
{
|
||||
BundleWriteData writeData = (BundleWriteData)writeDataParam;
|
||||
public ReturnCode Run()
|
||||
{
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
BundleWriteData writeData = (BundleWriteData)writeDataParam;
|
||||
|
||||
// 所有图集散图的 guid 集合
|
||||
HashSet<GUID> spriteGuids = new HashSet<GUID>();
|
||||
// 图集引用的精灵图片集合
|
||||
HashSet<GUID> spriteGuids = new HashSet<GUID>();
|
||||
foreach (var pair in writeData.FileToObjects)
|
||||
{
|
||||
foreach (ObjectIdentifier objectIdentifier in pair.Value)
|
||||
{
|
||||
var assetPath = AssetDatabase.GUIDToAssetPath(objectIdentifier.guid);
|
||||
var assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (assetType == typeof(SpriteAtlas))
|
||||
{
|
||||
var spritePaths = AssetDatabase.GetDependencies(assetPath, false);
|
||||
foreach (string spritePath in spritePaths)
|
||||
{
|
||||
GUID spriteGuild = AssetDatabase.GUIDFromAssetPath(spritePath);
|
||||
spriteGuids.Add(spriteGuild);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 遍历资源包里的资源记录其中图集的散图 guid
|
||||
foreach (var pair in writeData.FileToObjects)
|
||||
{
|
||||
foreach (ObjectIdentifier objectIdentifier in pair.Value)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(objectIdentifier.guid);
|
||||
Object asset = AssetDatabase.LoadAssetAtPath<Object>(path);
|
||||
if (asset is SpriteAtlas)
|
||||
{
|
||||
List<string> spritePaths = AssetDatabase.GetDependencies(path, false).ToList();
|
||||
foreach (string spritePath in spritePaths)
|
||||
{
|
||||
GUID spriteGuild = AssetDatabase.GUIDFromAssetPath(spritePath);
|
||||
spriteGuids.Add(spriteGuild);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 移除图集引用的精力图片对象
|
||||
foreach (var pair in writeData.FileToObjects)
|
||||
{
|
||||
List<ObjectIdentifier> objectIdentifiers = pair.Value;
|
||||
for (int i = objectIdentifiers.Count - 1; i >= 0; i--)
|
||||
{
|
||||
ObjectIdentifier objectIdentifier = objectIdentifiers[i];
|
||||
if (spriteGuids.Contains(objectIdentifier.guid))
|
||||
{
|
||||
if (objectIdentifier.localIdentifierInFile == 2800000)
|
||||
{
|
||||
// 删除图集散图的冗余纹理
|
||||
objectIdentifiers.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// 将 writeData.FileToObjects 包含的图集散图的 texture 删掉避免冗余
|
||||
foreach (var pair in writeData.FileToObjects)
|
||||
{
|
||||
List<ObjectIdentifier> objectIdentifiers = pair.Value;
|
||||
for (int i = objectIdentifiers.Count - 1; i >= 0; i--)
|
||||
{
|
||||
ObjectIdentifier objectIdentifier = objectIdentifiers[i];
|
||||
if (spriteGuids.Contains(objectIdentifier.guid))
|
||||
{
|
||||
if (objectIdentifier.localIdentifierInFile == 2800000)
|
||||
{
|
||||
// 删除图集散图的冗余 texture
|
||||
objectIdentifiers.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ReturnCode.Success;
|
||||
}
|
||||
}
|
||||
return ReturnCode.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
@@ -22,15 +19,16 @@ namespace YooAsset.Editor
|
||||
{
|
||||
List<IBuildTask> pipeline = new List<IBuildTask>
|
||||
{
|
||||
new TaskPrepare_SBP(), //前期准备工作
|
||||
new TaskGetBuildMap_SBP(), //获取构建列表
|
||||
new TaskBuilding_SBP(), //开始执行构建
|
||||
new TaskVerifyBuildResult_SBP(), //验证构建结果
|
||||
new TaskUpdateBundleInfo_SBP(), //更新补丁信息
|
||||
new TaskCreateManifest_SBP(), //创建清单文件
|
||||
new TaskCreateReport_SBP(), //创建报告文件
|
||||
new TaskCreatePackage_SBP(), //制作补丁包
|
||||
new TaskCopyBuildinFiles_SBP(), //拷贝内置文件
|
||||
new TaskPrepare_SBP(),
|
||||
new TaskGetBuildMap_SBP(),
|
||||
new TaskBuilding_SBP(),
|
||||
new TaskVerifyBuildResult_SBP(),
|
||||
new TaskEncryption_SBP(),
|
||||
new TaskUpdateBundleInfo_SBP(),
|
||||
new TaskCreateManifest_SBP(),
|
||||
new TaskCreateReport_SBP(),
|
||||
new TaskCreatePackage_SBP(),
|
||||
new TaskCopyBuildinFiles_SBP(),
|
||||
};
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public static class BuildLogger
|
||||
internal static class BuildLogger
|
||||
{
|
||||
private static bool _enableLog = true;
|
||||
|
||||
@@ -29,5 +29,10 @@ namespace YooAsset.Editor
|
||||
{
|
||||
Debug.LogError(message);
|
||||
}
|
||||
|
||||
public static string GetErrorMessage(ErrorCode code, string message)
|
||||
{
|
||||
return $"[ErrorCode{(int)code}] {message}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,17 +36,15 @@ namespace YooAsset.Editor
|
||||
try
|
||||
{
|
||||
_buildWatch = Stopwatch.StartNew();
|
||||
var taskAttribute = task.GetType().GetCustomAttribute<TaskAttribute>();
|
||||
if (taskAttribute != null)
|
||||
BuildLogger.Log($"---------------------------------------->{taskAttribute.TaskDesc}<---------------------------------------");
|
||||
string taskName = task.GetType().Name.Split('_')[0];
|
||||
BuildLogger.Log($"--------------------------------------------->{taskName}<--------------------------------------------");
|
||||
task.Run(context);
|
||||
_buildWatch.Stop();
|
||||
|
||||
// 统计耗时
|
||||
int seconds = GetBuildSeconds();
|
||||
TotalSeconds += seconds;
|
||||
if (taskAttribute != null)
|
||||
BuildLogger.Log($"{taskAttribute.TaskDesc}耗时:{seconds}秒");
|
||||
BuildLogger.Log($"{taskName} It takes {seconds} seconds in total");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -59,7 +57,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
// 返回运行结果
|
||||
BuildLogger.Log($"构建过程总计耗时:{TotalSeconds}秒");
|
||||
BuildLogger.Log($"Total build process time: {TotalSeconds} seconds");
|
||||
return buildResult;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal enum ErrorCode
|
||||
{
|
||||
// TaskPrepare
|
||||
ThePipelineIsBuiding = 100,
|
||||
FoundUnsavedScene = 101,
|
||||
NoBuildTarget = 110,
|
||||
PackageNameIsNullOrEmpty = 111,
|
||||
PackageVersionIsNullOrEmpty = 112,
|
||||
BuildOutputRootIsNullOrEmpty = 113,
|
||||
BuildinFileRootIsNullOrEmpty = 114,
|
||||
PackageOutputDirectoryExists = 115,
|
||||
RecommendScriptBuildPipeline = 130,
|
||||
BuildPipelineNotSupportBuildMode = 140,
|
||||
|
||||
// TaskGetBuildMap
|
||||
RemoveInvalidTags = 200,
|
||||
FoundUndependedAsset = 201,
|
||||
PackAssetListIsEmpty = 202,
|
||||
NotSupportMultipleRawAsset = 210,
|
||||
|
||||
// TaskBuilding
|
||||
UnityEngineBuildFailed = 300,
|
||||
UnityEngineBuildFatal = 301,
|
||||
|
||||
// TaskUpdateBundleInfo
|
||||
CharactersOverTheLimit = 400,
|
||||
NotFoundUnityBundleHash = 401,
|
||||
NotFoundUnityBundleCRC = 402,
|
||||
|
||||
// TaskVerifyBuildResult
|
||||
UnintendedBuildBundle = 500,
|
||||
UnintendedBuildResult = 501,
|
||||
|
||||
// TaskCreateManifest
|
||||
NotFoundUnityBundleInBuildResult = 600,
|
||||
FoundStrayBundle = 601,
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35749e57d9a3da84aa60c348bc6bbe9d
|
||||
guid: c3a10fd19801c0c428bac53081a96517
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,18 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class TaskAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// 任务说明
|
||||
/// </summary>
|
||||
public string TaskDesc;
|
||||
|
||||
public TaskAttribute(string taskDesc)
|
||||
{
|
||||
TaskDesc = taskDesc;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
private void CreateView(VisualElement parent)
|
||||
{
|
||||
// <EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
// 加载布局文件
|
||||
var visualAsset = UxmlLoader.LoadWindowUXML<BuildPipelineViewerBase>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
@@ -48,25 +48,25 @@ namespace YooAsset.Editor
|
||||
Root.style.flexGrow = 1f;
|
||||
parent.Add(Root);
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼
|
||||
// 输出目录
|
||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
_buildOutputField = Root.Q<TextField>("BuildOutput");
|
||||
_buildOutputField.SetValueWithoutNotify(defaultOutputRoot);
|
||||
_buildOutputField.SetEnabled(false);
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>汾
|
||||
// 构建版本
|
||||
_buildVersionField = Root.Q<TextField>("BuildVersion");
|
||||
_buildVersionField.style.width = StyleWidth;
|
||||
_buildVersionField.SetValueWithoutNotify(GetDefaultPackageVersion());
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
// 构建模式
|
||||
{
|
||||
var buildModeContainer = Root.Q("BuildModeContainer");
|
||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
||||
var buildModeList = GetSupportBuildModes();
|
||||
int defaultIndex = buildModeList.FindIndex(x => x.Equals(buildMode));
|
||||
_buildModeField = new PopupField<Enum>(buildModeList, defaultIndex);
|
||||
_buildModeField.label = "BuildMode";
|
||||
_buildModeField.label = "Build Mode";
|
||||
_buildModeField.style.width = StyleWidth;
|
||||
_buildModeField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
@@ -75,7 +75,7 @@ namespace YooAsset.Editor
|
||||
buildModeContainer.Add(_buildModeField);
|
||||
}
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD>ܷ<EFBFBD><EFBFBD><EFBFBD>
|
||||
// 加密方法
|
||||
{
|
||||
var encryptionContainer = Root.Q("EncryptionContainer");
|
||||
var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
||||
@@ -101,7 +101,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
}
|
||||
|
||||
// ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽѡ<EFBFBD><EFBFBD>
|
||||
// 压缩方式选项
|
||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
||||
_compressionField = Root.Q<EnumField>("Compression");
|
||||
_compressionField.Init(compressOption);
|
||||
@@ -112,7 +112,7 @@ namespace YooAsset.Editor
|
||||
AssetBundleBuilderSetting.SetPackageCompressOption(PackageName, BuildPipeline, (ECompressOption)_compressionField.value);
|
||||
});
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
||||
// 输出文件名称样式
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||
_outputNameStyleField = Root.Q<EnumField>("FileNameStyle");
|
||||
_outputNameStyleField.Init(fileNameStyle);
|
||||
@@ -123,7 +123,7 @@ namespace YooAsset.Editor
|
||||
AssetBundleBuilderSetting.SetPackageFileNameStyle(PackageName, BuildPipeline, (EFileNameStyle)_outputNameStyleField.value);
|
||||
});
|
||||
|
||||
// <EFBFBD>װ<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>
|
||||
// 首包文件拷贝选项
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||
_copyBuildinFileOptionField = Root.Q<EnumField>("CopyBuildinFileOption");
|
||||
_copyBuildinFileOptionField.Init(buildinFileCopyOption);
|
||||
@@ -135,16 +135,16 @@ namespace YooAsset.Editor
|
||||
RefreshView();
|
||||
});
|
||||
|
||||
// <EFBFBD>װ<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// 首包文件拷贝参数
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||
_copyBuildinFileTagsField = Root.Q<TextField>("CopyBuildinFileTags");
|
||||
_copyBuildinFileTagsField = Root.Q<TextField>("CopyBuildinFileParam");
|
||||
_copyBuildinFileTagsField.SetValueWithoutNotify(buildinFileCopyParams);
|
||||
_copyBuildinFileTagsField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageBuildinFileCopyParams(PackageName, BuildPipeline, _copyBuildinFileTagsField.value);
|
||||
});
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť
|
||||
// 构建按钮
|
||||
var buildButton = Root.Q<Button>("Build");
|
||||
buildButton.clicked += BuildButton_clicked;
|
||||
}
|
||||
@@ -157,29 +157,29 @@ namespace YooAsset.Editor
|
||||
private void BuildButton_clicked()
|
||||
{
|
||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
||||
if (EditorUtility.DisplayDialog("<EFBFBD><EFBFBD>ʾ", $"ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD>{buildMode}<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "Yes", "No"))
|
||||
if (EditorUtility.DisplayDialog("提示", $"通过构建模式【{buildMode}】来构建!", "Yes", "No"))
|
||||
{
|
||||
EditorTools.ClearUnityConsole();
|
||||
EditorApplication.delayCall += ExecuteBuild;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("[Build] <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD>ȡ<EFBFBD><EFBFBD>");
|
||||
Debug.LogWarning("[Build] 打包已经取消");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ִ<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// 执行构建任务
|
||||
/// </summary>
|
||||
protected abstract void ExecuteBuild();
|
||||
|
||||
/// <summary>
|
||||
/// <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD>ֵĹ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// 获取构建管线支持的构建模式集合
|
||||
/// </summary>
|
||||
protected abstract List<Enum> GetSupportBuildModes();
|
||||
|
||||
/// <summary>
|
||||
/// <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>汾
|
||||
/// 获取构建版本
|
||||
/// </summary>
|
||||
protected string GetPackageVersion()
|
||||
{
|
||||
@@ -187,7 +187,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD>
|
||||
/// 创建加密类实例
|
||||
/// </summary>
|
||||
protected IEncryptionServices CreateEncryptionInstance()
|
||||
{
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
<uie:EnumField label="Compression" value="Center" name="Compression" />
|
||||
<uie:EnumField label="File Name Style" value="Center" name="FileNameStyle" />
|
||||
<uie:EnumField label="Copy Buildin File Option" value="Center" name="CopyBuildinFileOption" />
|
||||
<ui:TextField picking-mode="Ignore" label="Copy Buildin File Tags" name="CopyBuildinFileTags" />
|
||||
<ui:TextField picking-mode="Ignore" label="Copy Buildin File Param" name="CopyBuildinFileParam" />
|
||||
<ui:VisualElement name="ExtensionContainer" />
|
||||
<ui:Button text="构建" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
|
||||
<ui:Button text="Click Build" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace YooAsset.Editor
|
||||
AssetBundleCollectorSettingData.Setting.UniqueBundleName = uniqueBundleName;
|
||||
AssetBundleCollectorSettingData.Setting.Packages.AddRange(packages);
|
||||
AssetBundleCollectorSettingData.SaveFile();
|
||||
Debug.Log($"导入配置完毕!");
|
||||
Debug.Log($"Asset bundle collector config import complete!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -245,7 +245,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 生成配置文件
|
||||
xmlDoc.Save(savePath);
|
||||
Debug.Log($"导出配置完毕!");
|
||||
Debug.Log($"Asset bundle collector config export complete!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -92,7 +92,6 @@ namespace YooAsset.Editor
|
||||
List<Type> types = new List<Type>(100)
|
||||
{
|
||||
typeof(AddressByFileName),
|
||||
typeof(AddressByFilePath),
|
||||
typeof(AddressByFolderAndFileName),
|
||||
typeof(AddressByGroupAndFileName),
|
||||
typeof(AddressDisable)
|
||||
@@ -266,7 +265,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{nameof(IActiveRule)}类型无效:{ruleName}");
|
||||
throw new Exception($"{nameof(IActiveRule)} is invalid:{ruleName}");
|
||||
}
|
||||
}
|
||||
public static IAddressRule GetAddressRuleInstance(string ruleName)
|
||||
@@ -283,7 +282,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{nameof(IAddressRule)}类型无效:{ruleName}");
|
||||
throw new Exception($"{nameof(IAddressRule)} is invalid:{ruleName}");
|
||||
}
|
||||
}
|
||||
public static IPackRule GetPackRuleInstance(string ruleName)
|
||||
@@ -300,7 +299,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{nameof(IPackRule)}类型无效:{ruleName}");
|
||||
throw new Exception($"{nameof(IPackRule)} is invalid:{ruleName}");
|
||||
}
|
||||
}
|
||||
public static IFilterRule GetFilterRuleInstance(string ruleName)
|
||||
@@ -317,7 +316,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{nameof(IFilterRule)}类型无效:{ruleName}");
|
||||
throw new Exception($"{nameof(IFilterRule)} is invalid:{ruleName}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace YooAsset.Editor
|
||||
[MenuItem("YooAsset/AssetBundle Collector", false, 101)]
|
||||
public static void OpenWindow()
|
||||
{
|
||||
AssetBundleCollectorWindow window = GetWindow<AssetBundleCollectorWindow>("资源包收集工具", true, WindowsDefine.DockedWindowTypes);
|
||||
AssetBundleCollectorWindow window = GetWindow<AssetBundleCollectorWindow>("AssetBundle Collector", true, WindowsDefine.DockedWindowTypes);
|
||||
window.minSize = new Vector2(800, 600);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace YooAsset.Editor
|
||||
private ListView _groupListView;
|
||||
private TextField _groupNameTxt;
|
||||
private TextField _groupDescTxt;
|
||||
private TextField _groupAssetTagsTxt;
|
||||
private TextField _groupTagsTxt;
|
||||
|
||||
private VisualElement _collectorContainer;
|
||||
private ScrollView _collectorScrollView;
|
||||
@@ -106,7 +106,7 @@ namespace YooAsset.Editor
|
||||
AssetBundleCollectorSettingData.ModifyShowPackageView(evt.newValue);
|
||||
RefreshWindow();
|
||||
});
|
||||
_showEditorAliasToggle = root.Q<Toggle>("ShowEditorAlias");
|
||||
_showEditorAliasToggle = root.Q<Toggle>("ShowRuleAlias");
|
||||
_showEditorAliasToggle.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleCollectorSettingData.ModifyShowEditorAlias(evt.newValue);
|
||||
@@ -290,8 +290,8 @@ namespace YooAsset.Editor
|
||||
});
|
||||
|
||||
// 分组的资源标签
|
||||
_groupAssetTagsTxt = root.Q<TextField>("GroupAssetTags");
|
||||
_groupAssetTagsTxt.RegisterValueChangedCallback(evt =>
|
||||
_groupTagsTxt = root.Q<TextField>("GroupTags");
|
||||
_groupTagsTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
@@ -320,7 +320,7 @@ namespace YooAsset.Editor
|
||||
// 分组激活规则
|
||||
var activeRuleContainer = root.Q("ActiveRuleContainer");
|
||||
{
|
||||
_activeRulePopupField = new PopupField<RuleDisplayName>("Active Rule", _activeRuleList, 0);
|
||||
_activeRulePopupField = new PopupField<RuleDisplayName>("Group Active", _activeRuleList, 0);
|
||||
_activeRulePopupField.name = "ActiveRuleMaskField";
|
||||
_activeRulePopupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
_activeRulePopupField.formatListItemCallback = FormatListItemCallback;
|
||||
@@ -463,8 +463,9 @@ namespace YooAsset.Editor
|
||||
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||
if (selectPackage != null)
|
||||
{
|
||||
string packageSettingName = "Package Settings";
|
||||
_packageSettingsButton.SetEnabled(true);
|
||||
_packageSettingsButton.text = $"Package Setting ({selectPackage.PackageName})";
|
||||
_packageSettingsButton.text = $"{packageSettingName} ({selectPackage.PackageName})";
|
||||
_enableAddressableToogle.SetValueWithoutNotify(selectPackage.EnableAddressable);
|
||||
_locationToLowerToogle.SetValueWithoutNotify(selectPackage.LocationToLower);
|
||||
_includeAssetGUIDToogle.SetValueWithoutNotify(selectPackage.IncludeAssetGUID);
|
||||
@@ -496,13 +497,15 @@ namespace YooAsset.Editor
|
||||
|
||||
if (_enableAddressableToogle.value && _locationToLowerToogle.value)
|
||||
{
|
||||
var helpBox = new HelpBox("无法同时开启[Enable Addressable]选项和[Location To Lower]选项", HelpBoxMessageType.Error);
|
||||
string tips = "The [Enable Addressable] option and [Location To Lower] option cannot be enabled at the same time.";
|
||||
var helpBox = new HelpBox(tips, HelpBoxMessageType.Error);
|
||||
_helpBoxContainer.Add(helpBox);
|
||||
}
|
||||
|
||||
if (AssetBundleCollectorSettingData.Setting.Packages.Count > 1 && _uniqueBundleNameToogle.value == false)
|
||||
{
|
||||
var helpBox = new HelpBox("检测到当前配置存在多个Package,建议开启[Unique Bundle Name]选项", HelpBoxMessageType.Warning);
|
||||
string tips = "There are multiple Packages in the current config, Recommended to enable the [Unique Bundle Name] option.";
|
||||
var helpBox = new HelpBox(tips, HelpBoxMessageType.Warning);
|
||||
_helpBoxContainer.Add(helpBox);
|
||||
}
|
||||
|
||||
@@ -654,7 +657,7 @@ namespace YooAsset.Editor
|
||||
_activeRulePopupField.SetValueWithoutNotify(GetActiveRuleIndex(selectGroup.ActiveRuleName));
|
||||
_groupNameTxt.SetValueWithoutNotify(selectGroup.GroupName);
|
||||
_groupDescTxt.SetValueWithoutNotify(selectGroup.GroupDesc);
|
||||
_groupAssetTagsTxt.SetValueWithoutNotify(selectGroup.AssetTags);
|
||||
_groupTagsTxt.SetValueWithoutNotify(selectGroup.AssetTags);
|
||||
|
||||
FillCollectorViewData();
|
||||
}
|
||||
@@ -778,7 +781,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
var textField = new TextField();
|
||||
textField.name = "TextField0";
|
||||
textField.label = "UserData";
|
||||
textField.label = "User Data";
|
||||
textField.style.width = 200;
|
||||
elementBottom.Add(textField);
|
||||
var label = textField.Q<Label>();
|
||||
@@ -787,7 +790,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
var textField = new TextField();
|
||||
textField.name = "TextField1";
|
||||
textField.label = "Tags";
|
||||
textField.label = "Asset Tags";
|
||||
textField.style.width = 100;
|
||||
textField.style.marginLeft = 20;
|
||||
textField.style.flexGrow = 1;
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
|
||||
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;">
|
||||
<ui:Button text="Save" display-tooltip-when-elided="true" name="SaveButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="导出" display-tooltip-when-elided="true" name="ExportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="导入" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="修复" display-tooltip-when-elided="true" name="FixButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="Export" display-tooltip-when-elided="true" name="ExportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="Import" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="Fix" display-tooltip-when-elided="true" name="FixButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
</uie:Toolbar>
|
||||
<ui:VisualElement name="PublicContainer" style="background-color: rgb(79, 79, 79); flex-direction: column; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||
<ui:VisualElement name="PublicContainer" style="background-color: rgb(79, 79, 79); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||
<ui:VisualElement name="HelpBoxContainer" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="GlobalSettingsContainer">
|
||||
<ui:Button text="Global Settings" name="GlobalSettingsButton" />
|
||||
<ui:VisualElement name="PublicContainer1" style="flex-direction: row; flex-wrap: nowrap; height: 28px;">
|
||||
<ui:VisualElement name="PublicContainer1">
|
||||
<ui:Toggle label="Show Packages" name="ShowPackages" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
<ui:Toggle label="Show Editor Alias" name="ShowEditorAlias" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
<ui:Toggle label="Show Rule Alias" name="ShowRuleAlias" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
<ui:Toggle label="Unique Bundle Name" name="UniqueBundleName" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="PackageSettingsContainer">
|
||||
<ui:Button text="Package Settings" display-tooltip-when-elided="true" name="PackageSettingsButton" />
|
||||
<ui:VisualElement name="PublicContainer2" style="flex-direction: row; flex-wrap: nowrap; height: 28px;">
|
||||
<ui:VisualElement name="PublicContainer2">
|
||||
<ui:Toggle label="Enable Addressable" name="EnableAddressable" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
<ui:Toggle label="Location To Lower" name="LocationToLower" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
<ui:Toggle label="Include Asset GUID" name="IncludeAssetGUID" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
@@ -50,7 +50,7 @@
|
||||
<ui:VisualElement name="ActiveRuleContainer" style="height: 20px;" />
|
||||
<ui:TextField picking-mode="Ignore" label="Group Name" name="GroupName" />
|
||||
<ui:TextField picking-mode="Ignore" label="Group Desc" name="GroupDesc" />
|
||||
<ui:TextField picking-mode="Ignore" label="Group Asset Tags" name="GroupAssetTags" />
|
||||
<ui:TextField picking-mode="Ignore" label="Asset Tags" name="GroupTags" />
|
||||
<ui:VisualElement name="CollectorAddContainer" style="height: 20px; flex-direction: row-reverse;">
|
||||
<ui:Button text="[ + ]" display-tooltip-when-elided="true" name="AddBtn" />
|
||||
</ui:VisualElement>
|
||||
|
||||
@@ -20,15 +20,6 @@ namespace YooAsset.Editor
|
||||
}
|
||||
}
|
||||
|
||||
[DisplayName("定位地址: 文件路径")]
|
||||
public class AddressByFilePath : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
{
|
||||
throw new System.Exception("可寻址模式下已经默认支持通过资源路径加载!");
|
||||
}
|
||||
}
|
||||
|
||||
[DisplayName("定位地址: 分组名_文件名")]
|
||||
public class AddressByGroupAndFileName : IAddressRule
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace YooAsset.Editor
|
||||
[MenuItem("YooAsset/AssetBundle Debugger", false, 104)]
|
||||
public static void OpenWindow()
|
||||
{
|
||||
AssetBundleDebuggerWindow wnd = GetWindow<AssetBundleDebuggerWindow>("资源包调试工具", true, WindowsDefine.DockedWindowTypes);
|
||||
AssetBundleDebuggerWindow wnd = GetWindow<AssetBundleDebuggerWindow>("AssetBundle Debugger", true, WindowsDefine.DockedWindowTypes);
|
||||
wnd.minSize = new Vector2(800, 600);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
||||
<uie:Toolbar name="TopToolbar" style="display: flex;">
|
||||
<ui:Label text="Player" display-tooltip-when-elided="true" name="PlayerName" style="width: 200px; -unity-text-align: middle-left; padding-left: 5px;" />
|
||||
<ui:Label text="Player" display-tooltip-when-elided="true" name="PlayerName" style="width: 200px; -unity-text-align: lower-left; padding-left: 5px;" />
|
||||
<uie:ToolbarMenu display-tooltip-when-elided="true" name="ViewModeMenu" text="ViewMode" style="width: 100px; flex-grow: 0;" />
|
||||
<uie:ToolbarSearchField focusable="true" name="SearchField" style="flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="刷新" display-tooltip-when-elided="true" name="SampleButton" style="width: 70px; background-color: rgb(15, 118, 31); -unity-text-align: middle-center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-left-width: 1px; border-right-width: 1px;" />
|
||||
<uie:ToolbarButton text="导出" display-tooltip-when-elided="true" name="ExportButton" style="width: 70px; background-color: rgb(15, 118, 31); -unity-text-align: middle-center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-left-width: 1px; border-right-width: 1px;" />
|
||||
<uie:ToolbarButton text="Refresh" display-tooltip-when-elided="true" name="SampleButton" style="width: 70px; background-color: rgb(15, 118, 31); -unity-text-align: middle-center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-left-width: 1px; border-right-width: 1px;" />
|
||||
<uie:ToolbarButton text="Export" display-tooltip-when-elided="true" name="ExportButton" style="width: 70px; background-color: rgb(15, 118, 31); -unity-text-align: middle-center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-left-width: 1px; border-right-width: 1px;" />
|
||||
</uie:Toolbar>
|
||||
<uie:Toolbar name="FrameToolbar">
|
||||
<ui:SliderInt picking-mode="Ignore" label="Frame:" value="42" high-value="100" name="FrameSlider" style="flex-grow: 1;" />
|
||||
|
||||
@@ -224,7 +224,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// Status
|
||||
StyleColor textColor;
|
||||
if (providerInfo.Status == ProviderBase.EStatus.Failed.ToString())
|
||||
if (providerInfo.Status == EOperationStatus.Failed.ToString())
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = label1.style.color;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace YooAsset.Editor
|
||||
[MenuItem("YooAsset/AssetBundle Reporter", false, 103)]
|
||||
public static void OpenWindow()
|
||||
{
|
||||
AssetBundleReporterWindow window = GetWindow<AssetBundleReporterWindow>("资源包报告工具", true, WindowsDefine.DockedWindowTypes);
|
||||
AssetBundleReporterWindow window = GetWindow<AssetBundleReporterWindow>("AssetBundle Reporter", true, WindowsDefine.DockedWindowTypes);
|
||||
window.minSize = new Vector2(800, 600);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
<uie:Toolbar name="Toolbar" style="display: flex;">
|
||||
<uie:ToolbarMenu display-tooltip-when-elided="true" name="ViewModeMenu" text="ViewMode" style="width: 100px; flex-grow: 0;" />
|
||||
<uie:ToolbarSearchField focusable="true" name="SearchField" style="width: 300px; flex-grow: 1;" />
|
||||
<ui:Button text="导入" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="Import" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
</uie:Toolbar>
|
||||
</ui:UXML>
|
||||
|
||||
@@ -53,32 +53,16 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public string BuildPackageVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 启用可寻址资源定位
|
||||
/// </summary>
|
||||
public bool EnableAddressable;
|
||||
|
||||
/// <summary>
|
||||
/// 资源定位地址大小写不敏感
|
||||
/// </summary>
|
||||
public bool LocationToLower;
|
||||
|
||||
/// <summary>
|
||||
/// 包含资源GUID数据
|
||||
/// </summary>
|
||||
public bool IncludeAssetGUID;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名唯一化
|
||||
/// </summary>
|
||||
// 收集器配置
|
||||
public bool UniqueBundleName;
|
||||
|
||||
/// <summary>
|
||||
/// 加密服务类名称
|
||||
/// </summary>
|
||||
public string EncryptionServicesClassName;
|
||||
public bool EnableAddressable;
|
||||
public bool LocationToLower;
|
||||
public bool IncludeAssetGUID;
|
||||
public bool IgnoreDefaultType;
|
||||
public bool AutoCollectShaders;
|
||||
|
||||
// 构建参数
|
||||
public string EncryptionClassName;
|
||||
public EFileNameStyle FileNameStyle;
|
||||
public ECompressOption CompressOption;
|
||||
public bool DisableWriteTypeTree;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements">
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Asset Path" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
@@ -9,8 +9,8 @@
|
||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Depend Bundles" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Size" display-tooltip-when-elided="true" name="BottomBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Hash" display-tooltip-when-elided="true" name="BottomBar3" style="width: 280px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="File Size" display-tooltip-when-elided="true" name="BottomBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="File Hash" display-tooltip-when-elided="true" name="BottomBar3" style="width: 280px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Size" display-tooltip-when-elided="true" name="TopBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Hash" display-tooltip-when-elided="true" name="TopBar3" style="width: 280px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="File Size" display-tooltip-when-elided="true" name="TopBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="File Hash" display-tooltip-when-elided="true" name="TopBar3" style="width: 280px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Encrypted" display-tooltip-when-elided="true" name="TopBar4" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Tags" display-tooltip-when-elided="true" name="TopBar5" style="width: 80px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
</uie:Toolbar>
|
||||
|
||||
@@ -56,38 +56,41 @@ namespace YooAsset.Editor
|
||||
{
|
||||
_items.Clear();
|
||||
|
||||
_items.Add(new ItemWrapper("YooAsset版本", buildReport.Summary.YooVersion));
|
||||
_items.Add(new ItemWrapper("引擎版本", buildReport.Summary.UnityVersion));
|
||||
_items.Add(new ItemWrapper("构建时间", buildReport.Summary.BuildDate));
|
||||
_items.Add(new ItemWrapper("构建耗时", ConvertTime(buildReport.Summary.BuildSeconds)));
|
||||
_items.Add(new ItemWrapper("构建平台", $"{buildReport.Summary.BuildTarget}"));
|
||||
_items.Add(new ItemWrapper("构建管线", $"{buildReport.Summary.BuildPipeline}"));
|
||||
_items.Add(new ItemWrapper("构建模式", $"{buildReport.Summary.BuildMode}"));
|
||||
_items.Add(new ItemWrapper("包裹名称", buildReport.Summary.BuildPackageName));
|
||||
_items.Add(new ItemWrapper("包裹版本", buildReport.Summary.BuildPackageVersion));
|
||||
_items.Add(new ItemWrapper("YooAsset Version", buildReport.Summary.YooVersion));
|
||||
_items.Add(new ItemWrapper("UnityEngine Version", buildReport.Summary.UnityVersion));
|
||||
_items.Add(new ItemWrapper("Build Date", buildReport.Summary.BuildDate));
|
||||
_items.Add(new ItemWrapper("Build Seconds", ConvertTime(buildReport.Summary.BuildSeconds)));
|
||||
_items.Add(new ItemWrapper("Build Target", $"{buildReport.Summary.BuildTarget}"));
|
||||
_items.Add(new ItemWrapper("Build Pipeline", $"{buildReport.Summary.BuildPipeline}"));
|
||||
_items.Add(new ItemWrapper("Build Mode", $"{buildReport.Summary.BuildMode}"));
|
||||
_items.Add(new ItemWrapper("Package Name", buildReport.Summary.BuildPackageName));
|
||||
_items.Add(new ItemWrapper("Package Version", buildReport.Summary.BuildPackageVersion));
|
||||
|
||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||
_items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}"));
|
||||
_items.Add(new ItemWrapper("资源定位地址大小写不敏感", $"{buildReport.Summary.LocationToLower}"));
|
||||
_items.Add(new ItemWrapper("包含资源GUID数据", $"{buildReport.Summary.IncludeAssetGUID}"));
|
||||
_items.Add(new ItemWrapper("资源包名唯一化", $"{buildReport.Summary.UniqueBundleName}"));
|
||||
_items.Add(new ItemWrapper("资源加密服务类", buildReport.Summary.EncryptionServicesClassName));
|
||||
_items.Add(new ItemWrapper("Settings", string.Empty));
|
||||
_items.Add(new ItemWrapper("Unique Bundle Name", $"{buildReport.Summary.UniqueBundleName}"));
|
||||
_items.Add(new ItemWrapper("Enable Addressable", $"{buildReport.Summary.EnableAddressable}"));
|
||||
_items.Add(new ItemWrapper("Location To Lower", $"{buildReport.Summary.LocationToLower}"));
|
||||
_items.Add(new ItemWrapper("Include Asset GUID", $"{buildReport.Summary.IncludeAssetGUID}"));
|
||||
_items.Add(new ItemWrapper("Ignore Default Type", $"{buildReport.Summary.IgnoreDefaultType}"));
|
||||
_items.Add(new ItemWrapper("Auto Collect Shaders", $"{buildReport.Summary.AutoCollectShaders}"));
|
||||
|
||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||
_items.Add(new ItemWrapper("构建参数", string.Empty));
|
||||
_items.Add(new ItemWrapper("Build Params", string.Empty));
|
||||
_items.Add(new ItemWrapper("Encryption Class Name", buildReport.Summary.EncryptionClassName));
|
||||
_items.Add(new ItemWrapper("FileNameStyle", $"{buildReport.Summary.FileNameStyle}"));
|
||||
_items.Add(new ItemWrapper("CompressOption", $"{buildReport.Summary.CompressOption}"));
|
||||
_items.Add(new ItemWrapper("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}"));
|
||||
_items.Add(new ItemWrapper("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}"));
|
||||
|
||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||
_items.Add(new ItemWrapper("构建结果", string.Empty));
|
||||
_items.Add(new ItemWrapper("构建文件总数", $"{buildReport.Summary.AssetFileTotalCount}"));
|
||||
_items.Add(new ItemWrapper("主资源总数", $"{buildReport.Summary.MainAssetTotalCount}"));
|
||||
_items.Add(new ItemWrapper("资源包总数", $"{buildReport.Summary.AllBundleTotalCount}"));
|
||||
_items.Add(new ItemWrapper("资源包总大小", ConvertSize(buildReport.Summary.AllBundleTotalSize)));
|
||||
_items.Add(new ItemWrapper("加密资源包总数", $"{buildReport.Summary.EncryptedBundleTotalCount}"));
|
||||
_items.Add(new ItemWrapper("加密资源包总大小", ConvertSize(buildReport.Summary.EncryptedBundleTotalSize)));
|
||||
_items.Add(new ItemWrapper("Build Results", string.Empty));
|
||||
_items.Add(new ItemWrapper("Asset File Total Count", $"{buildReport.Summary.AssetFileTotalCount}"));
|
||||
_items.Add(new ItemWrapper("Main Asset Total Count", $"{buildReport.Summary.MainAssetTotalCount}"));
|
||||
_items.Add(new ItemWrapper("All Bundle Total Count", $"{buildReport.Summary.AllBundleTotalCount}"));
|
||||
_items.Add(new ItemWrapper("All Bundle Total Size", ConvertSize(buildReport.Summary.AllBundleTotalSize)));
|
||||
_items.Add(new ItemWrapper("Encrypted Bundle Total Count", $"{buildReport.Summary.EncryptedBundleTotalCount}"));
|
||||
_items.Add(new ItemWrapper("Encrypted Bundle Total Size", ConvertSize(buildReport.Summary.EncryptedBundleTotalSize)));
|
||||
|
||||
_listView.Clear();
|
||||
_listView.ClearSelection();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
|
||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="概览" display-tooltip-when-elided="true" name="TopBar1" style="width: 200px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="参数" display-tooltip-when-elided="true" name="TopBar2" style="width: 150px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Info" display-tooltip-when-elided="true" name="TopBar1" style="width: 200px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Param" display-tooltip-when-elided="true" name="TopBar2" style="width: 150px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="ListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System;
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -13,5 +12,4 @@ namespace YooAsset.Editor
|
||||
Application.OpenURL("https://www.yooasset.com/");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -26,11 +26,11 @@ namespace YooAsset
|
||||
{
|
||||
_cache = cache;
|
||||
}
|
||||
internal override void Start()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.GetAllCacheFiles;
|
||||
}
|
||||
internal override void Update()
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
@@ -28,11 +28,11 @@ namespace YooAsset
|
||||
_package = package;
|
||||
_cache = cache;
|
||||
}
|
||||
internal override void Start()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.GetUnusedCacheFiles;
|
||||
}
|
||||
internal override void Update()
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
@@ -31,12 +31,12 @@ namespace YooAsset
|
||||
_persistent = persistent;
|
||||
_cache = cache;
|
||||
}
|
||||
internal override void Start()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.Prepare;
|
||||
_verifyStartTime = UnityEngine.Time.realtimeSinceStartup;
|
||||
}
|
||||
internal override void Update()
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
@@ -48,12 +48,12 @@ namespace YooAsset
|
||||
_cache = cache;
|
||||
_waitingList = elements;
|
||||
}
|
||||
internal override void Start()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.InitVerify;
|
||||
_verifyStartTime = UnityEngine.Time.realtimeSinceStartup;
|
||||
}
|
||||
internal override void Update()
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -175,12 +175,12 @@ namespace YooAsset
|
||||
_cache = cache;
|
||||
_waitingList = elements;
|
||||
}
|
||||
internal override void Start()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.InitVerify;
|
||||
_verifyStartTime = UnityEngine.Time.realtimeSinceStartup;
|
||||
}
|
||||
internal override void Update()
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
@@ -41,11 +41,11 @@ namespace YooAsset
|
||||
{
|
||||
_element = element;
|
||||
}
|
||||
internal override void Start()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.VerifyFile;
|
||||
}
|
||||
internal override void Update()
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -110,11 +110,11 @@ namespace YooAsset
|
||||
{
|
||||
_element = element;
|
||||
}
|
||||
internal override void Start()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.VerifyFile;
|
||||
}
|
||||
internal override void Update()
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
@@ -26,11 +26,11 @@ namespace YooAsset
|
||||
_persistent = persistent;
|
||||
_cache = cache;
|
||||
}
|
||||
internal override void Start()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.FindCacheFiles;
|
||||
}
|
||||
internal override void Update()
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
@@ -10,13 +10,17 @@ namespace YooAsset
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
return StringUtility.Format("file:///{0}", path);
|
||||
#elif UNITY_WEBGL
|
||||
return path;
|
||||
#elif UNITY_IPHONE
|
||||
return StringUtility.Format("file://{0}", path);
|
||||
#elif UNITY_ANDROID
|
||||
return path;
|
||||
#elif UNITY_STANDALONE_OSX
|
||||
return new System.Uri(path).ToString();
|
||||
#elif UNITY_STANDALONE
|
||||
return StringUtility.Format("file:///{0}", path);
|
||||
#elif UNITY_WEBGL
|
||||
#else
|
||||
return path;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace YooAsset
|
||||
DownloaderBase newDownloader = null;
|
||||
YooLogger.Log($"Beginning to download bundle : {bundleInfo.Bundle.BundleName} URL : {bundleInfo.RemoteMainURL}");
|
||||
#if UNITY_WEBGL
|
||||
if (bundleInfo.Bundle.Buildpipeline == DefaultBuildPipeline.RawFileBuildPipelineName)
|
||||
if (bundleInfo.Bundle.Buildpipeline == EDefaultBuildPipeline.RawFileBuildPipeline.ToString())
|
||||
{
|
||||
FileUtility.CreateFileDirectory(bundleInfo.CachedDataFilePath);
|
||||
System.Type requesterType = typeof(FileGeneralRequest);
|
||||
@@ -147,4 +147,4 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace YooAsset
|
||||
if (_steps == ESteps.WaitingVerifyTempFile)
|
||||
{
|
||||
if (WaitForAsyncComplete)
|
||||
_verifyFileOp.Update();
|
||||
_verifyFileOp.InternalOnUpdate();
|
||||
|
||||
if (_verifyFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -4,11 +4,22 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 默认的构建管线
|
||||
/// </summary>
|
||||
public class DefaultBuildPipeline
|
||||
public enum EDefaultBuildPipeline
|
||||
{
|
||||
public const string BuiltinBuildPipelineName = "BuiltinBuildPipeline";
|
||||
public const string ScriptableBuildPipelineName = "ScriptableBuildPipeline";
|
||||
public const string RawFileBuildPipelineName = "RawFileBuildPipeline";
|
||||
/// <summary>
|
||||
/// 内置构建管线
|
||||
/// </summary>
|
||||
BuiltinBuildPipeline,
|
||||
|
||||
/// <summary>
|
||||
/// 可编程构建管线
|
||||
/// </summary>
|
||||
ScriptableBuildPipeline,
|
||||
|
||||
/// <summary>
|
||||
/// 原生文件构建管线
|
||||
/// </summary>
|
||||
RawFileBuildPipeline,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -65,10 +76,9 @@ namespace YooAsset
|
||||
public EVerifyLevel CacheBootVerifyLevel = EVerifyLevel.Middle;
|
||||
|
||||
/// <summary>
|
||||
/// 资源加载每帧处理的最大时间片段
|
||||
/// 注意:默认值为MaxValue
|
||||
/// 自动销毁不再使用的资源提供者
|
||||
/// </summary>
|
||||
public long LoadingMaxTimeSlice = long.MaxValue;
|
||||
public bool AutoDestroyAssetProvider = false;
|
||||
|
||||
/// <summary>
|
||||
/// 启用断点续传参数
|
||||
|
||||
@@ -5,16 +5,24 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public abstract class AsyncOperationBase : IEnumerator
|
||||
public abstract class AsyncOperationBase : IEnumerator, IComparable<AsyncOperationBase>
|
||||
{
|
||||
// 用户请求的回调
|
||||
private Action<AsyncOperationBase> _callback;
|
||||
|
||||
// 是否已经完成
|
||||
internal bool IsFinish = false;
|
||||
|
||||
/// <summary>
|
||||
/// 所属包裹
|
||||
/// </summary>
|
||||
public string PackageName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 优先级
|
||||
/// </summary>
|
||||
public uint Priority { set; get; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
@@ -76,13 +84,32 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
internal abstract void Start();
|
||||
internal abstract void Update();
|
||||
internal abstract void InternalOnStart();
|
||||
internal abstract void InternalOnUpdate();
|
||||
internal virtual void InternalOnAbort() { }
|
||||
|
||||
internal void SetPackageName(string packageName)
|
||||
internal void Init(string packageName)
|
||||
{
|
||||
PackageName = packageName;
|
||||
}
|
||||
internal void SetStart()
|
||||
{
|
||||
Status = EOperationStatus.Processing;
|
||||
InternalOnStart();
|
||||
}
|
||||
internal void SetFinish()
|
||||
{
|
||||
IsFinish = true;
|
||||
|
||||
// 进度百分百完成
|
||||
Progress = 1f;
|
||||
|
||||
//注意:如果完成回调内发生异常,会导致Task无限期等待
|
||||
_callback?.Invoke(this);
|
||||
|
||||
if (_taskCompletionSource != null)
|
||||
_taskCompletionSource.TrySetResult(null);
|
||||
}
|
||||
internal void SetAbort()
|
||||
{
|
||||
if (IsDone == false)
|
||||
@@ -90,19 +117,9 @@ namespace YooAsset
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "user abort";
|
||||
YooLogger.Warning($"Async operaiton has been abort : {this.GetType().Name}");
|
||||
InternalOnAbort();
|
||||
}
|
||||
}
|
||||
internal void SetFinish()
|
||||
{
|
||||
Progress = 1f;
|
||||
_callback?.Invoke(this); //注意:如果完成回调内发生异常,会导致Task无限期等待
|
||||
if (_taskCompletionSource != null)
|
||||
_taskCompletionSource.TrySetResult(null);
|
||||
}
|
||||
internal void SetStart()
|
||||
{
|
||||
Status = EOperationStatus.Processing;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空完成回调
|
||||
@@ -112,6 +129,13 @@ namespace YooAsset
|
||||
_callback = null;
|
||||
}
|
||||
|
||||
#region 排序接口实现
|
||||
public int CompareTo(AsyncOperationBase other)
|
||||
{
|
||||
return other.Priority.CompareTo(this.Priority);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 异步编程相关
|
||||
bool IEnumerator.MoveNext()
|
||||
{
|
||||
|
||||
@@ -3,14 +3,18 @@ namespace YooAsset
|
||||
{
|
||||
public abstract class GameAsyncOperation : AsyncOperationBase
|
||||
{
|
||||
internal override void Start()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
OnStart();
|
||||
}
|
||||
internal override void Update()
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
OnUpdate();
|
||||
}
|
||||
internal override void InternalOnAbort()
|
||||
{
|
||||
OnAbort();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步操作开始
|
||||
@@ -22,6 +26,11 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
protected abstract void OnUpdate();
|
||||
|
||||
/// <summary>
|
||||
/// 异步操作终止
|
||||
/// </summary>
|
||||
protected abstract void OnAbort();
|
||||
|
||||
/// <summary>
|
||||
/// 异步操作系统是否繁忙
|
||||
/// </summary>
|
||||
|
||||
@@ -45,30 +45,50 @@ namespace YooAsset
|
||||
{
|
||||
_frameTime = _watch.ElapsedMilliseconds;
|
||||
|
||||
// 添加新的异步操作
|
||||
// 添加新增的异步操作
|
||||
if (_newList.Count > 0)
|
||||
{
|
||||
bool sorting = false;
|
||||
foreach (var operation in _newList)
|
||||
{
|
||||
if (operation.Priority > 0)
|
||||
{
|
||||
sorting = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_operations.AddRange(_newList);
|
||||
_newList.Clear();
|
||||
|
||||
// 重新排序优先级
|
||||
if (sorting)
|
||||
_operations.Sort();
|
||||
}
|
||||
|
||||
// 更新所有的异步操作
|
||||
for (int i = _operations.Count - 1; i >= 0; i--)
|
||||
// 更新进行中的异步操作
|
||||
for (int i = 0; i < _operations.Count; i++)
|
||||
{
|
||||
if (IsBusy)
|
||||
break;
|
||||
|
||||
var operation = _operations[i];
|
||||
if (operation.IsFinish)
|
||||
continue;
|
||||
|
||||
if (operation.IsDone == false)
|
||||
operation.InternalOnUpdate();
|
||||
|
||||
if (operation.IsDone)
|
||||
{
|
||||
// 注意:如果业务端发生异常,保证异步操作提前移除。
|
||||
_operations.RemoveAt(i);
|
||||
operation.SetFinish();
|
||||
}
|
||||
else
|
||||
{
|
||||
operation.Update();
|
||||
}
|
||||
}
|
||||
|
||||
// 移除已经完成的异步操作
|
||||
for (int i = _operations.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var operation = _operations[i];
|
||||
if (operation.IsFinish)
|
||||
_operations.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,9 +134,8 @@ namespace YooAsset
|
||||
public static void StartOperation(string packageName, AsyncOperationBase operation)
|
||||
{
|
||||
_newList.Add(operation);
|
||||
operation.SetPackageName(packageName);
|
||||
operation.Init(packageName);
|
||||
operation.SetStart();
|
||||
operation.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,15 +45,7 @@ namespace YooAsset
|
||||
if (IsValidWithWarning == false)
|
||||
return EOperationStatus.None;
|
||||
|
||||
var status = Provider.Status;
|
||||
if (status == ProviderBase.EStatus.None)
|
||||
return EOperationStatus.None;
|
||||
else if (status == ProviderBase.EStatus.Succeed)
|
||||
return EOperationStatus.Succeed;
|
||||
else if (status == ProviderBase.EStatus.Failed)
|
||||
return EOperationStatus.Failed;
|
||||
else
|
||||
return EOperationStatus.Processing;
|
||||
return Provider.Status;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +58,7 @@ namespace YooAsset
|
||||
{
|
||||
if (IsValidWithWarning == false)
|
||||
return string.Empty;
|
||||
return Provider.LastError;
|
||||
return Provider.Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,19 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 场景名称
|
||||
/// </summary>
|
||||
public string SceneName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsValidWithWarning == false)
|
||||
return string.Empty;
|
||||
return Provider.SceneName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 场景对象
|
||||
/// </summary>
|
||||
@@ -152,10 +165,8 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 卸载子场景
|
||||
Scene sceneObject = SceneObject;
|
||||
Provider.Impl.UnloadSubScene(Provider);
|
||||
{
|
||||
var operation = new UnloadSceneOperation(sceneObject);
|
||||
var operation = new UnloadSceneOperation(Provider);
|
||||
OperationSystem.StartOperation(packageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_createRequest != null)
|
||||
{
|
||||
if (_isWaitForAsyncComplete)
|
||||
if (_isWaitForAsyncComplete || IsForceDestroyComplete)
|
||||
{
|
||||
// 强制挂起主线程(注意:该操作会很耗时)
|
||||
YooLogger.Warning("Suspend the main thread to load unity bundle.");
|
||||
|
||||
@@ -45,6 +45,8 @@ namespace YooAsset
|
||||
public bool IsDestroyed { private set; get; } = false;
|
||||
|
||||
private readonly List<ProviderBase> _providers = new List<ProviderBase>(100);
|
||||
private readonly List<ProviderBase> _removeList = new List<ProviderBase>(100);
|
||||
protected bool IsForceDestroyComplete { private set; get; } = false;
|
||||
internal AssetBundle CacheBundle { set; get; }
|
||||
internal string FileLoadPath { set; get; }
|
||||
internal float DownloadProgress { set; get; }
|
||||
@@ -59,15 +61,6 @@ namespace YooAsset
|
||||
Status = EStatus.None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加附属的资源提供者
|
||||
/// </summary>
|
||||
public void AddProvider(ProviderBase provider)
|
||||
{
|
||||
if (_providers.Contains(provider) == false)
|
||||
_providers.Add(provider);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 引用(引用计数递加)
|
||||
/// </summary>
|
||||
@@ -100,39 +93,45 @@ namespace YooAsset
|
||||
if (IsDone() == false)
|
||||
return false;
|
||||
|
||||
if (RefCount > 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return RefCount <= 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在满足条件的前提下,销毁所有资源提供者
|
||||
/// 添加附属的资源提供者
|
||||
/// </summary>
|
||||
public void TryDestroyAllProviders()
|
||||
public void AddProvider(ProviderBase provider)
|
||||
{
|
||||
if (IsDone() == false)
|
||||
return;
|
||||
if (_providers.Contains(provider) == false)
|
||||
_providers.Add(provider);
|
||||
}
|
||||
|
||||
// 条件1:必须等待所有Provider可以销毁
|
||||
/// <summary>
|
||||
/// 尝试销毁资源提供者
|
||||
/// </summary>
|
||||
public void TryDestroyProviders()
|
||||
{
|
||||
// 获取移除列表
|
||||
_removeList.Clear();
|
||||
foreach (var provider in _providers)
|
||||
{
|
||||
if (provider.CanDestroy() == false)
|
||||
return;
|
||||
if (provider.CanDestroy())
|
||||
{
|
||||
_removeList.Add(provider);
|
||||
}
|
||||
}
|
||||
|
||||
// 条件2:除了自己没有其它引用
|
||||
if (RefCount > _providers.Count)
|
||||
return;
|
||||
|
||||
// 销毁所有Providers
|
||||
// 销毁资源提供者
|
||||
foreach (var provider in _removeList)
|
||||
{
|
||||
foreach (var provider in _providers)
|
||||
{
|
||||
provider.Destroy();
|
||||
}
|
||||
Impl.RemoveBundleProviders(_providers);
|
||||
_providers.Clear();
|
||||
_providers.Remove(provider);
|
||||
provider.Destroy();
|
||||
}
|
||||
|
||||
// 移除资源提供者
|
||||
if (_removeList.Count > 0)
|
||||
{
|
||||
Impl.RemoveBundleProviders(_removeList);
|
||||
_removeList.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,6 +161,18 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 强制销毁资源提供者
|
||||
/// </summary>
|
||||
public void ForceDestroyComplete()
|
||||
{
|
||||
IsForceDestroyComplete = true;
|
||||
|
||||
// 注意:主动轮询更新完成同步加载
|
||||
// 说明:如果正在下载或解压也可以放心销毁。
|
||||
Update();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主线程等待异步操作完毕
|
||||
/// </summary>
|
||||
|
||||
@@ -34,11 +34,11 @@ namespace YooAsset
|
||||
_parent = parent;
|
||||
_worldPositionStays = worldPositionStays;
|
||||
}
|
||||
internal override void Start()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.Clone;
|
||||
}
|
||||
internal override void Update()
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -93,7 +93,7 @@ namespace YooAsset
|
||||
if (_steps == ESteps.Done)
|
||||
return;
|
||||
_handle.WaitForAsyncComplete();
|
||||
Update();
|
||||
InternalOnUpdate();
|
||||
}
|
||||
|
||||
internal static GameObject InstantiateInternal(UnityEngine.Object assetObject, bool setPositionAndRotation, Vector3 position, Quaternion rotation, Transform parent, bool worldPositionStays)
|
||||
|
||||
@@ -8,68 +8,82 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public sealed class UnloadSceneOperation : AsyncOperationBase
|
||||
{
|
||||
private enum EFlag
|
||||
{
|
||||
Normal,
|
||||
Error,
|
||||
}
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
UnLoad,
|
||||
CheckError,
|
||||
PrepareDone,
|
||||
UnLoadScene,
|
||||
Checking,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly EFlag _flag;
|
||||
private ESteps _steps = ESteps.None;
|
||||
private Scene _scene;
|
||||
private readonly string _error;
|
||||
private readonly ProviderBase _provider;
|
||||
private AsyncOperation _asyncOp;
|
||||
|
||||
internal UnloadSceneOperation(string error)
|
||||
{
|
||||
_flag = EFlag.Error;
|
||||
Error = error;
|
||||
_error = error;
|
||||
}
|
||||
internal UnloadSceneOperation(Scene scene)
|
||||
internal UnloadSceneOperation(ProviderBase provider)
|
||||
{
|
||||
_flag = EFlag.Normal;
|
||||
_scene = scene;
|
||||
_error = null;
|
||||
_provider = provider;
|
||||
}
|
||||
internal override void Start()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
if (_flag == EFlag.Normal)
|
||||
{
|
||||
_steps = ESteps.UnLoad;
|
||||
}
|
||||
else if (_flag == EFlag.Error)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException(_flag.ToString());
|
||||
}
|
||||
_steps = ESteps.CheckError;
|
||||
}
|
||||
internal override void Update()
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.UnLoad)
|
||||
if (_steps == ESteps.CheckError)
|
||||
{
|
||||
if (_scene.IsValid() && _scene.isLoaded)
|
||||
if (string.IsNullOrEmpty(_error) == false)
|
||||
{
|
||||
_asyncOp = SceneManager.UnloadSceneAsync(_scene);
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
else
|
||||
{
|
||||
Error = "Scene is invalid or is not loaded.";
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _error;
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.PrepareDone;
|
||||
}
|
||||
|
||||
if(_steps == ESteps.PrepareDone)
|
||||
{
|
||||
if (_provider.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_provider.SceneObject.IsValid() == false)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Scene is invalid !";
|
||||
return;
|
||||
}
|
||||
|
||||
if (_provider.SceneObject.isLoaded == false)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Scene is not loaded !";
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.UnLoadScene;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.UnLoadScene)
|
||||
{
|
||||
_asyncOp = SceneManager.UnloadSceneAsync(_provider.SceneObject);
|
||||
_provider.ResourceMgr.UnloadSubScene(_provider.SceneName);
|
||||
_provider.ResourceMgr.TryUnloadUnusedAsset(_provider.MainAssetInfo);
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.Checking)
|
||||
|
||||
@@ -7,24 +7,26 @@ namespace YooAsset
|
||||
internal sealed class BundledAllAssetsProvider : ProviderBase
|
||||
{
|
||||
private AssetBundleRequest _cacheRequest;
|
||||
|
||||
public BundledAllAssetsProvider(ResourceManager impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
|
||||
public BundledAllAssetsProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
}
|
||||
public override void Update()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (IsDone)
|
||||
return;
|
||||
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
Status = EStatus.CheckBundle;
|
||||
_steps = ESteps.CheckBundle;
|
||||
}
|
||||
|
||||
// 1. 检测资源包
|
||||
if (Status == EStatus.CheckBundle)
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
@@ -39,17 +41,15 @@ namespace YooAsset
|
||||
|
||||
if (DependBundles.IsSucceed() == false)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = DependBundles.GetLastError();
|
||||
InvokeCompletion();
|
||||
string error = DependBundles.GetLastError();
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
string error = OwnerBundle.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,13 +59,13 @@ namespace YooAsset
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
_steps = ESteps.Loading;
|
||||
}
|
||||
|
||||
// 2. 加载资源对象
|
||||
if (Status == EStatus.Loading)
|
||||
if (_steps == ESteps.Loading)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
if (IsWaitForAsyncComplete || IsForceDestroyComplete)
|
||||
{
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
AllAssetObjects = OwnerBundle.CacheBundle.LoadAllAssets();
|
||||
@@ -79,15 +79,15 @@ namespace YooAsset
|
||||
else
|
||||
_cacheRequest = OwnerBundle.CacheBundle.LoadAllAssetsAsync(MainAssetInfo.AssetType);
|
||||
}
|
||||
Status = EStatus.Checking;
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
|
||||
// 3. 检测加载结果
|
||||
if (Status == EStatus.Checking)
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
if (_cacheRequest != null)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
if (IsWaitForAsyncComplete || IsForceDestroyComplete)
|
||||
{
|
||||
// 强制挂起主线程(注意:该操作会很耗时)
|
||||
YooLogger.Warning("Suspend the main thread to load unity asset.");
|
||||
@@ -102,16 +102,20 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
Status = AllAssetObjects == null ? EStatus.Failed : EStatus.Succeed;
|
||||
if (Status == EStatus.Failed)
|
||||
if (AllAssetObjects == null)
|
||||
{
|
||||
string error;
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
LastError = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
error = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
else
|
||||
LastError = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
YooLogger.Error(LastError);
|
||||
error = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
else
|
||||
{
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,23 +8,25 @@ namespace YooAsset
|
||||
{
|
||||
private AssetBundleRequest _cacheRequest;
|
||||
|
||||
public BundledAssetProvider(ResourceManager impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
public BundledAssetProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
}
|
||||
public override void Update()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (IsDone)
|
||||
return;
|
||||
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
Status = EStatus.CheckBundle;
|
||||
_steps = ESteps.CheckBundle;
|
||||
}
|
||||
|
||||
// 1. 检测资源包
|
||||
if (Status == EStatus.CheckBundle)
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
@@ -39,17 +41,15 @@ namespace YooAsset
|
||||
|
||||
if (DependBundles.IsSucceed() == false)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = DependBundles.GetLastError();
|
||||
InvokeCompletion();
|
||||
string error = DependBundles.GetLastError();
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
string error = OwnerBundle.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,13 +59,13 @@ namespace YooAsset
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
_steps = ESteps.Loading;
|
||||
}
|
||||
|
||||
// 2. 加载资源对象
|
||||
if (Status == EStatus.Loading)
|
||||
if (_steps == ESteps.Loading)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
if (IsWaitForAsyncComplete || IsForceDestroyComplete)
|
||||
{
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
AssetObject = OwnerBundle.CacheBundle.LoadAsset(MainAssetInfo.AssetPath);
|
||||
@@ -79,15 +79,15 @@ namespace YooAsset
|
||||
else
|
||||
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetAsync(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
|
||||
}
|
||||
Status = EStatus.Checking;
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
|
||||
// 3. 检测加载结果
|
||||
if (Status == EStatus.Checking)
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
if (_cacheRequest != null)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
if (IsWaitForAsyncComplete || IsForceDestroyComplete)
|
||||
{
|
||||
// 强制挂起主线程(注意:该操作会很耗时)
|
||||
YooLogger.Warning("Suspend the main thread to load unity asset.");
|
||||
@@ -102,16 +102,20 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
Status = AssetObject == null ? EStatus.Failed : EStatus.Succeed;
|
||||
if (Status == EStatus.Failed)
|
||||
if (AssetObject == null)
|
||||
{
|
||||
string error;
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
LastError = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
error = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
else
|
||||
LastError = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
YooLogger.Error(LastError);
|
||||
error = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
else
|
||||
{
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,23 +3,25 @@ namespace YooAsset
|
||||
{
|
||||
internal class BundledRawFileProvider : ProviderBase
|
||||
{
|
||||
public BundledRawFileProvider(ResourceManager impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
public BundledRawFileProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
}
|
||||
public override void Update()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (IsDone)
|
||||
return;
|
||||
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
Status = EStatus.CheckBundle;
|
||||
_steps = ESteps.CheckBundle;
|
||||
}
|
||||
|
||||
// 1. 检测资源包
|
||||
if (Status == EStatus.CheckBundle)
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
@@ -31,21 +33,19 @@ namespace YooAsset
|
||||
|
||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
string error = OwnerBundle.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Checking;
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
|
||||
// 2. 检测加载结果
|
||||
if (Status == EStatus.Checking)
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
RawFilePath = OwnerBundle.FileLoadPath;
|
||||
Status = EStatus.Succeed;
|
||||
InvokeCompletion();
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,32 +9,31 @@ namespace YooAsset
|
||||
internal sealed class BundledSceneProvider : ProviderBase
|
||||
{
|
||||
public readonly LoadSceneMode SceneMode;
|
||||
private readonly string _sceneName;
|
||||
private readonly bool _suspendLoad;
|
||||
private readonly int _priority;
|
||||
private AsyncOperation _asyncOperation;
|
||||
|
||||
public BundledSceneProvider(ResourceManager impl, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad, int priority) : base(impl, providerGUID, assetInfo)
|
||||
public BundledSceneProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
SceneMode = sceneMode;
|
||||
_sceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath);
|
||||
SceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath);
|
||||
_suspendLoad = suspendLoad;
|
||||
_priority = priority;
|
||||
}
|
||||
public override void Update()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (IsDone)
|
||||
return;
|
||||
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
Status = EStatus.CheckBundle;
|
||||
_steps = ESteps.CheckBundle;
|
||||
}
|
||||
|
||||
// 1. 检测资源包
|
||||
if (Status == EStatus.CheckBundle)
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (DependBundles.IsDone() == false)
|
||||
return;
|
||||
@@ -43,57 +42,57 @@ namespace YooAsset
|
||||
|
||||
if (DependBundles.IsSucceed() == false)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = DependBundles.GetLastError();
|
||||
InvokeCompletion();
|
||||
string error = DependBundles.GetLastError();
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
string error = OwnerBundle.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
_steps = ESteps.Loading;
|
||||
}
|
||||
|
||||
// 2. 加载场景
|
||||
if (Status == EStatus.Loading)
|
||||
if (_steps == ESteps.Loading)
|
||||
{
|
||||
// 注意:如果场景不存在则返回NULL
|
||||
_asyncOperation = SceneManager.LoadSceneAsync(MainAssetInfo.AssetPath, SceneMode);
|
||||
if (_asyncOperation != null)
|
||||
{
|
||||
_asyncOperation.allowSceneActivation = !_suspendLoad;
|
||||
_asyncOperation.priority = _priority;
|
||||
_asyncOperation.priority = 100;
|
||||
SceneObject = SceneManager.GetSceneAt(SceneManager.sceneCount - 1);
|
||||
Status = EStatus.Checking;
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = $"Failed to load scene : {_sceneName}";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion();
|
||||
string error = $"Failed to load scene : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 检测加载结果
|
||||
if (Status == EStatus.Checking)
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
Progress = _asyncOperation.progress;
|
||||
if (_asyncOperation.isDone)
|
||||
{
|
||||
Status = SceneObject.IsValid() ? EStatus.Succeed : EStatus.Failed;
|
||||
if (Status == EStatus.Failed)
|
||||
if (SceneObject.IsValid())
|
||||
{
|
||||
LastError = $"The load scene is invalid : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
string error = $"The load scene is invalid : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,23 +8,25 @@ namespace YooAsset
|
||||
{
|
||||
private AssetBundleRequest _cacheRequest;
|
||||
|
||||
public BundledSubAssetsProvider(ResourceManager impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
public BundledSubAssetsProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
}
|
||||
public override void Update()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (IsDone)
|
||||
return;
|
||||
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
Status = EStatus.CheckBundle;
|
||||
_steps = ESteps.CheckBundle;
|
||||
}
|
||||
|
||||
// 1. 检测资源包
|
||||
if (Status == EStatus.CheckBundle)
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
@@ -39,17 +41,15 @@ namespace YooAsset
|
||||
|
||||
if (DependBundles.IsSucceed() == false)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = DependBundles.GetLastError();
|
||||
InvokeCompletion();
|
||||
string error = DependBundles.GetLastError();
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
string error = OwnerBundle.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,13 +59,13 @@ namespace YooAsset
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
_steps = ESteps.Loading;
|
||||
}
|
||||
|
||||
// 2. 加载资源对象
|
||||
if (Status == EStatus.Loading)
|
||||
if (_steps == ESteps.Loading)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
if (IsWaitForAsyncComplete || IsForceDestroyComplete)
|
||||
{
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
AllAssetObjects = OwnerBundle.CacheBundle.LoadAssetWithSubAssets(MainAssetInfo.AssetPath);
|
||||
@@ -79,15 +79,15 @@ namespace YooAsset
|
||||
else
|
||||
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetWithSubAssetsAsync(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
|
||||
}
|
||||
Status = EStatus.Checking;
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
|
||||
// 3. 检测加载结果
|
||||
if (Status == EStatus.Checking)
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
if (_cacheRequest != null)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
if (IsWaitForAsyncComplete || IsForceDestroyComplete)
|
||||
{
|
||||
// 强制挂起主线程(注意:该操作会很耗时)
|
||||
YooLogger.Warning("Suspend the main thread to load unity asset.");
|
||||
@@ -102,16 +102,20 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
Status = AllAssetObjects == null ? EStatus.Failed : EStatus.Succeed;
|
||||
if (Status == EStatus.Failed)
|
||||
if (AllAssetObjects == null)
|
||||
{
|
||||
string error;
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
error = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
else
|
||||
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
YooLogger.Error(LastError);
|
||||
error = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
else
|
||||
{
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,16 +6,19 @@ namespace YooAsset
|
||||
public CompletedProvider(AssetInfo assetInfo) : base(null, string.Empty, assetInfo)
|
||||
{
|
||||
}
|
||||
public override void Update()
|
||||
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
public void SetCompleted(string error)
|
||||
{
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = error;
|
||||
InvokeCompletion();
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,29 +6,32 @@ namespace YooAsset
|
||||
{
|
||||
internal sealed class DatabaseAllAssetsProvider : ProviderBase
|
||||
{
|
||||
public DatabaseAllAssetsProvider(ResourceManager impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
public DatabaseAllAssetsProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
}
|
||||
public override void Update()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (IsDone)
|
||||
return;
|
||||
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
// 检测资源文件是否存在
|
||||
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
|
||||
if (string.IsNullOrEmpty(guid))
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = $"Not found asset : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion();
|
||||
string error = $"Not found asset : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.CheckBundle;
|
||||
_steps = ESteps.CheckBundle;
|
||||
|
||||
// 注意:模拟异步加载效果提前返回
|
||||
if (IsWaitForAsyncComplete == false)
|
||||
@@ -36,7 +39,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 1. 检测资源包
|
||||
if (Status == EStatus.CheckBundle)
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
@@ -48,17 +51,16 @@ namespace YooAsset
|
||||
|
||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
string error = OwnerBundle.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
_steps = ESteps.Loading;
|
||||
}
|
||||
|
||||
// 2. 加载资源对象
|
||||
if (Status == EStatus.Loading)
|
||||
if (_steps == ESteps.Loading)
|
||||
{
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
{
|
||||
@@ -82,22 +84,26 @@ namespace YooAsset
|
||||
}
|
||||
AllAssetObjects = result.ToArray();
|
||||
}
|
||||
Status = EStatus.Checking;
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
|
||||
// 3. 检测加载结果
|
||||
if (Status == EStatus.Checking)
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
Status = AllAssetObjects == null ? EStatus.Failed : EStatus.Succeed;
|
||||
if (Status == EStatus.Failed)
|
||||
if (AllAssetObjects == null)
|
||||
{
|
||||
string error;
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
LastError = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : null";
|
||||
error = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : null";
|
||||
else
|
||||
LastError = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
|
||||
YooLogger.Error(LastError);
|
||||
error = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
else
|
||||
{
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -6,29 +6,32 @@ namespace YooAsset
|
||||
{
|
||||
internal sealed class DatabaseAssetProvider : ProviderBase
|
||||
{
|
||||
public DatabaseAssetProvider(ResourceManager impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
public DatabaseAssetProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
}
|
||||
public override void Update()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (IsDone)
|
||||
return;
|
||||
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
// 检测资源文件是否存在
|
||||
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
|
||||
if (string.IsNullOrEmpty(guid))
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = $"Not found asset : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion();
|
||||
string error = $"Not found asset : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.CheckBundle;
|
||||
_steps = ESteps.CheckBundle;
|
||||
|
||||
// 注意:模拟异步加载效果提前返回
|
||||
if (IsWaitForAsyncComplete == false)
|
||||
@@ -36,7 +39,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 1. 检测资源包
|
||||
if (Status == EStatus.CheckBundle)
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
@@ -48,38 +51,41 @@ namespace YooAsset
|
||||
|
||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
string error = OwnerBundle.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
_steps = ESteps.Loading;
|
||||
}
|
||||
|
||||
// 2. 加载资源对象
|
||||
if (Status == EStatus.Loading)
|
||||
if (_steps == ESteps.Loading)
|
||||
{
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
AssetObject = UnityEditor.AssetDatabase.LoadMainAssetAtPath(MainAssetInfo.AssetPath);
|
||||
else
|
||||
AssetObject = UnityEditor.AssetDatabase.LoadAssetAtPath(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
|
||||
Status = EStatus.Checking;
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
|
||||
// 3. 检测加载结果
|
||||
if (Status == EStatus.Checking)
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
Status = AssetObject == null ? EStatus.Failed : EStatus.Succeed;
|
||||
if (Status == EStatus.Failed)
|
||||
if (AssetObject == null)
|
||||
{
|
||||
string error;
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
LastError = $"Failed to load asset object : {MainAssetInfo.AssetPath} AssetType : null";
|
||||
error = $"Failed to load asset object : {MainAssetInfo.AssetPath} AssetType : null";
|
||||
else
|
||||
LastError = $"Failed to load asset object : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
|
||||
YooLogger.Error(LastError);
|
||||
error = $"Failed to load asset object : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
else
|
||||
{
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -3,29 +3,32 @@ namespace YooAsset
|
||||
{
|
||||
internal class DatabaseRawFileProvider : ProviderBase
|
||||
{
|
||||
public DatabaseRawFileProvider(ResourceManager impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
public DatabaseRawFileProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
}
|
||||
public override void Update()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (IsDone)
|
||||
return;
|
||||
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
// 检测资源文件是否存在
|
||||
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
|
||||
if (string.IsNullOrEmpty(guid))
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = $"Not found asset : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion();
|
||||
string error = $"Not found asset : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.CheckBundle;
|
||||
_steps = ESteps.CheckBundle;
|
||||
|
||||
// 注意:模拟异步加载效果提前返回
|
||||
if (IsWaitForAsyncComplete == false)
|
||||
@@ -33,7 +36,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 1. 检测资源包
|
||||
if (Status == EStatus.CheckBundle)
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
@@ -45,21 +48,19 @@ namespace YooAsset
|
||||
|
||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
string error = OwnerBundle.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Checking;
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
|
||||
// 2. 检测加载结果
|
||||
if (Status == EStatus.Checking)
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
RawFilePath = MainAssetInfo.AssetPath;
|
||||
Status = EStatus.Succeed;
|
||||
InvokeCompletion();
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace YooAsset
|
||||
@@ -7,28 +10,31 @@ namespace YooAsset
|
||||
{
|
||||
public readonly LoadSceneMode SceneMode;
|
||||
private readonly bool _suspendLoad;
|
||||
private readonly int _priority;
|
||||
private AsyncOperation _asyncOperation;
|
||||
|
||||
public DatabaseSceneProvider(ResourceManager impl, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad, int priority) : base(impl, providerGUID, assetInfo)
|
||||
public DatabaseSceneProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
SceneMode = sceneMode;
|
||||
SceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath);
|
||||
_suspendLoad = suspendLoad;
|
||||
_priority = priority;
|
||||
}
|
||||
public override void Update()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (IsDone)
|
||||
return;
|
||||
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
Status = EStatus.CheckBundle;
|
||||
_steps = ESteps.CheckBundle;
|
||||
}
|
||||
|
||||
// 1. 检测资源包
|
||||
if (Status == EStatus.CheckBundle)
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
@@ -40,17 +46,16 @@ namespace YooAsset
|
||||
|
||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
string error = OwnerBundle.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
_steps = ESteps.Loading;
|
||||
}
|
||||
|
||||
// 2. 加载资源对象
|
||||
if (Status == EStatus.Loading)
|
||||
if (_steps == ESteps.Loading)
|
||||
{
|
||||
LoadSceneParameters loadSceneParameters = new LoadSceneParameters();
|
||||
loadSceneParameters.loadSceneMode = SceneMode;
|
||||
@@ -58,32 +63,34 @@ namespace YooAsset
|
||||
if (_asyncOperation != null)
|
||||
{
|
||||
_asyncOperation.allowSceneActivation = !_suspendLoad;
|
||||
_asyncOperation.priority = _priority;
|
||||
_asyncOperation.priority = 100;
|
||||
SceneObject = SceneManager.GetSceneAt(SceneManager.sceneCount - 1);
|
||||
Status = EStatus.Checking;
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = $"Failed to load scene : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion();
|
||||
string error = $"Failed to load scene : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 检测加载结果
|
||||
if (Status == EStatus.Checking)
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
Progress = _asyncOperation.progress;
|
||||
if (_asyncOperation.isDone)
|
||||
{
|
||||
Status = SceneObject.IsValid() ? EStatus.Succeed : EStatus.Failed;
|
||||
if (Status == EStatus.Failed)
|
||||
if (SceneObject.IsValid())
|
||||
{
|
||||
LastError = $"The loaded scene is invalid : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
string error = $"The loaded scene is invalid : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -6,29 +6,32 @@ namespace YooAsset
|
||||
{
|
||||
internal sealed class DatabaseSubAssetsProvider : ProviderBase
|
||||
{
|
||||
public DatabaseSubAssetsProvider(ResourceManager impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
public DatabaseSubAssetsProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
}
|
||||
public override void Update()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (IsDone)
|
||||
return;
|
||||
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
// 检测资源文件是否存在
|
||||
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
|
||||
if (string.IsNullOrEmpty(guid))
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = $"Not found asset : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion();
|
||||
string error = $"Not found asset : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.CheckBundle;
|
||||
_steps = ESteps.CheckBundle;
|
||||
|
||||
// 注意:模拟异步加载效果提前返回
|
||||
if (IsWaitForAsyncComplete == false)
|
||||
@@ -36,7 +39,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 1. 检测资源包
|
||||
if (Status == EStatus.CheckBundle)
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
@@ -48,17 +51,16 @@ namespace YooAsset
|
||||
|
||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
string error = OwnerBundle.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
_steps = ESteps.Loading;
|
||||
}
|
||||
|
||||
// 2. 加载资源对象
|
||||
if (Status == EStatus.Loading)
|
||||
if (_steps == ESteps.Loading)
|
||||
{
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
{
|
||||
@@ -75,22 +77,26 @@ namespace YooAsset
|
||||
}
|
||||
AllAssetObjects = result.ToArray();
|
||||
}
|
||||
Status = EStatus.Checking;
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
|
||||
// 3. 检测加载结果
|
||||
if (Status == EStatus.Checking)
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
Status = AllAssetObjects == null ? EStatus.Failed : EStatus.Succeed;
|
||||
if (Status == EStatus.Failed)
|
||||
if (AllAssetObjects == null)
|
||||
{
|
||||
string error;
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : null";
|
||||
error = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : null";
|
||||
else
|
||||
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
|
||||
YooLogger.Error(LastError);
|
||||
error = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
else
|
||||
{
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal abstract class ProviderBase
|
||||
internal abstract class ProviderBase : AsyncOperationBase
|
||||
{
|
||||
public enum EStatus
|
||||
protected enum ESteps
|
||||
{
|
||||
None = 0,
|
||||
CheckBundle,
|
||||
Loading,
|
||||
Checking,
|
||||
Succeed,
|
||||
Failed,
|
||||
Done,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -25,7 +25,7 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 所属资源系统
|
||||
/// </summary>
|
||||
public ResourceManager Impl { private set; get; }
|
||||
public ResourceManager ResourceMgr { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源信息
|
||||
@@ -47,27 +47,16 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public UnityEngine.SceneManagement.Scene SceneObject { protected set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 加载的场景名称
|
||||
/// </summary>
|
||||
public string SceneName { protected set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 原生文件路径
|
||||
/// </summary>
|
||||
public string RawFilePath { protected set; get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 当前的加载状态
|
||||
/// </summary>
|
||||
public EStatus Status { protected set; get; } = EStatus.None;
|
||||
|
||||
/// <summary>
|
||||
/// 最近的错误信息
|
||||
/// </summary>
|
||||
public string LastError { protected set; get; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 加载进度
|
||||
/// </summary>
|
||||
public float Progress { protected set; get; } = 0f;
|
||||
|
||||
/// <summary>
|
||||
/// 引用计数
|
||||
/// </summary>
|
||||
@@ -78,55 +67,48 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public bool IsDestroyed { private set; get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 是否完毕(成功或失败)
|
||||
/// </summary>
|
||||
public bool IsDone
|
||||
{
|
||||
get
|
||||
{
|
||||
return Status == EStatus.Succeed || Status == EStatus.Failed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected ESteps _steps = ESteps.None;
|
||||
protected BundleLoaderBase OwnerBundle { private set; get; }
|
||||
protected DependAssetBundles DependBundles { private set; get; }
|
||||
protected bool IsWaitForAsyncComplete { private set; get; } = false;
|
||||
protected bool IsForceDestroyComplete { private set; get; } = false;
|
||||
private readonly List<HandleBase> _handles = new List<HandleBase>();
|
||||
|
||||
|
||||
public ProviderBase(ResourceManager impl, string providerGUID, AssetInfo assetInfo)
|
||||
public ProviderBase(ResourceManager manager, string providerGUID, AssetInfo assetInfo)
|
||||
{
|
||||
Impl = impl;
|
||||
ResourceMgr = manager;
|
||||
ProviderGUID = providerGUID;
|
||||
MainAssetInfo = assetInfo;
|
||||
|
||||
// 创建资源包加载器
|
||||
if (impl != null)
|
||||
if (manager != null)
|
||||
{
|
||||
OwnerBundle = impl.CreateOwnerAssetBundleLoader(assetInfo);
|
||||
OwnerBundle = manager.CreateOwnerAssetBundleLoader(assetInfo);
|
||||
OwnerBundle.Reference();
|
||||
OwnerBundle.AddProvider(this);
|
||||
|
||||
var dependList = impl.CreateDependAssetBundleLoaders(assetInfo);
|
||||
var dependList = manager.CreateDependAssetBundleLoaders(assetInfo);
|
||||
DependBundles = new DependAssetBundles(dependList);
|
||||
DependBundles.Reference();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 轮询更新方法
|
||||
/// </summary>
|
||||
public abstract void Update();
|
||||
|
||||
/// <summary>
|
||||
/// 销毁资源对象
|
||||
/// 销毁资源提供者
|
||||
/// </summary>
|
||||
public void Destroy()
|
||||
{
|
||||
IsDestroyed = true;
|
||||
|
||||
// 检测是否为正常销毁
|
||||
if (IsDone == false)
|
||||
{
|
||||
Error = "User abort !";
|
||||
Status = EOperationStatus.Failed;
|
||||
}
|
||||
|
||||
// 释放资源包加载器
|
||||
if (OwnerBundle != null)
|
||||
{
|
||||
@@ -145,14 +127,15 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public bool CanDestroy()
|
||||
{
|
||||
if (IsDone == false)
|
||||
// 注意:在进行资源加载过程时不可以销毁
|
||||
if (_steps == ESteps.Loading || _steps == ESteps.Checking)
|
||||
return false;
|
||||
|
||||
return RefCount <= 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建操作句柄
|
||||
/// 创建资源句柄
|
||||
/// </summary>
|
||||
public T CreateHandle<T>() where T : HandleBase
|
||||
{
|
||||
@@ -178,12 +161,12 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放操作句柄
|
||||
/// 释放资源句柄
|
||||
/// </summary>
|
||||
public void ReleaseHandle(HandleBase handle)
|
||||
{
|
||||
if (RefCount <= 0)
|
||||
YooLogger.Warning("Asset provider reference count is already zero. There may be resource leaks !");
|
||||
throw new System.Exception("Should never get here !");
|
||||
|
||||
if (_handles.Remove(handle) == false)
|
||||
throw new System.Exception("Should never get here !");
|
||||
@@ -192,6 +175,18 @@ namespace YooAsset
|
||||
RefCount--;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放所有资源句柄
|
||||
/// </summary>
|
||||
public void ReleaseAllHandles()
|
||||
{
|
||||
for (int i = _handles.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var handle = _handles[i];
|
||||
handle.ReleaseInternal();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 等待异步执行完毕
|
||||
/// </summary>
|
||||
@@ -200,15 +195,27 @@ namespace YooAsset
|
||||
IsWaitForAsyncComplete = true;
|
||||
|
||||
// 注意:主动轮询更新完成同步加载
|
||||
Update();
|
||||
InternalOnUpdate();
|
||||
|
||||
// 验证结果
|
||||
if (IsDone == false)
|
||||
{
|
||||
YooLogger.Warning($"WaitForAsyncComplete failed to loading : {MainAssetInfo.AssetPath}");
|
||||
YooLogger.Warning($"{nameof(WaitForAsyncComplete)} failed to loading : {MainAssetInfo.AssetPath}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 强制销毁资源提供者
|
||||
/// </summary>
|
||||
public void ForceDestroyComplete()
|
||||
{
|
||||
IsForceDestroyComplete = true;
|
||||
|
||||
// 注意:主动轮询更新完成同步加载
|
||||
// 说明:如果资源包未准备完毕也可以放心销毁。
|
||||
InternalOnUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理特殊异常
|
||||
/// </summary>
|
||||
@@ -217,37 +224,21 @@ namespace YooAsset
|
||||
if (OwnerBundle.IsDestroyed)
|
||||
throw new System.Exception("Should never get here !");
|
||||
|
||||
Status = EStatus.Failed;
|
||||
LastError = $"The bundle {OwnerBundle.MainBundleInfo.Bundle.BundleName} has been destroyed by unity bugs !";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion();
|
||||
string error = $"The bundle {OwnerBundle.MainBundleInfo.Bundle.BundleName} has been destroyed by unity bugs !";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(Error, EOperationStatus.Failed);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步操作任务
|
||||
/// 结束流程
|
||||
/// </summary>
|
||||
public Task Task
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_taskCompletionSource == null)
|
||||
{
|
||||
_taskCompletionSource = new TaskCompletionSource<object>();
|
||||
if (IsDone)
|
||||
_taskCompletionSource.SetResult(null);
|
||||
}
|
||||
return _taskCompletionSource.Task;
|
||||
}
|
||||
}
|
||||
|
||||
#region 异步编程相关
|
||||
private TaskCompletionSource<object> _taskCompletionSource;
|
||||
protected void InvokeCompletion()
|
||||
protected void InvokeCompletion(string error, EOperationStatus status)
|
||||
{
|
||||
DebugEndRecording();
|
||||
|
||||
// 进度百分百完成
|
||||
Progress = 1f;
|
||||
_steps = ESteps.Done;
|
||||
Error = error;
|
||||
Status = status;
|
||||
|
||||
// 注意:创建临时列表是为了防止外部逻辑在回调函数内创建或者释放资源句柄。
|
||||
// 注意:回调方法如果发生异常,会阻断列表里的后续回调方法!
|
||||
@@ -259,11 +250,7 @@ namespace YooAsset
|
||||
hande.InvokeCallback();
|
||||
}
|
||||
}
|
||||
|
||||
if (_taskCompletionSource != null)
|
||||
_taskCompletionSource.TrySetResult(null);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 调试信息相关
|
||||
/// <summary>
|
||||
|
||||
@@ -9,31 +9,17 @@ namespace YooAsset
|
||||
{
|
||||
internal class ResourceManager
|
||||
{
|
||||
private readonly Dictionary<string, BundleLoaderBase> _loaderDic = new Dictionary<string, BundleLoaderBase>(5000);
|
||||
private readonly List<BundleLoaderBase> _loaderList = new List<BundleLoaderBase>(5000);
|
||||
|
||||
private readonly Dictionary<string, ProviderBase> _providerDic = new Dictionary<string, ProviderBase>(5000);
|
||||
private readonly List<ProviderBase> _providerList = new List<ProviderBase>(5000);
|
||||
|
||||
// 全局场景句柄集合
|
||||
private readonly static Dictionary<string, SceneHandle> _sceneHandles = new Dictionary<string, SceneHandle>(100);
|
||||
private static long _sceneCreateCount = 0;
|
||||
|
||||
private readonly Dictionary<string, ProviderBase> _providerDic = new Dictionary<string, ProviderBase>(5000);
|
||||
private readonly Dictionary<string, BundleLoaderBase> _loaderDic = new Dictionary<string, BundleLoaderBase>(5000);
|
||||
private readonly List<BundleLoaderBase> _loaderList = new List<BundleLoaderBase>(5000);
|
||||
|
||||
private bool _simulationOnEditor;
|
||||
private long _loadingMaxTimeSlice;
|
||||
private bool _autoDestroyAssetProvider;
|
||||
private IBundleQuery _bundleQuery;
|
||||
private bool _isUnloadSafe = true;
|
||||
|
||||
// 计时器相关
|
||||
private Stopwatch _watch;
|
||||
private long _frameTime;
|
||||
private bool IsBusy
|
||||
{
|
||||
get
|
||||
{
|
||||
return _watch.ElapsedMilliseconds - _frameTime >= _loadingMaxTimeSlice;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 所属包裹
|
||||
@@ -49,12 +35,11 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 初始化
|
||||
/// </summary>
|
||||
public void Initialize(bool simulationOnEditor, long loadingMaxTimeSlice, IBundleQuery bundleServices)
|
||||
public void Initialize(bool simulationOnEditor, bool autoDestroyAssetProvider, IBundleQuery bundleServices)
|
||||
{
|
||||
_simulationOnEditor = simulationOnEditor;
|
||||
_loadingMaxTimeSlice = loadingMaxTimeSlice;
|
||||
_autoDestroyAssetProvider = autoDestroyAssetProvider;
|
||||
_bundleQuery = bundleServices;
|
||||
_watch = Stopwatch.StartNew();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -62,50 +47,24 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public void Update()
|
||||
{
|
||||
_frameTime = _watch.ElapsedMilliseconds;
|
||||
|
||||
// 更新加载器
|
||||
foreach (var loader in _loaderList)
|
||||
{
|
||||
loader.Update();
|
||||
}
|
||||
|
||||
// 更新资源提供者
|
||||
// 注意:循环更新的时候,可能会扩展列表
|
||||
_isUnloadSafe = false;
|
||||
for (int i = 0; i < _providerList.Count; i++)
|
||||
{
|
||||
if (IsBusy)
|
||||
break;
|
||||
_providerList[i].Update();
|
||||
if (_autoDestroyAssetProvider)
|
||||
loader.TryDestroyProviders();
|
||||
}
|
||||
_isUnloadSafe = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源回收(卸载引用计数为零的资源)
|
||||
/// </summary>
|
||||
public void UnloadUnusedAssets()
|
||||
{
|
||||
if (_isUnloadSafe == false)
|
||||
{
|
||||
YooLogger.Warning("Can not unload unused assets when processing resource loading !");
|
||||
return;
|
||||
}
|
||||
|
||||
// 注意:资源包之间可能存在多层深层嵌套,需要多次循环释放。
|
||||
int loopCount = 10;
|
||||
for (int i = 0; i < loopCount; i++)
|
||||
{
|
||||
UnloadUnusedAssetsInternal();
|
||||
}
|
||||
}
|
||||
private void UnloadUnusedAssetsInternal()
|
||||
{
|
||||
for (int i = _loaderList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
BundleLoaderBase loader = _loaderList[i];
|
||||
loader.TryDestroyAllProviders();
|
||||
loader.TryDestroyProviders();
|
||||
}
|
||||
|
||||
for (int i = _loaderList.Count - 1; i >= 0; i--)
|
||||
@@ -121,26 +80,91 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试卸载指定资源的资源包(包括依赖资源)
|
||||
/// </summary>
|
||||
public void TryUnloadUnusedAsset(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
YooLogger.Error($"Failed to unload asset ! {assetInfo.Error}");
|
||||
return;
|
||||
}
|
||||
|
||||
// 卸载主资源包加载器
|
||||
string manBundleName = _bundleQuery.GetMainBundleName(assetInfo);
|
||||
var mainLoader = TryGetAssetBundleLoader(manBundleName);
|
||||
if (mainLoader != null)
|
||||
{
|
||||
mainLoader.TryDestroyProviders();
|
||||
if (mainLoader.CanDestroy())
|
||||
{
|
||||
string bundleName = mainLoader.MainBundleInfo.Bundle.BundleName;
|
||||
mainLoader.Destroy();
|
||||
_loaderList.Remove(mainLoader);
|
||||
_loaderDic.Remove(bundleName);
|
||||
}
|
||||
}
|
||||
|
||||
// 卸载依赖资源包加载器
|
||||
string[] dependBundleNames = _bundleQuery.GetDependBundleNames(assetInfo);
|
||||
foreach (var dependBundleName in dependBundleNames)
|
||||
{
|
||||
var dependLoader = TryGetAssetBundleLoader(dependBundleName);
|
||||
if (dependLoader != null)
|
||||
{
|
||||
if (dependLoader.CanDestroy())
|
||||
{
|
||||
string bundleName = dependLoader.MainBundleInfo.Bundle.BundleName;
|
||||
dependLoader.Destroy();
|
||||
_loaderList.Remove(dependLoader);
|
||||
_loaderDic.Remove(bundleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 强制回收所有资源
|
||||
/// 注意:加载器在销毁后关联的下载器还会继续下载!
|
||||
/// </summary>
|
||||
public void ForceUnloadAllAssets()
|
||||
{
|
||||
#if UNITY_WEBGL
|
||||
throw new Exception($"WebGL not support invoke {nameof(ForceUnloadAllAssets)}");
|
||||
#else
|
||||
foreach (var provider in _providerList)
|
||||
// 注意:因为场景无法异步转同步,需要等待所有场景加载完毕!
|
||||
foreach (var sceneHandlePair in _sceneHandles)
|
||||
{
|
||||
provider.WaitForAsyncComplete();
|
||||
var sceneHandle = sceneHandlePair.Value;
|
||||
if (sceneHandle.PackageName == PackageName)
|
||||
{
|
||||
if (sceneHandle.IsDone == false)
|
||||
throw new Exception($"{nameof(ForceUnloadAllAssets)} cannot be called when loading the scene !");
|
||||
}
|
||||
}
|
||||
|
||||
// 释放所有资源句柄
|
||||
foreach (var provider in _providerDic.Values)
|
||||
{
|
||||
provider.ReleaseAllHandles();
|
||||
}
|
||||
|
||||
// 强制销毁资源提供者
|
||||
foreach (var provider in _providerDic.Values)
|
||||
{
|
||||
provider.ForceDestroyComplete();
|
||||
provider.Destroy();
|
||||
}
|
||||
|
||||
// 强制销毁资源加载器
|
||||
foreach (var loader in _loaderList)
|
||||
{
|
||||
loader.WaitForAsyncComplete();
|
||||
loader.ForceDestroyComplete();
|
||||
loader.Destroy();
|
||||
}
|
||||
|
||||
_providerList.Clear();
|
||||
// 清空数据
|
||||
_providerDic.Clear();
|
||||
_loaderList.Clear();
|
||||
_loaderDic.Clear();
|
||||
@@ -152,9 +176,11 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载场景
|
||||
/// 加载场景对象
|
||||
/// 注意:返回的场景句柄是唯一的,每个场景句柄对应自己的场景提供者对象。
|
||||
/// 注意:业务逻辑层应该避免同时加载一个子场景。
|
||||
/// </summary>
|
||||
public SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad, int priority)
|
||||
public SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad, uint priority)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
@@ -175,14 +201,15 @@ namespace YooAsset
|
||||
ProviderBase provider;
|
||||
{
|
||||
if (_simulationOnEditor)
|
||||
provider = new DatabaseSceneProvider(this, providerGUID, assetInfo, sceneMode, suspendLoad, priority);
|
||||
provider = new DatabaseSceneProvider(this, providerGUID, assetInfo, sceneMode, suspendLoad);
|
||||
else
|
||||
provider = new BundledSceneProvider(this, providerGUID, assetInfo, sceneMode, suspendLoad, priority);
|
||||
provider = new BundledSceneProvider(this, providerGUID, assetInfo, sceneMode, suspendLoad);
|
||||
provider.InitSpawnDebugInfo();
|
||||
_providerList.Add(provider);
|
||||
_providerDic.Add(providerGUID, provider);
|
||||
OperationSystem.StartOperation(PackageName, provider);
|
||||
}
|
||||
|
||||
provider.Priority = priority;
|
||||
var handle = provider.CreateHandle<SceneHandle>();
|
||||
handle.PackageName = PackageName;
|
||||
_sceneHandles.Add(providerGUID, handle);
|
||||
@@ -192,7 +219,7 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 加载资源对象
|
||||
/// </summary>
|
||||
public AssetHandle LoadAssetAsync(AssetInfo assetInfo)
|
||||
public AssetHandle LoadAssetAsync(AssetInfo assetInfo, uint priority)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
@@ -202,7 +229,7 @@ namespace YooAsset
|
||||
return completedProvider.CreateHandle<AssetHandle>();
|
||||
}
|
||||
|
||||
string providerGUID = assetInfo.GUID;
|
||||
string providerGUID = nameof(LoadAssetAsync) + assetInfo.GUID;
|
||||
ProviderBase provider = TryGetProvider(providerGUID);
|
||||
if (provider == null)
|
||||
{
|
||||
@@ -211,16 +238,18 @@ namespace YooAsset
|
||||
else
|
||||
provider = new BundledAssetProvider(this, providerGUID, assetInfo);
|
||||
provider.InitSpawnDebugInfo();
|
||||
_providerList.Add(provider);
|
||||
_providerDic.Add(providerGUID, provider);
|
||||
OperationSystem.StartOperation(PackageName, provider);
|
||||
}
|
||||
|
||||
provider.Priority = priority;
|
||||
return provider.CreateHandle<AssetHandle>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载子资源对象
|
||||
/// </summary>
|
||||
public SubAssetsHandle LoadSubAssetsAsync(AssetInfo assetInfo)
|
||||
public SubAssetsHandle LoadSubAssetsAsync(AssetInfo assetInfo, uint priority)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
@@ -230,7 +259,7 @@ namespace YooAsset
|
||||
return completedProvider.CreateHandle<SubAssetsHandle>();
|
||||
}
|
||||
|
||||
string providerGUID = assetInfo.GUID;
|
||||
string providerGUID = nameof(LoadSubAssetsAsync) + assetInfo.GUID;
|
||||
ProviderBase provider = TryGetProvider(providerGUID);
|
||||
if (provider == null)
|
||||
{
|
||||
@@ -239,16 +268,18 @@ namespace YooAsset
|
||||
else
|
||||
provider = new BundledSubAssetsProvider(this, providerGUID, assetInfo);
|
||||
provider.InitSpawnDebugInfo();
|
||||
_providerList.Add(provider);
|
||||
_providerDic.Add(providerGUID, provider);
|
||||
OperationSystem.StartOperation(PackageName, provider);
|
||||
}
|
||||
|
||||
provider.Priority = priority;
|
||||
return provider.CreateHandle<SubAssetsHandle>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载所有资源对象
|
||||
/// </summary>
|
||||
public AllAssetsHandle LoadAllAssetsAsync(AssetInfo assetInfo)
|
||||
public AllAssetsHandle LoadAllAssetsAsync(AssetInfo assetInfo, uint priority)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
@@ -258,7 +289,7 @@ namespace YooAsset
|
||||
return completedProvider.CreateHandle<AllAssetsHandle>();
|
||||
}
|
||||
|
||||
string providerGUID = assetInfo.GUID;
|
||||
string providerGUID = nameof(LoadAllAssetsAsync) + assetInfo.GUID;
|
||||
ProviderBase provider = TryGetProvider(providerGUID);
|
||||
if (provider == null)
|
||||
{
|
||||
@@ -267,16 +298,18 @@ namespace YooAsset
|
||||
else
|
||||
provider = new BundledAllAssetsProvider(this, providerGUID, assetInfo);
|
||||
provider.InitSpawnDebugInfo();
|
||||
_providerList.Add(provider);
|
||||
_providerDic.Add(providerGUID, provider);
|
||||
OperationSystem.StartOperation(PackageName, provider);
|
||||
}
|
||||
|
||||
provider.Priority = priority;
|
||||
return provider.CreateHandle<AllAssetsHandle>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载原生文件
|
||||
/// </summary>
|
||||
public RawFileHandle LoadRawFileAsync(AssetInfo assetInfo)
|
||||
public RawFileHandle LoadRawFileAsync(AssetInfo assetInfo, uint priority)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
@@ -286,7 +319,7 @@ namespace YooAsset
|
||||
return completedProvider.CreateHandle<RawFileHandle>();
|
||||
}
|
||||
|
||||
string providerGUID = assetInfo.GUID;
|
||||
string providerGUID = nameof(LoadRawFileAsync) + assetInfo.GUID;
|
||||
ProviderBase provider = TryGetProvider(providerGUID);
|
||||
if (provider == null)
|
||||
{
|
||||
@@ -295,21 +328,32 @@ namespace YooAsset
|
||||
else
|
||||
provider = new BundledRawFileProvider(this, providerGUID, assetInfo);
|
||||
provider.InitSpawnDebugInfo();
|
||||
_providerList.Add(provider);
|
||||
_providerDic.Add(providerGUID, provider);
|
||||
OperationSystem.StartOperation(PackageName, provider);
|
||||
}
|
||||
|
||||
provider.Priority = priority;
|
||||
return provider.CreateHandle<RawFileHandle>();
|
||||
}
|
||||
|
||||
internal void UnloadSubScene(ProviderBase provider)
|
||||
internal void UnloadSubScene(string sceneName)
|
||||
{
|
||||
string providerGUID = provider.ProviderGUID;
|
||||
if (_sceneHandles.ContainsKey(providerGUID) == false)
|
||||
throw new Exception("Should never get here !");
|
||||
List<string> removeKeys = new List<string>();
|
||||
foreach (var valuePair in _sceneHandles)
|
||||
{
|
||||
var sceneHandle = valuePair.Value;
|
||||
if (sceneHandle.SceneName == sceneName)
|
||||
{
|
||||
// 释放子场景句柄
|
||||
sceneHandle.ReleaseInternal();
|
||||
removeKeys.Add(valuePair.Key);
|
||||
}
|
||||
}
|
||||
|
||||
// 释放子场景句柄
|
||||
_sceneHandles[providerGUID].ReleaseInternal();
|
||||
_sceneHandles.Remove(providerGUID);
|
||||
foreach (string key in removeKeys)
|
||||
{
|
||||
_sceneHandles.Remove(key);
|
||||
}
|
||||
}
|
||||
private void UnloadAllScene()
|
||||
{
|
||||
@@ -357,14 +401,17 @@ namespace YooAsset
|
||||
}
|
||||
return result;
|
||||
}
|
||||
internal void RemoveBundleProviders(List<ProviderBase> providers)
|
||||
internal void RemoveBundleProviders(List<ProviderBase> removeList)
|
||||
{
|
||||
foreach (var provider in providers)
|
||||
foreach (var provider in removeList)
|
||||
{
|
||||
_providerList.Remove(provider);
|
||||
_providerDic.Remove(provider.ProviderGUID);
|
||||
}
|
||||
}
|
||||
internal bool HasAnyLoader()
|
||||
{
|
||||
return _loaderList.Count > 0;
|
||||
}
|
||||
|
||||
private BundleLoaderBase CreateAssetBundleLoaderInternal(BundleInfo bundleInfo)
|
||||
{
|
||||
@@ -382,12 +429,12 @@ namespace YooAsset
|
||||
else
|
||||
{
|
||||
#if UNITY_WEBGL
|
||||
if (bundleInfo.Bundle.Buildpipeline== DefaultBuildPipeline.RawFileBuildPipelineName)
|
||||
if (bundleInfo.Bundle.Buildpipeline== EDefaultBuildPipeline.RawFileBuildPipeline.ToString())
|
||||
loader = new RawBundleWebLoader(this, bundleInfo);
|
||||
else
|
||||
loader = new AssetBundleWebLoader(this, bundleInfo);
|
||||
#else
|
||||
if (bundleInfo.Bundle.Buildpipeline == DefaultBuildPipeline.RawFileBuildPipelineName)
|
||||
if (bundleInfo.Bundle.Buildpipeline == EDefaultBuildPipeline.RawFileBuildPipeline.ToString())
|
||||
loader = new RawBundleFileLoader(this, bundleInfo);
|
||||
else
|
||||
loader = new AssetBundleFileLoader(this, bundleInfo);
|
||||
@@ -416,8 +463,8 @@ namespace YooAsset
|
||||
#region 调试信息
|
||||
internal List<DebugProviderInfo> GetDebugReportInfos()
|
||||
{
|
||||
List<DebugProviderInfo> result = new List<DebugProviderInfo>(_providerList.Count);
|
||||
foreach (var provider in _providerList)
|
||||
List<DebugProviderInfo> result = new List<DebugProviderInfo>(_providerDic.Count);
|
||||
foreach (var provider in _providerDic.Values)
|
||||
{
|
||||
DebugProviderInfo providerInfo = new DebugProviderInfo();
|
||||
providerInfo.AssetPath = provider.MainAssetInfo.AssetPath;
|
||||
@@ -432,15 +479,6 @@ namespace YooAsset
|
||||
}
|
||||
return result;
|
||||
}
|
||||
internal List<BundleInfo> GetLoadedBundleInfos()
|
||||
{
|
||||
List<BundleInfo> result = new List<BundleInfo>(100);
|
||||
foreach (var loader in _loaderList)
|
||||
{
|
||||
result.Add(loader.MainBundleInfo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user