mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-22 16:50:18 +00:00
Compare commits
51 Commits
2.0.2-prev
...
2.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f13c021b9 | ||
|
|
5f30c92d44 | ||
|
|
3e6c55d981 | ||
|
|
de36f984d7 | ||
|
|
95328fe1a6 | ||
|
|
1fb78185ff | ||
|
|
58f9aea979 | ||
|
|
4d4bb1e34f | ||
|
|
6e1978ec10 | ||
|
|
d8a8afba5e | ||
|
|
6e6f425bdd | ||
|
|
9ebe92f832 | ||
|
|
cbdb84a69f | ||
|
|
67b2b886a8 | ||
|
|
2838289650 | ||
|
|
4b68362fb8 | ||
|
|
e8e7696a4d | ||
|
|
82b2a5cc20 | ||
|
|
2332765932 | ||
|
|
552d689317 | ||
|
|
5e2d82d071 | ||
|
|
727f356eea | ||
|
|
544832c46a | ||
|
|
5c1d316d67 | ||
|
|
267ec77c37 | ||
|
|
c2a7106221 | ||
|
|
0e29e9823d | ||
|
|
47962424eb | ||
|
|
505d23ca07 | ||
|
|
d4fcb868d8 | ||
|
|
6dd1f43445 | ||
|
|
2626cb6750 | ||
|
|
81a98ded8a | ||
|
|
930f02765d | ||
|
|
a4ffa580b7 | ||
|
|
506612527d | ||
|
|
74f9f2b0e6 | ||
|
|
4119f02c60 | ||
|
|
bc9a4e07e2 | ||
|
|
9418544264 | ||
|
|
460ea091bd | ||
|
|
64681db027 | ||
|
|
992957e1e9 | ||
|
|
ce62dbc27f | ||
|
|
e2df967aa9 | ||
|
|
5b4a188c0b | ||
|
|
e8b5a58a90 | ||
|
|
c3d5c13a80 | ||
|
|
d30a8aefa4 | ||
|
|
194afe435a | ||
|
|
82ef993d83 |
@@ -2,38 +2,82 @@
|
|||||||
|
|
||||||
All notable changes to this package will be documented in this file.
|
All notable changes to this package will be documented in this file.
|
||||||
|
|
||||||
## [2.0.2-preview] - 2023-10-17
|
## [2.1.1] - 2024-01-17
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed the mistaken code in the build window.
|
- (#224) 修复了编辑器模式打包时 SimulateBuild 报错的问题。
|
||||||
- Fixed an issue where auto collect shaders was not effective for dependent resources.
|
- (#223) 修复了资源构建界面读取配置导致的报错问题。
|
||||||
|
|
||||||
### 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
|
### Added
|
||||||
|
|
||||||
- Resource downloader add combine function.
|
- 支持共享资源打包规则,可以定制化独立的构建规则。
|
||||||
|
|
||||||
```c#
|
```c#
|
||||||
|
public class BuildParameters
|
||||||
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 合并其它下载器
|
/// 是否启用共享资源打包
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="downloader">合并的下载器</param>
|
public bool EnableSharePackRule = false;
|
||||||
public void Combine(DownloaderOperation downloader);
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## [2.0.0-preview] - 2023-10-07
|
- 微信小游戏平台,资源下载器支持底层缓存查询。
|
||||||
|
|
||||||
|
## [2.1.0] - 2023-12-27
|
||||||
|
|
||||||
|
升级了 Scriptable build pipeline (SBP) 的版本,来解决图集引用的精灵图片冗余问题。
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- (#195) 修复了在EditorPlayMode模式下,AssetHandle.GetDownloadStatus()发生异常的问题。
|
||||||
|
- (#201) 修复了断点续传失效的问题。
|
||||||
|
- (#202) 修复了打包参数FileNameStyle设置为BundleName后,IQueryServices会一直返回true的问题。
|
||||||
|
- (#205) 修复了HybridCLR插件里创建资源下载器触发的异常。
|
||||||
|
- (#210) 修复了DownloaderOperation在未开始下载前,内部的PackageName为空的问题。
|
||||||
|
- (#220) 修复了资源收集界面关闭后,撤回操作还会生效的问题。
|
||||||
|
- 修复了下载器合并后重新计算下载字节数不正确的问题。
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
- (#198) 资源收集界面禁用的分组不再检测合法性。
|
||||||
|
- (#203) 资源构建类容许自定义打包的输出目录。
|
||||||
|
- 资源构建报告增加未依赖的资源信息列表。
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- IBuildinQueryServices和IDeliveryQueryServices查询方法变更。
|
||||||
|
|
||||||
|
```c#
|
||||||
|
public interface IBuildinQueryServices
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 查询是否为应用程序内置的资源文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="packageName">包裹名称</param>
|
||||||
|
/// <param name="fileName">文件名称(包含文件的后缀格式)</param>
|
||||||
|
/// <param name="fileCRC">文件哈希值</param>
|
||||||
|
/// <returns>返回查询结果</returns>
|
||||||
|
bool Query(string packageName, string fileName, string fileCRC);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IDeliveryQueryServices
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 查询是否为开发者分发的资源文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="packageName">包裹名称</param>
|
||||||
|
/// <param name="fileName">文件名称(包含文件的后缀格式)</param>
|
||||||
|
/// <param name="fileCRC">文件哈希值</param>
|
||||||
|
/// <returns>返回查询结果</returns>
|
||||||
|
bool Query(string packageName, string fileName, string fileCRC);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- (#212) 移除了构建报告里的资源冗余信息列表。
|
||||||
|
|
||||||
This is the preview version.
|
|
||||||
|
|||||||
@@ -26,19 +26,9 @@ namespace YooAsset.Editor
|
|||||||
public string Address { private set; get; }
|
public string Address { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源路径
|
/// 资源信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetPath { private set; get; }
|
public AssetInfo AssetInfo { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源GUID
|
|
||||||
/// </summary>
|
|
||||||
public string AssetGUID { private set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源类型
|
|
||||||
/// </summary>
|
|
||||||
public System.Type AssetType { private set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源的分类标签
|
/// 资源的分类标签
|
||||||
@@ -52,25 +42,19 @@ namespace YooAsset.Editor
|
|||||||
public List<BuildAssetInfo> AllDependAssetInfos { private set; get; }
|
public List<BuildAssetInfo> AllDependAssetInfos { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
public BuildAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath)
|
public BuildAssetInfo(ECollectorType collectorType, string bundleName, string address, AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
CollectorType = collectorType;
|
CollectorType = collectorType;
|
||||||
BundleName = bundleName;
|
BundleName = bundleName;
|
||||||
Address = address;
|
Address = address;
|
||||||
AssetPath = assetPath;
|
AssetInfo = assetInfo;
|
||||||
|
|
||||||
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
|
|
||||||
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
|
||||||
}
|
}
|
||||||
public BuildAssetInfo(string assetPath)
|
public BuildAssetInfo(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
CollectorType = ECollectorType.None;
|
CollectorType = ECollectorType.None;
|
||||||
BundleName = string.Empty;
|
BundleName = string.Empty;
|
||||||
Address = string.Empty;
|
Address = string.Empty;
|
||||||
AssetPath = assetPath;
|
AssetInfo = assetInfo;
|
||||||
|
|
||||||
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
|
|
||||||
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -86,13 +70,14 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置为统一的着色器包名
|
/// 设置资源包名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SetShaderBundleName(string packageName, bool uniqueBundleName)
|
public void SetBundleName(string bundleName)
|
||||||
{
|
{
|
||||||
// 获取着色器打包规则结果
|
if (HasBundleName())
|
||||||
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
throw new System.Exception("Should never get here !");
|
||||||
BundleName = shaderPackRuleResult.GetBundleName(packageName, uniqueBundleName);
|
|
||||||
|
BundleName = bundleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -137,17 +122,6 @@ namespace YooAsset.Editor
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 判断是否为冗余资源
|
|
||||||
/// </summary>
|
|
||||||
public bool IsRedundancyAsset()
|
|
||||||
{
|
|
||||||
if (HasBundleName())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return _referenceBundleNames.Count > 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取关联资源包的数量
|
/// 获取关联资源包的数量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -82,12 +82,12 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加一个打包资源
|
/// 添加一个打包资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void PackAsset(BuildAssetInfo assetInfo)
|
public void PackAsset(BuildAssetInfo buildAsset)
|
||||||
{
|
{
|
||||||
if (IsContainsAsset(assetInfo.AssetPath))
|
if (IsContainsAsset(buildAsset.AssetInfo.AssetPath))
|
||||||
throw new System.Exception($"Should never get here ! Asset is existed : {assetInfo.AssetPath}");
|
throw new System.Exception($"Should never get here ! Asset is existed : {buildAsset.AssetInfo.AssetPath}");
|
||||||
|
|
||||||
MainAssets.Add(assetInfo);
|
MainAssets.Add(buildAsset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -95,9 +95,9 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsContainsAsset(string assetPath)
|
public bool IsContainsAsset(string assetPath)
|
||||||
{
|
{
|
||||||
foreach (var assetInfo in MainAssets)
|
foreach (var buildAsset in MainAssets)
|
||||||
{
|
{
|
||||||
if (assetInfo.AssetPath == assetPath)
|
if (buildAsset.AssetInfo.AssetPath == assetPath)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] GetAllMainAssetPaths()
|
public string[] GetAllMainAssetPaths()
|
||||||
{
|
{
|
||||||
return MainAssets.Select(t => t.AssetPath).ToArray();
|
return MainAssets.Select(t => t.AssetInfo.AssetPath).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -120,17 +120,17 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
var packAssets = GetAllMainAssetPaths();
|
var packAssets = GetAllMainAssetPaths();
|
||||||
List<string> result = new List<string>(packAssets);
|
List<string> result = new List<string>(packAssets);
|
||||||
foreach (var assetInfo in MainAssets)
|
foreach (var buildAsset in MainAssets)
|
||||||
{
|
{
|
||||||
if (assetInfo.AllDependAssetInfos == null)
|
if (buildAsset.AllDependAssetInfos == null)
|
||||||
continue;
|
continue;
|
||||||
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
|
foreach (var dependAssetInfo in buildAsset.AllDependAssetInfos)
|
||||||
{
|
{
|
||||||
// 注意:依赖资源里只添加零依赖资源和冗余资源
|
// 注意:依赖资源里只添加零依赖资源和冗余资源
|
||||||
if (dependAssetInfo.HasBundleName() == false)
|
if (dependAssetInfo.HasBundleName() == false)
|
||||||
{
|
{
|
||||||
if (result.Contains(dependAssetInfo.AssetPath) == false)
|
if (result.Contains(dependAssetInfo.AssetInfo.AssetPath) == false)
|
||||||
result.Add(dependAssetInfo.AssetPath);
|
result.Add(dependAssetInfo.AssetInfo.AssetPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public UnityEditor.AssetBundleBuild CreatePipelineBuild()
|
public UnityEditor.AssetBundleBuild CreatePipelineBuild()
|
||||||
{
|
{
|
||||||
// 注意:我们不在支持AssetBundle的变种机制
|
// 注意:我们不再支持AssetBundle的变种机制
|
||||||
AssetBundleBuild build = new AssetBundleBuild();
|
AssetBundleBuild build = new AssetBundleBuild();
|
||||||
build.assetBundleName = BundleName;
|
build.assetBundleName = BundleName;
|
||||||
build.assetBundleVariant = string.Empty;
|
build.assetBundleVariant = string.Empty;
|
||||||
@@ -165,10 +165,10 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
PackageBundle packageBundle = new PackageBundle();
|
PackageBundle packageBundle = new PackageBundle();
|
||||||
packageBundle.BundleName = BundleName;
|
packageBundle.BundleName = BundleName;
|
||||||
|
packageBundle.UnityCRC = PackageUnityCRC;
|
||||||
packageBundle.FileHash = PackageFileHash;
|
packageBundle.FileHash = PackageFileHash;
|
||||||
packageBundle.FileCRC = PackageFileCRC;
|
packageBundle.FileCRC = PackageFileCRC;
|
||||||
packageBundle.FileSize = PackageFileSize;
|
packageBundle.FileSize = PackageFileSize;
|
||||||
packageBundle.UnityCRC = PackageUnityCRC;
|
|
||||||
packageBundle.Encrypted = Encrypted;
|
packageBundle.Encrypted = Encrypted;
|
||||||
return packageBundle;
|
return packageBundle;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,9 @@ namespace YooAsset.Editor
|
|||||||
private readonly Dictionary<string, BuildBundleInfo> _bundleInfoDic = new Dictionary<string, BuildBundleInfo>(10000);
|
private readonly Dictionary<string, BuildBundleInfo> _bundleInfoDic = new Dictionary<string, BuildBundleInfo>(10000);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 冗余的资源列表
|
/// 未被依赖的资源列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly List<ReportRedundancyInfo> RedundancyInfos = new List<ReportRedundancyInfo>(1000);
|
public readonly List<ReportIndependAsset> IndependAssets = new List<ReportIndependAsset>(1000);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 参与构建的资源总数
|
/// 参与构建的资源总数
|
||||||
|
|||||||
@@ -47,6 +47,11 @@ namespace YooAsset.Editor
|
|||||||
public string PackageVersion;
|
public string PackageVersion;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否启用共享资源打包
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableSharePackRule = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证构建结果
|
/// 验证构建结果
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -161,7 +166,7 @@ namespace YooAsset.Editor
|
|||||||
/// 获取构建管线的输出目录
|
/// 获取构建管线的输出目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string GetPipelineOutputDirectory()
|
public virtual string GetPipelineOutputDirectory()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_pipelineOutputDirectory))
|
if (string.IsNullOrEmpty(_pipelineOutputDirectory))
|
||||||
{
|
{
|
||||||
@@ -173,7 +178,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取本次构建的补丁输出目录
|
/// 获取本次构建的补丁输出目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetPackageOutputDirectory()
|
public virtual string GetPackageOutputDirectory()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_packageOutputDirectory))
|
if (string.IsNullOrEmpty(_packageOutputDirectory))
|
||||||
{
|
{
|
||||||
@@ -185,7 +190,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取本次构建的补丁根目录
|
/// 获取本次构建的补丁根目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetPackageRootDirectory()
|
public virtual string GetPackageRootDirectory()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_packageRootDirectory))
|
if (string.IsNullOrEmpty(_packageRootDirectory))
|
||||||
{
|
{
|
||||||
@@ -197,7 +202,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取内置资源的根目录
|
/// 获取内置资源的根目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetBuildinRootDirectory()
|
public virtual string GetBuildinRootDirectory()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_buildinRootDirectory))
|
if (string.IsNullOrEmpty(_buildinRootDirectory))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -105,8 +105,8 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
PackageAsset packageAsset = new PackageAsset();
|
PackageAsset packageAsset = new PackageAsset();
|
||||||
packageAsset.Address = buildMapContext.Command.EnableAddressable ? assetInfo.Address : string.Empty;
|
packageAsset.Address = buildMapContext.Command.EnableAddressable ? assetInfo.Address : string.Empty;
|
||||||
packageAsset.AssetPath = assetInfo.AssetPath;
|
packageAsset.AssetPath = assetInfo.AssetInfo.AssetPath;
|
||||||
packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetGUID : string.Empty;
|
packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetInfo.AssetGUID : string.Empty;
|
||||||
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
||||||
packageAsset.BundleID = GetCachedBundleID(assetInfo.BundleName);
|
packageAsset.BundleID = GetCachedBundleID(assetInfo.BundleName);
|
||||||
result.Add(packageAsset);
|
result.Add(packageAsset);
|
||||||
|
|||||||
@@ -31,16 +31,18 @@ namespace YooAsset.Editor
|
|||||||
buildReport.Summary.BuildMode = buildParameters.BuildMode;
|
buildReport.Summary.BuildMode = buildParameters.BuildMode;
|
||||||
buildReport.Summary.BuildPackageName = buildParameters.PackageName;
|
buildReport.Summary.BuildPackageName = buildParameters.PackageName;
|
||||||
buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion;
|
buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion;
|
||||||
|
|
||||||
|
// 收集器配置
|
||||||
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
|
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
|
||||||
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||||
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
|
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||||
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||||
buildReport.Summary.IgnoreDefaultType = buildMapContext.Command.IgnoreDefaultType;
|
buildReport.Summary.IgnoreDefaultType = buildMapContext.Command.IgnoreDefaultType;
|
||||||
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
|
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
|
||||||
buildReport.Summary.EncryptionClassName = buildParameters.EncryptionServices == null ?
|
|
||||||
"null" : buildParameters.EncryptionServices.GetType().FullName;
|
|
||||||
|
|
||||||
// 构建参数
|
// 构建参数
|
||||||
|
buildReport.Summary.EnableSharePackRule = buildParameters.EnableSharePackRule;
|
||||||
|
buildReport.Summary.EncryptionClassName = buildParameters.EncryptionServices == null ? "null" : buildParameters.EncryptionServices.GetType().FullName;
|
||||||
if (buildParameters.BuildPipeline == nameof(BuiltinBuildPipeline))
|
if (buildParameters.BuildPipeline == nameof(BuiltinBuildPipeline))
|
||||||
{
|
{
|
||||||
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
||||||
@@ -107,8 +109,8 @@ namespace YooAsset.Editor
|
|||||||
buildReport.BundleInfos.Add(reportBundleInfo);
|
buildReport.BundleInfos.Add(reportBundleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 冗余资源列表
|
// 其它资源列表
|
||||||
buildReport.RedundancyInfos = new List<ReportRedundancyInfo>(buildMapContext.RedundancyInfos);
|
buildReport.IndependAssets = new List<ReportIndependAsset>(buildMapContext.IndependAssets);
|
||||||
|
|
||||||
// 序列化文件
|
// 序列化文件
|
||||||
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
@@ -140,11 +142,11 @@ namespace YooAsset.Editor
|
|||||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||||
{
|
{
|
||||||
BuildAssetInfo findAssetInfo = null;
|
BuildAssetInfo findAssetInfo = null;
|
||||||
foreach (var assetInfo in bundleInfo.MainAssets)
|
foreach (var buildAsset in bundleInfo.MainAssets)
|
||||||
{
|
{
|
||||||
if (assetInfo.AssetPath == assetPath)
|
if (buildAsset.AssetInfo.AssetPath == assetPath)
|
||||||
{
|
{
|
||||||
findAssetInfo = assetInfo;
|
findAssetInfo = buildAsset;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,7 +156,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
foreach (var dependAssetInfo in findAssetInfo.AllDependAssetInfos)
|
foreach (var dependAssetInfo in findAssetInfo.AllDependAssetInfos)
|
||||||
{
|
{
|
||||||
result.Add(dependAssetInfo.AssetPath);
|
result.Add(dependAssetInfo.AssetInfo.AssetPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildMapContext CreateBuildMap(BuildParameters buildParameters)
|
public BuildMapContext CreateBuildMap(BuildParameters buildParameters)
|
||||||
{
|
{
|
||||||
|
BuildMapContext context = new BuildMapContext();
|
||||||
var buildMode = buildParameters.BuildMode;
|
var buildMode = buildParameters.BuildMode;
|
||||||
var packageName = buildParameters.PackageName;
|
var packageName = buildParameters.PackageName;
|
||||||
|
|
||||||
@@ -21,103 +22,107 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 1. 获取所有收集器收集的资源
|
// 1. 获取所有收集器收集的资源
|
||||||
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
||||||
List<CollectAssetInfo> allCollectAssetInfos = collectResult.CollectAssets;
|
List<CollectAssetInfo> allCollectAssets = collectResult.CollectAssets;
|
||||||
|
|
||||||
// 2. 剔除未被引用的依赖项资源
|
// 2. 剔除未被引用的依赖项资源
|
||||||
RemoveZeroReferenceAssets(allCollectAssetInfos);
|
RemoveZeroReferenceAssets(context, allCollectAssets);
|
||||||
|
|
||||||
// 3. 录入所有收集器主动收集的资源
|
// 3. 录入所有收集器主动收集的资源
|
||||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
foreach (var collectAssetInfo in allCollectAssets)
|
||||||
{
|
{
|
||||||
if (allBuildAssetInfos.ContainsKey(collectAssetInfo.AssetPath) == false)
|
if (allBuildAssetInfos.ContainsKey(collectAssetInfo.AssetInfo.AssetPath))
|
||||||
{
|
{
|
||||||
|
throw new Exception($"Should never get here !");
|
||||||
|
}
|
||||||
|
|
||||||
if (collectAssetInfo.CollectorType != ECollectorType.MainAssetCollector)
|
if (collectAssetInfo.CollectorType != ECollectorType.MainAssetCollector)
|
||||||
{
|
{
|
||||||
if (collectAssetInfo.AssetTags.Count > 0)
|
if (collectAssetInfo.AssetTags.Count > 0)
|
||||||
{
|
{
|
||||||
collectAssetInfo.AssetTags.Clear();
|
collectAssetInfo.AssetTags.Clear();
|
||||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.RemoveInvalidTags, $"Remove asset tags that don't work, see the asset collector type : {collectAssetInfo.AssetPath}");
|
string warning = BuildLogger.GetErrorMessage(ErrorCode.RemoveInvalidTags, $"Remove asset tags that don't work, see the asset collector type : {collectAssetInfo.AssetInfo.AssetPath}");
|
||||||
BuildLogger.Warning(warning);
|
BuildLogger.Warning(warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.CollectorType, collectAssetInfo.BundleName, collectAssetInfo.Address, collectAssetInfo.AssetPath);
|
var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.CollectorType, collectAssetInfo.BundleName, collectAssetInfo.Address, collectAssetInfo.AssetInfo);
|
||||||
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
|
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
|
||||||
allBuildAssetInfos.Add(collectAssetInfo.AssetPath, buildAssetInfo);
|
allBuildAssetInfos.Add(collectAssetInfo.AssetInfo.AssetPath, buildAssetInfo);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception($"Should never get here !");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 录入所有收集资源依赖的其它资源
|
// 4. 录入所有收集资源依赖的其它资源
|
||||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
foreach (var collectAssetInfo in allCollectAssets)
|
||||||
{
|
{
|
||||||
string bundleName = collectAssetInfo.BundleName;
|
string bundleName = collectAssetInfo.BundleName;
|
||||||
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
|
foreach (var dependAsset in collectAssetInfo.DependAssets)
|
||||||
{
|
{
|
||||||
if (allBuildAssetInfos.ContainsKey(dependAssetPath))
|
if (allBuildAssetInfos.ContainsKey(dependAsset.AssetPath))
|
||||||
{
|
{
|
||||||
allBuildAssetInfos[dependAssetPath].AddReferenceBundleName(bundleName);
|
allBuildAssetInfos[dependAsset.AssetPath].AddReferenceBundleName(bundleName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var buildAssetInfo = new BuildAssetInfo(dependAssetPath);
|
var buildAssetInfo = new BuildAssetInfo(dependAsset);
|
||||||
buildAssetInfo.AddReferenceBundleName(bundleName);
|
buildAssetInfo.AddReferenceBundleName(bundleName);
|
||||||
allBuildAssetInfos.Add(dependAssetPath, buildAssetInfo);
|
allBuildAssetInfos.Add(dependAsset.AssetPath, buildAssetInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. 填充所有收集资源的依赖列表
|
// 5. 填充所有收集资源的依赖列表
|
||||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
foreach (var collectAssetInfo in allCollectAssets)
|
||||||
{
|
{
|
||||||
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
|
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
|
||||||
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
|
foreach (var dependAsset in collectAssetInfo.DependAssets)
|
||||||
{
|
{
|
||||||
if (allBuildAssetInfos.TryGetValue(dependAssetPath, out BuildAssetInfo value))
|
if (allBuildAssetInfos.TryGetValue(dependAsset.AssetPath, out BuildAssetInfo value))
|
||||||
dependAssetInfos.Add(value);
|
dependAssetInfos.Add(value);
|
||||||
else
|
else
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
}
|
}
|
||||||
allBuildAssetInfos[collectAssetInfo.AssetPath].SetDependAssetInfos(dependAssetInfos);
|
allBuildAssetInfos[collectAssetInfo.AssetInfo.AssetPath].SetDependAssetInfos(dependAssetInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. 自动收集所有依赖的着色器
|
// 6. 自动收集所有依赖的着色器
|
||||||
if (collectResult.Command.AutoCollectShaders)
|
if (collectResult.Command.AutoCollectShaders)
|
||||||
{
|
{
|
||||||
|
// 获取着色器打包规则结果
|
||||||
|
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||||
|
string shaderBundleName = shaderPackRuleResult.GetBundleName(collectResult.Command.PackageName, collectResult.Command.UniqueBundleName);
|
||||||
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||||
{
|
{
|
||||||
if (buildAssetInfo.CollectorType == ECollectorType.None)
|
if (buildAssetInfo.CollectorType == ECollectorType.None)
|
||||||
{
|
{
|
||||||
if (buildAssetInfo.AssetType == typeof(UnityEngine.Shader) || buildAssetInfo.AssetType == typeof(UnityEngine.ShaderVariantCollection))
|
if (buildAssetInfo.AssetInfo.IsShaderAsset())
|
||||||
{
|
{
|
||||||
buildAssetInfo.SetShaderBundleName(collectResult.Command.PackageName, collectResult.Command.UniqueBundleName);
|
buildAssetInfo.SetBundleName(shaderBundleName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. 记录关键信息
|
// 7. 计算共享资源的包名
|
||||||
BuildMapContext context = new BuildMapContext();
|
if (buildParameters.EnableSharePackRule)
|
||||||
context.AssetFileCount = allBuildAssetInfos.Count;
|
{
|
||||||
context.Command = collectResult.Command;
|
PreProcessPackShareBundle(buildParameters, collectResult.Command, allBuildAssetInfos);
|
||||||
|
|
||||||
// 8. 记录冗余资源
|
|
||||||
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||||
{
|
{
|
||||||
if (buildAssetInfo.IsRedundancyAsset())
|
if (buildAssetInfo.HasBundleName() == false)
|
||||||
{
|
{
|
||||||
var redundancyInfo = new ReportRedundancyInfo();
|
PackRuleResult packRuleResult = GetShareBundleName(buildAssetInfo);
|
||||||
redundancyInfo.AssetPath = buildAssetInfo.AssetPath;
|
if (packRuleResult.IsValid())
|
||||||
redundancyInfo.AssetType = buildAssetInfo.AssetType.Name;
|
{
|
||||||
redundancyInfo.AssetGUID = buildAssetInfo.AssetGUID;
|
string shareBundleName = packRuleResult.GetShareBundleName(collectResult.Command.PackageName, collectResult.Command.UniqueBundleName);
|
||||||
redundancyInfo.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetPath);
|
buildAssetInfo.SetBundleName(shareBundleName);
|
||||||
redundancyInfo.Number = buildAssetInfo.GetReferenceBundleCount();
|
|
||||||
context.RedundancyInfos.Add(redundancyInfo);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
PostProcessPackShareBundle();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 8. 记录关键信息
|
||||||
|
context.AssetFileCount = allBuildAssetInfos.Count;
|
||||||
|
context.Command = collectResult.Command;
|
||||||
|
|
||||||
// 9. 移除不参与构建的资源
|
// 9. 移除不参与构建的资源
|
||||||
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
||||||
@@ -128,7 +133,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
foreach (var removeValue in removeBuildList)
|
foreach (var removeValue in removeBuildList)
|
||||||
{
|
{
|
||||||
allBuildAssetInfos.Remove(removeValue.AssetPath);
|
allBuildAssetInfos.Remove(removeValue.AssetInfo.AssetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10. 构建资源列表
|
// 10. 构建资源列表
|
||||||
@@ -145,35 +150,35 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
private void RemoveZeroReferenceAssets(List<CollectAssetInfo> allCollectAssetInfos)
|
private void RemoveZeroReferenceAssets(BuildMapContext context, List<CollectAssetInfo> allCollectAssets)
|
||||||
{
|
{
|
||||||
// 1. 检测是否任何存在依赖资源
|
// 1. 检测依赖资源收集器是否存在
|
||||||
if (allCollectAssetInfos.Exists(x => x.CollectorType == ECollectorType.DependAssetCollector) == false)
|
if (allCollectAssets.Exists(x => x.CollectorType == ECollectorType.DependAssetCollector) == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 2. 获取所有主资源的依赖资源集合
|
// 2. 获取所有主资源的依赖资源集合
|
||||||
HashSet<string> allDependAsset = new HashSet<string>();
|
HashSet<string> allDependAsset = new HashSet<string>();
|
||||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
foreach (var collectAsset in allCollectAssets)
|
||||||
{
|
{
|
||||||
var collectorType = collectAssetInfo.CollectorType;
|
var collectorType = collectAsset.CollectorType;
|
||||||
if (collectorType == ECollectorType.MainAssetCollector || collectorType == ECollectorType.StaticAssetCollector)
|
if (collectorType == ECollectorType.MainAssetCollector || collectorType == ECollectorType.StaticAssetCollector)
|
||||||
{
|
{
|
||||||
foreach (var dependAsset in collectAssetInfo.DependAssets)
|
foreach (var dependAsset in collectAsset.DependAssets)
|
||||||
{
|
{
|
||||||
if (allDependAsset.Contains(dependAsset) == false)
|
if (allDependAsset.Contains(dependAsset.AssetPath) == false)
|
||||||
allDependAsset.Add(dependAsset);
|
allDependAsset.Add(dependAsset.AssetPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 找出所有零引用的依赖资源集合
|
// 3. 找出所有零引用的依赖资源集合
|
||||||
List<CollectAssetInfo> removeList = new List<CollectAssetInfo>();
|
List<CollectAssetInfo> removeList = new List<CollectAssetInfo>();
|
||||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
foreach (var collectAssetInfo in allCollectAssets)
|
||||||
{
|
{
|
||||||
var collectorType = collectAssetInfo.CollectorType;
|
var collectorType = collectAssetInfo.CollectorType;
|
||||||
if (collectorType == ECollectorType.DependAssetCollector)
|
if (collectorType == ECollectorType.DependAssetCollector)
|
||||||
{
|
{
|
||||||
if (allDependAsset.Contains(collectAssetInfo.AssetPath) == false)
|
if (allDependAsset.Contains(collectAssetInfo.AssetInfo.AssetPath) == false)
|
||||||
removeList.Add(collectAssetInfo);
|
removeList.Add(collectAssetInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,10 +186,44 @@ namespace YooAsset.Editor
|
|||||||
// 4. 移除所有零引用的依赖资源
|
// 4. 移除所有零引用的依赖资源
|
||||||
foreach (var removeValue in removeList)
|
foreach (var removeValue in removeList)
|
||||||
{
|
{
|
||||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundUndependedAsset, $"Found undepended asset and remove it : {removeValue.AssetPath}");
|
string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundUndependedAsset, $"Found undepended asset and remove it : {removeValue.AssetInfo.AssetPath}");
|
||||||
BuildLogger.Warning(warning);
|
BuildLogger.Warning(warning);
|
||||||
allCollectAssetInfos.Remove(removeValue);
|
|
||||||
|
var independAsset = new ReportIndependAsset();
|
||||||
|
independAsset.AssetPath = removeValue.AssetInfo.AssetPath;
|
||||||
|
independAsset.AssetGUID = removeValue.AssetInfo.AssetGUID;
|
||||||
|
independAsset.AssetType = removeValue.AssetInfo.AssetType.ToString();
|
||||||
|
independAsset.FileSize = FileUtility.GetFileSize(removeValue.AssetInfo.AssetPath);
|
||||||
|
context.IndependAssets.Add(independAsset);
|
||||||
|
|
||||||
|
allCollectAssets.Remove(removeValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region 共享资源打包规则
|
||||||
|
/// <summary>
|
||||||
|
/// 共享资源打包前置处理
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void PreProcessPackShareBundle(BuildParameters buildParameters, CollectCommand command, Dictionary<string, BuildAssetInfo> allBuildAssetInfos)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 共享资源打包后置处理
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void PostProcessPackShareBundle()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取共享资源包名称
|
||||||
|
/// </summary>
|
||||||
|
protected virtual PackRuleResult GetShareBundleName(BuildAssetInfo buildAssetInfo)
|
||||||
|
{
|
||||||
|
string bundleName = Path.GetDirectoryName(buildAssetInfo.AssetInfo.AssetPath);
|
||||||
|
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,9 +44,9 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
bundleInfo.PackageUnityHash = GetUnityHash(bundleInfo, context);
|
bundleInfo.PackageUnityHash = GetUnityHash(bundleInfo, context);
|
||||||
bundleInfo.PackageUnityCRC = GetUnityCRC(bundleInfo, context);
|
bundleInfo.PackageUnityCRC = GetUnityCRC(bundleInfo, context);
|
||||||
bundleInfo.PackageFileHash = GetBundleFileHash(bundleInfo.PackageSourceFilePath, buildParametersContext);
|
bundleInfo.PackageFileHash = GetBundleFileHash(bundleInfo, buildParametersContext);
|
||||||
bundleInfo.PackageFileCRC = GetBundleFileCRC(bundleInfo.PackageSourceFilePath, buildParametersContext);
|
bundleInfo.PackageFileCRC = GetBundleFileCRC(bundleInfo, buildParametersContext);
|
||||||
bundleInfo.PackageFileSize = GetBundleFileSize(bundleInfo.PackageSourceFilePath, buildParametersContext);
|
bundleInfo.PackageFileSize = GetBundleFileSize(bundleInfo, buildParametersContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4.更新补丁包输出的文件路径
|
// 4.更新补丁包输出的文件路径
|
||||||
@@ -62,9 +62,9 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
protected abstract string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context);
|
protected abstract string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context);
|
||||||
protected abstract uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context);
|
protected abstract uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context);
|
||||||
protected abstract string GetBundleFileHash(string filePath, BuildParametersContext buildParametersContext);
|
protected abstract string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||||
protected abstract string GetBundleFileCRC(string filePath, BuildParametersContext buildParametersContext);
|
protected abstract string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||||
protected abstract long GetBundleFileSize(string filePath, BuildParametersContext buildParametersContext);
|
protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||||
|
|
||||||
protected string GetFilePathTempHash(string filePath)
|
protected string GetFilePathTempHash(string filePath)
|
||||||
{
|
{
|
||||||
@@ -74,5 +74,23 @@ namespace YooAsset.Editor
|
|||||||
// 注意:在文件路径的哈希值冲突的情况下,可以使用下面的方法
|
// 注意:在文件路径的哈希值冲突的情况下,可以使用下面的方法
|
||||||
//return $"{HashUtility.BytesMD5(bytes)}-{Guid.NewGuid():N}";
|
//return $"{HashUtility.BytesMD5(bytes)}-{Guid.NewGuid():N}";
|
||||||
}
|
}
|
||||||
|
protected long GetBundleTempSize(BuildBundleInfo bundleInfo)
|
||||||
|
{
|
||||||
|
long tempSize = 0;
|
||||||
|
|
||||||
|
var assetPaths = bundleInfo.GetAllMainAssetPaths();
|
||||||
|
foreach (var assetPath in assetPaths)
|
||||||
|
{
|
||||||
|
long size = FileUtility.GetFileSize(assetPath);
|
||||||
|
tempSize += size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tempSize == 0)
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BundleTempSizeIsZero, $"Bundle temp size is zero, check bundle main asset list : {bundleInfo.BundleName}");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
return tempSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,27 +60,30 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileHash(string filePath, BuildParametersContext buildParametersContext)
|
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||||
return GetFilePathTempHash(filePath);
|
return GetFilePathTempHash(filePath);
|
||||||
else
|
else
|
||||||
return HashUtility.FileMD5(filePath);
|
return HashUtility.FileMD5(filePath);
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileCRC(string filePath, BuildParametersContext buildParametersContext)
|
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||||
return "00000000"; //8位
|
return "00000000"; //8位
|
||||||
else
|
else
|
||||||
return HashUtility.FileCRC32(filePath);
|
return HashUtility.FileCRC32(filePath);
|
||||||
}
|
}
|
||||||
protected override long GetBundleFileSize(string filePath, BuildParametersContext buildParametersContext)
|
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||||
return 0;
|
return GetBundleTempSize(bundleInfo);
|
||||||
else
|
else
|
||||||
return FileUtility.GetFileSize(filePath);
|
return FileUtility.GetFileSize(filePath);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
|
||||||
using System.Linq;
|
|
||||||
using UnityEditor;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
@@ -26,6 +23,7 @@ namespace YooAsset.Editor
|
|||||||
new TaskGetBuildMap_BBP(),
|
new TaskGetBuildMap_BBP(),
|
||||||
new TaskBuilding_BBP(),
|
new TaskBuilding_BBP(),
|
||||||
new TaskVerifyBuildResult_BBP(),
|
new TaskVerifyBuildResult_BBP(),
|
||||||
|
new TaskEncryption_BBP(),
|
||||||
new TaskUpdateBundleInfo_BBP(),
|
new TaskUpdateBundleInfo_BBP(),
|
||||||
new TaskCreateManifest_BBP(),
|
new TaskCreateManifest_BBP(),
|
||||||
new TaskCreateReport_BBP(),
|
new TaskCreateReport_BBP(),
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ namespace YooAsset.Editor
|
|||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||||
foreach (var assetInfo in bundleInfo.MainAssets)
|
foreach (var buildAsset in bundleInfo.MainAssets)
|
||||||
{
|
{
|
||||||
EditorTools.CopyFile(assetInfo.AssetPath, dest, true);
|
EditorTools.CopyFile(buildAsset.AssetInfo.AssetPath, dest, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,13 @@ namespace YooAsset.Editor
|
|||||||
// 检测基础构建参数
|
// 检测基础构建参数
|
||||||
buildParametersContext.CheckBuildParameters();
|
buildParametersContext.CheckBuildParameters();
|
||||||
|
|
||||||
|
// 检测不被支持的参数
|
||||||
|
if (buildParameters.EnableSharePackRule)
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportSharePackRule, $"{nameof(EBuildPipeline.RawFileBuildPipeline)} not support share pack rule !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
|
||||||
// 检测不被支持的构建模式
|
// 检测不被支持的构建模式
|
||||||
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,27 +32,30 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileHash(string filePath, BuildParametersContext buildParametersContext)
|
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.SimulateBuild)
|
||||||
return GetFilePathTempHash(filePath);
|
return GetFilePathTempHash(filePath);
|
||||||
else
|
else
|
||||||
return HashUtility.FileMD5(filePath);
|
return HashUtility.FileMD5(filePath);
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileCRC(string filePath, BuildParametersContext buildParametersContext)
|
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.SimulateBuild)
|
||||||
return "00000000"; //8位
|
return "00000000"; //8位
|
||||||
else
|
else
|
||||||
return HashUtility.FileCRC32(filePath);
|
return HashUtility.FileCRC32(filePath);
|
||||||
}
|
}
|
||||||
protected override long GetBundleFileSize(string filePath, BuildParametersContext buildParametersContext)
|
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.SimulateBuild)
|
||||||
return 0;
|
return GetBundleTempSize(bundleInfo);
|
||||||
else
|
else
|
||||||
return FileUtility.GetFileSize(filePath);
|
return FileUtility.GetFileSize(filePath);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,27 +60,30 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileHash(string filePath, BuildParametersContext buildParametersContext)
|
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.SimulateBuild)
|
||||||
return GetFilePathTempHash(filePath);
|
return GetFilePathTempHash(filePath);
|
||||||
else
|
else
|
||||||
return HashUtility.FileMD5(filePath);
|
return HashUtility.FileMD5(filePath);
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileCRC(string filePath, BuildParametersContext buildParametersContext)
|
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.SimulateBuild)
|
||||||
return "00000000"; //8位
|
return "00000000"; //8位
|
||||||
else
|
else
|
||||||
return HashUtility.FileCRC32(filePath);
|
return HashUtility.FileCRC32(filePath);
|
||||||
}
|
}
|
||||||
protected override long GetBundleFileSize(string filePath, BuildParametersContext buildParametersContext)
|
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.SimulateBuild)
|
||||||
return 0;
|
return GetBundleTempSize(bundleInfo);
|
||||||
else
|
else
|
||||||
return FileUtility.GetFileSize(filePath);
|
return FileUtility.GetFileSize(filePath);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using UnityEditor.Build.Content;
|
|
||||||
using UnityEngine.U2D;
|
|
||||||
using UnityEditor.Build.Pipeline.Injector;
|
|
||||||
using UnityEditor.Build.Pipeline.Interfaces;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace UnityEditor.Build.Pipeline.Tasks
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Ref https://zhuanlan.zhihu.com/p/586918159
|
|
||||||
/// </summary>
|
|
||||||
public class RemoveSpriteAtlasRedundancy : IBuildTask
|
|
||||||
{
|
|
||||||
public int Version => 1;
|
|
||||||
|
|
||||||
[InjectContext]
|
|
||||||
IBundleWriteData writeDataParam;
|
|
||||||
|
|
||||||
public ReturnCode Run()
|
|
||||||
{
|
|
||||||
#if UNITY_2020_3_OR_NEWER
|
|
||||||
BundleWriteData writeData = (BundleWriteData)writeDataParam;
|
|
||||||
|
|
||||||
// 图集引用的精灵图片集合
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 移除图集引用的精力图片对象
|
|
||||||
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
|
|
||||||
|
|
||||||
return ReturnCode.Success;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -33,7 +33,6 @@ namespace UnityEditor.Build.Pipeline.Tasks
|
|||||||
|
|
||||||
// Packing
|
// Packing
|
||||||
buildTasks.Add(new GenerateBundlePacking());
|
buildTasks.Add(new GenerateBundlePacking());
|
||||||
buildTasks.Add(new RemoveSpriteAtlasRedundancy()); // Fix for SpriteAtlas Redundancy
|
|
||||||
buildTasks.Add(new UpdateBundleObjectLayout());
|
buildTasks.Add(new UpdateBundleObjectLayout());
|
||||||
buildTasks.Add(new GenerateBundleCommands());
|
buildTasks.Add(new GenerateBundleCommands());
|
||||||
buildTasks.Add(new GenerateSubAssetPathMaps());
|
buildTasks.Add(new GenerateSubAssetPathMaps());
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
|
||||||
using System.Linq;
|
|
||||||
using UnityEditor;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
@@ -26,6 +23,7 @@ namespace YooAsset.Editor
|
|||||||
new TaskGetBuildMap_SBP(),
|
new TaskGetBuildMap_SBP(),
|
||||||
new TaskBuilding_SBP(),
|
new TaskBuilding_SBP(),
|
||||||
new TaskVerifyBuildResult_SBP(),
|
new TaskVerifyBuildResult_SBP(),
|
||||||
|
new TaskEncryption_SBP(),
|
||||||
new TaskUpdateBundleInfo_SBP(),
|
new TaskUpdateBundleInfo_SBP(),
|
||||||
new TaskCreateManifest_SBP(),
|
new TaskCreateManifest_SBP(),
|
||||||
new TaskCreateReport_SBP(),
|
new TaskCreateReport_SBP(),
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace YooAsset.Editor
|
|||||||
PackageOutputDirectoryExists = 115,
|
PackageOutputDirectoryExists = 115,
|
||||||
RecommendScriptBuildPipeline = 130,
|
RecommendScriptBuildPipeline = 130,
|
||||||
BuildPipelineNotSupportBuildMode = 140,
|
BuildPipelineNotSupportBuildMode = 140,
|
||||||
|
BuildPipelineNotSupportSharePackRule = 141,
|
||||||
|
|
||||||
// TaskGetBuildMap
|
// TaskGetBuildMap
|
||||||
RemoveInvalidTags = 200,
|
RemoveInvalidTags = 200,
|
||||||
@@ -29,6 +30,7 @@ namespace YooAsset.Editor
|
|||||||
CharactersOverTheLimit = 400,
|
CharactersOverTheLimit = 400,
|
||||||
NotFoundUnityBundleHash = 401,
|
NotFoundUnityBundleHash = 401,
|
||||||
NotFoundUnityBundleCRC = 402,
|
NotFoundUnityBundleCRC = 402,
|
||||||
|
BundleTempSizeIsZero = 403,
|
||||||
|
|
||||||
// TaskVerifyBuildResult
|
// TaskVerifyBuildResult
|
||||||
UnintendedBuildBundle = 500,
|
UnintendedBuildBundle = 500,
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ namespace YooAsset.Editor
|
|||||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
||||||
var buildModeList = GetSupportBuildModes();
|
var buildModeList = GetSupportBuildModes();
|
||||||
int defaultIndex = buildModeList.FindIndex(x => x.Equals(buildMode));
|
int defaultIndex = buildModeList.FindIndex(x => x.Equals(buildMode));
|
||||||
|
if (defaultIndex < 0)
|
||||||
|
defaultIndex = (int)(EBuildMode)buildModeList[0];
|
||||||
_buildModeField = new PopupField<Enum>(buildModeList, defaultIndex);
|
_buildModeField = new PopupField<Enum>(buildModeList, defaultIndex);
|
||||||
_buildModeField.label = "Build Mode";
|
_buildModeField.label = "Build Mode";
|
||||||
_buildModeField.style.width = StyleWidth;
|
_buildModeField.style.width = StyleWidth;
|
||||||
@@ -83,6 +85,8 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
var encyptionClassName = AssetBundleBuilderSetting.GetPackageEncyptionClassName(PackageName, BuildPipeline);
|
var encyptionClassName = AssetBundleBuilderSetting.GetPackageEncyptionClassName(PackageName, BuildPipeline);
|
||||||
int defaultIndex = encryptionClassTypes.FindIndex(x => x.FullName.Equals(encyptionClassName));
|
int defaultIndex = encryptionClassTypes.FindIndex(x => x.FullName.Equals(encyptionClassName));
|
||||||
|
if (defaultIndex < 0)
|
||||||
|
defaultIndex = 0;
|
||||||
_encryptionField = new PopupField<Type>(encryptionClassTypes, defaultIndex);
|
_encryptionField = new PopupField<Type>(encryptionClassTypes, defaultIndex);
|
||||||
_encryptionField.label = "Encryption";
|
_encryptionField.label = "Encryption";
|
||||||
_encryptionField.style.width = StyleWidth;
|
_encryptionField.style.width = StyleWidth;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ namespace YooAsset.Editor
|
|||||||
buildParameters.BuildMode = buildMode;
|
buildParameters.BuildMode = buildMode;
|
||||||
buildParameters.PackageName = PackageName;
|
buildParameters.PackageName = PackageName;
|
||||||
buildParameters.PackageVersion = GetPackageVersion();
|
buildParameters.PackageVersion = GetPackageVersion();
|
||||||
|
buildParameters.EnableSharePackRule = true;
|
||||||
buildParameters.VerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.FileNameStyle = fileNameStyle;
|
buildParameters.FileNameStyle = fileNameStyle;
|
||||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ namespace YooAsset.Editor
|
|||||||
buildParameters.BuildMode = buildMode;
|
buildParameters.BuildMode = buildMode;
|
||||||
buildParameters.PackageName = PackageName;
|
buildParameters.PackageName = PackageName;
|
||||||
buildParameters.PackageVersion = GetPackageVersion();
|
buildParameters.PackageVersion = GetPackageVersion();
|
||||||
|
buildParameters.EnableSharePackRule = true;
|
||||||
buildParameters.VerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.FileNameStyle = fileNameStyle;
|
buildParameters.FileNameStyle = fileNameStyle;
|
||||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||||
|
|||||||
@@ -148,18 +148,29 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
|
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
|
||||||
|
|
||||||
// 收集打包资源
|
// 收集打包资源路径
|
||||||
|
List<string> findAssets =new List<string>();
|
||||||
if (AssetDatabase.IsValidFolder(CollectPath))
|
if (AssetDatabase.IsValidFolder(CollectPath))
|
||||||
{
|
{
|
||||||
string collectDirectory = CollectPath;
|
string collectDirectory = CollectPath;
|
||||||
string[] findAssets = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory);
|
string[] findResult = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory);
|
||||||
|
findAssets.AddRange(findResult);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string assetPath = CollectPath;
|
||||||
|
findAssets.Add(assetPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 收集打包资源信息
|
||||||
foreach (string assetPath in findAssets)
|
foreach (string assetPath in findAssets)
|
||||||
{
|
{
|
||||||
if (IsValidateAsset(command, assetPath) && IsCollectAsset(group, assetPath))
|
var assetInfo = new AssetInfo(assetPath);
|
||||||
|
if (IsValidateAsset(command, assetInfo) && IsCollectAsset(group, assetInfo))
|
||||||
{
|
{
|
||||||
if (result.ContainsKey(assetPath) == false)
|
if (result.ContainsKey(assetPath) == false)
|
||||||
{
|
{
|
||||||
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath);
|
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetInfo);
|
||||||
result.Add(assetPath, collectAssetInfo);
|
result.Add(assetPath, collectAssetInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -168,20 +179,6 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string assetPath = CollectPath;
|
|
||||||
if (IsValidateAsset(command, assetPath) && IsCollectAsset(group, assetPath))
|
|
||||||
{
|
|
||||||
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath);
|
|
||||||
result.Add(assetPath, collectAssetInfo);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception($"The collecting single asset file is invalid : {assetPath} in collector : {CollectPath}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检测可寻址地址是否重复
|
// 检测可寻址地址是否重复
|
||||||
if (command.EnableAddressable)
|
if (command.EnableAddressable)
|
||||||
@@ -192,7 +189,7 @@ namespace YooAsset.Editor
|
|||||||
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
||||||
{
|
{
|
||||||
string address = collectInfoPair.Value.Address;
|
string address = collectInfoPair.Value.Address;
|
||||||
string assetPath = collectInfoPair.Value.AssetPath;
|
string assetPath = collectInfoPair.Value.AssetInfo.AssetPath;
|
||||||
if (string.IsNullOrEmpty(address))
|
if (string.IsNullOrEmpty(address))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -211,61 +208,64 @@ namespace YooAsset.Editor
|
|||||||
return result.Values.ToList();
|
return result.Values.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建资源收集类
|
||||||
|
/// </summary>
|
||||||
|
private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
string address = GetAddress(command, group, assetPath);
|
string address = GetAddress(command, group, assetInfo);
|
||||||
string bundleName = GetBundleName(command, group, assetPath);
|
string bundleName = GetBundleName(command, group, assetInfo);
|
||||||
List<string> assetTags = GetAssetTags(group);
|
List<string> assetTags = GetAssetTags(group);
|
||||||
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags);
|
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetInfo, assetTags);
|
||||||
|
|
||||||
// 注意:模拟构建模式下不需要收集依赖资源
|
// 注意:模拟构建模式下不需要收集依赖资源
|
||||||
if (command.BuildMode == EBuildMode.SimulateBuild)
|
if (command.BuildMode == EBuildMode.SimulateBuild)
|
||||||
collectAssetInfo.DependAssets = new List<string>();
|
collectAssetInfo.DependAssets = new List<AssetInfo>();
|
||||||
else
|
else
|
||||||
collectAssetInfo.DependAssets = GetAllDependencies(command, assetPath);
|
collectAssetInfo.DependAssets = GetAllDependencies(command, assetInfo.AssetPath);
|
||||||
|
|
||||||
return collectAssetInfo;
|
return collectAssetInfo;
|
||||||
}
|
}
|
||||||
private bool IsValidateAsset(CollectCommand command, string assetPath)
|
|
||||||
|
private bool IsValidateAsset(CollectCommand command, AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
if (assetPath.StartsWith("Assets/") == false && assetPath.StartsWith("Packages/") == false)
|
if (assetInfo.AssetPath.StartsWith("Assets/") == false && assetInfo.AssetPath.StartsWith("Packages/") == false)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogError($"Invalid asset path : {assetPath}");
|
UnityEngine.Debug.LogError($"Invalid asset path : {assetInfo.AssetPath}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 忽略文件夹
|
// 忽略文件夹
|
||||||
if (AssetDatabase.IsValidFolder(assetPath))
|
if (AssetDatabase.IsValidFolder(assetInfo.AssetPath))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// 忽略编辑器下的类型资源
|
// 忽略编辑器下的类型资源
|
||||||
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
if (assetInfo.AssetType == typeof(LightingDataAsset))
|
||||||
if (assetType == typeof(LightingDataAsset))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// 忽略Unity引擎无法识别的文件
|
// 忽略Unity引擎无法识别的文件
|
||||||
if (command.IgnoreDefaultType)
|
if (command.IgnoreDefaultType)
|
||||||
{
|
{
|
||||||
if (assetType == typeof(UnityEditor.DefaultAsset))
|
if (assetInfo.AssetType == typeof(UnityEditor.DefaultAsset))
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogWarning($"Cannot pack default asset : {assetPath}");
|
UnityEngine.Debug.LogWarning($"Cannot pack default asset : {assetInfo.AssetPath}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string fileExtension = System.IO.Path.GetExtension(assetPath);
|
if (DefaultFilterRule.IsIgnoreFile(assetInfo.FileExtension))
|
||||||
if (DefaultFilterRule.IsIgnoreFile(fileExtension))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private bool IsCollectAsset(AssetBundleCollectorGroup group, string assetPath)
|
private bool IsCollectAsset(AssetBundleCollectorGroup group, AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
// 根据规则设置过滤资源文件
|
// 根据规则设置过滤资源文件
|
||||||
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
|
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
|
||||||
return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetInfo.AssetPath, CollectPath, group.GroupName, UserData));
|
||||||
}
|
}
|
||||||
private string GetAddress(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
private string GetAddress(CollectCommand command, AssetBundleCollectorGroup group, AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
if (command.EnableAddressable == false)
|
if (command.EnableAddressable == false)
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
@@ -274,15 +274,14 @@ namespace YooAsset.Editor
|
|||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
||||||
IAddressRule addressRuleInstance = AssetBundleCollectorSettingData.GetAddressRuleInstance(AddressRuleName);
|
IAddressRule addressRuleInstance = AssetBundleCollectorSettingData.GetAddressRuleInstance(AddressRuleName);
|
||||||
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetInfo.AssetPath, CollectPath, group.GroupName, UserData));
|
||||||
return adressValue;
|
return adressValue;
|
||||||
}
|
}
|
||||||
private string GetBundleName(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
private string GetBundleName(CollectCommand command, AssetBundleCollectorGroup group, AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
if (command.AutoCollectShaders)
|
if (command.AutoCollectShaders)
|
||||||
{
|
{
|
||||||
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
if (assetInfo.IsShaderAsset())
|
||||||
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
|
|
||||||
{
|
{
|
||||||
// 获取着色器打包规则结果
|
// 获取着色器打包规则结果
|
||||||
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||||
@@ -292,7 +291,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 获取其它资源打包规则结果
|
// 获取其它资源打包规则结果
|
||||||
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
||||||
PackRuleResult defaultPackRuleResult = packRuleInstance.GetPackRuleResult(new PackRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
PackRuleResult defaultPackRuleResult = packRuleInstance.GetPackRuleResult(new PackRuleData(assetInfo.AssetPath, CollectPath, group.GroupName, UserData));
|
||||||
return defaultPackRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName);
|
return defaultPackRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName);
|
||||||
}
|
}
|
||||||
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
||||||
@@ -302,18 +301,19 @@ namespace YooAsset.Editor
|
|||||||
tags.AddRange(temper);
|
tags.AddRange(temper);
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
private List<string> GetAllDependencies(CollectCommand command, string mainAssetPath)
|
private List<AssetInfo> GetAllDependencies(CollectCommand command, string mainAssetPath)
|
||||||
{
|
{
|
||||||
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
|
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
|
||||||
List<string> result = new List<string>(depends.Length);
|
List<AssetInfo> result = new List<AssetInfo>(depends.Length);
|
||||||
foreach (string assetPath in depends)
|
foreach (string assetPath in depends)
|
||||||
{
|
{
|
||||||
// 注意:排除主资源对象
|
// 注意:排除主资源对象
|
||||||
if (assetPath == mainAssetPath)
|
if (assetPath == mainAssetPath)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (IsValidateAsset(command, assetPath))
|
AssetInfo assetInfo = new AssetInfo(assetPath);
|
||||||
result.Add(assetPath);
|
if (IsValidateAsset(command, assetInfo))
|
||||||
|
result.Add(assetInfo);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ namespace YooAsset.Editor
|
|||||||
if (AssetBundleCollectorSettingData.HasActiveRuleName(ActiveRuleName) == false)
|
if (AssetBundleCollectorSettingData.HasActiveRuleName(ActiveRuleName) == false)
|
||||||
throw new Exception($"Invalid {nameof(IActiveRule)} class type : {ActiveRuleName} in group : {GroupName}");
|
throw new Exception($"Invalid {nameof(IActiveRule)} class type : {ActiveRuleName} in group : {GroupName}");
|
||||||
|
|
||||||
|
// 检测分组是否激活
|
||||||
|
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(ActiveRuleName);
|
||||||
|
if (activeRule.IsActiveGroup() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
foreach (var collector in Collectors)
|
foreach (var collector in Collectors)
|
||||||
{
|
{
|
||||||
collector.CheckConfigError();
|
collector.CheckConfigError();
|
||||||
@@ -84,12 +89,12 @@ namespace YooAsset.Editor
|
|||||||
foreach (var collector in Collectors)
|
foreach (var collector in Collectors)
|
||||||
{
|
{
|
||||||
var temper = collector.GetAllCollectAssets(command, this);
|
var temper = collector.GetAllCollectAssets(command, this);
|
||||||
foreach (var assetInfo in temper)
|
foreach (var collectAsset in temper)
|
||||||
{
|
{
|
||||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
if (result.ContainsKey(collectAsset.AssetInfo.AssetPath) == false)
|
||||||
result.Add(assetInfo.AssetPath, assetInfo);
|
result.Add(collectAsset.AssetInfo.AssetPath, collectAsset);
|
||||||
else
|
else
|
||||||
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath} in group : {GroupName}");
|
throw new Exception($"The collecting asset file is existed : {collectAsset.AssetInfo.AssetPath} in group : {GroupName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,12 +102,12 @@ namespace YooAsset.Editor
|
|||||||
if (command.EnableAddressable)
|
if (command.EnableAddressable)
|
||||||
{
|
{
|
||||||
var addressTemper = new Dictionary<string, string>();
|
var addressTemper = new Dictionary<string, string>();
|
||||||
foreach (var collectInfoPair in result)
|
foreach (var collectAssetPair in result)
|
||||||
{
|
{
|
||||||
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
if (collectAssetPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
||||||
{
|
{
|
||||||
string address = collectInfoPair.Value.Address;
|
string address = collectAssetPair.Value.Address;
|
||||||
string assetPath = collectInfoPair.Value.AssetPath;
|
string assetPath = collectAssetPair.Value.AssetInfo.AssetPath;
|
||||||
if (string.IsNullOrEmpty(address))
|
if (string.IsNullOrEmpty(address))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -89,12 +89,12 @@ namespace YooAsset.Editor
|
|||||||
foreach (var group in Groups)
|
foreach (var group in Groups)
|
||||||
{
|
{
|
||||||
var temper = group.GetAllCollectAssets(command);
|
var temper = group.GetAllCollectAssets(command);
|
||||||
foreach (var assetInfo in temper)
|
foreach (var collectAsset in temper)
|
||||||
{
|
{
|
||||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
if (result.ContainsKey(collectAsset.AssetInfo.AssetPath) == false)
|
||||||
result.Add(assetInfo.AssetPath, assetInfo);
|
result.Add(collectAsset.AssetInfo.AssetPath, collectAsset);
|
||||||
else
|
else
|
||||||
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath}");
|
throw new Exception($"The collecting asset file is existed : {collectAsset.AssetInfo.AssetPath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ namespace YooAsset.Editor
|
|||||||
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
||||||
{
|
{
|
||||||
string address = collectInfoPair.Value.Address;
|
string address = collectInfoPair.Value.Address;
|
||||||
string assetPath = collectInfoPair.Value.AssetPath;
|
string assetPath = collectInfoPair.Value.AssetInfo.AssetPath;
|
||||||
if (string.IsNullOrEmpty(address))
|
if (string.IsNullOrEmpty(address))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -65,9 +65,6 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
public void CreateGUI()
|
public void CreateGUI()
|
||||||
{
|
{
|
||||||
Undo.undoRedoPerformed -= RefreshWindow;
|
|
||||||
Undo.undoRedoPerformed += RefreshWindow;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_collectorTypeList = new List<string>()
|
_collectorTypeList = new List<string>()
|
||||||
@@ -347,6 +344,15 @@ namespace YooAsset.Editor
|
|||||||
Debug.LogError(e.ToString());
|
Debug.LogError(e.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void OnEnable()
|
||||||
|
{
|
||||||
|
Undo.undoRedoPerformed += RefreshWindow;
|
||||||
|
}
|
||||||
|
public void OnDisable()
|
||||||
|
{
|
||||||
|
if (Undo.undoRedoPerformed != null)
|
||||||
|
Undo.undoRedoPerformed -= RefreshWindow;
|
||||||
|
}
|
||||||
public void OnDestroy()
|
public void OnDestroy()
|
||||||
{
|
{
|
||||||
// 注意:清空所有撤销操作
|
// 注意:清空所有撤销操作
|
||||||
@@ -991,15 +997,15 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
if (collectAssetInfos != null)
|
if (collectAssetInfos != null)
|
||||||
{
|
{
|
||||||
foreach (var collectAssetInfo in collectAssetInfos)
|
foreach (var collectAsset in collectAssetInfos)
|
||||||
{
|
{
|
||||||
VisualElement elementRow = new VisualElement();
|
VisualElement elementRow = new VisualElement();
|
||||||
elementRow.style.flexDirection = FlexDirection.Row;
|
elementRow.style.flexDirection = FlexDirection.Row;
|
||||||
foldout.Add(elementRow);
|
foldout.Add(elementRow);
|
||||||
|
|
||||||
string showInfo = collectAssetInfo.AssetPath;
|
string showInfo = collectAsset.AssetInfo.AssetPath;
|
||||||
if (_enableAddressableToogle.value)
|
if (_enableAddressableToogle.value)
|
||||||
showInfo = $"[{collectAssetInfo.Address}] {collectAssetInfo.AssetPath}";
|
showInfo = $"[{collectAsset.Address}] {collectAsset.AssetInfo.AssetPath}";
|
||||||
|
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.text = showInfo;
|
label.text = showInfo;
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ namespace YooAsset.Editor
|
|||||||
public string Address { private set; get; }
|
public string Address { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源路径
|
/// 资源信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetPath { private set; get; }
|
public AssetInfo AssetInfo { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源分类标签
|
/// 资源分类标签
|
||||||
@@ -33,15 +33,15 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 依赖的资源列表
|
/// 依赖的资源列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> DependAssets = new List<string>();
|
public List<AssetInfo> DependAssets = new List<AssetInfo>();
|
||||||
|
|
||||||
|
|
||||||
public CollectAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath, List<string> assetTags)
|
public CollectAssetInfo(ECollectorType collectorType, string bundleName, string address, AssetInfo assetInfo, List<string> assetTags)
|
||||||
{
|
{
|
||||||
CollectorType = collectorType;
|
CollectorType = collectorType;
|
||||||
BundleName = bundleName;
|
BundleName = bundleName;
|
||||||
Address = address;
|
Address = address;
|
||||||
AssetPath = assetPath;
|
AssetInfo = assetInfo;
|
||||||
AssetTags = assetTags;
|
AssetTags = assetTags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,14 @@ namespace YooAsset.Editor
|
|||||||
_bundleExtension = bundleExtension;
|
_bundleExtension = bundleExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 结果是否有效
|
||||||
|
/// </summary>
|
||||||
|
public bool IsValid()
|
||||||
|
{
|
||||||
|
return string.IsNullOrEmpty(_bundleName) == false && string.IsNullOrEmpty(_bundleExtension) == false;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包全名称
|
/// 获取资源包全名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -41,6 +49,20 @@ namespace YooAsset.Editor
|
|||||||
fullName = $"{bundleName}.{_bundleExtension}";
|
fullName = $"{bundleName}.{_bundleExtension}";
|
||||||
return fullName.ToLower();
|
return fullName.ToLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取共享资源包全名称
|
||||||
|
/// </summary>
|
||||||
|
public string GetShareBundleName(string packageName, bool uniqueBundleName)
|
||||||
|
{
|
||||||
|
string fullName;
|
||||||
|
string bundleName = EditorTools.GetRegularPath(_bundleName).Replace('/', '_').Replace('.', '_').ToLower();
|
||||||
|
if (uniqueBundleName)
|
||||||
|
fullName = $"{packageName}_share_{bundleName}.{_bundleExtension}";
|
||||||
|
else
|
||||||
|
fullName = $"share_{bundleName}.{_bundleExtension}";
|
||||||
|
return fullName.ToLower();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// Status
|
// Status
|
||||||
StyleColor textColor;
|
StyleColor textColor;
|
||||||
if (providerInfo.Status == ProviderBase.EStatus.Failed.ToString())
|
if (providerInfo.Status == EOperationStatus.Failed.ToString())
|
||||||
textColor = new StyleColor(Color.yellow);
|
textColor = new StyleColor(Color.yellow);
|
||||||
else
|
else
|
||||||
textColor = label1.style.color;
|
textColor = label1.style.color;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace YooAsset.Editor
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
AssetBundle newBundle = AssetBundle.LoadFromFile(filePath);
|
AssetBundle newBundle = AssetBundle.LoadFromFile(filePath);
|
||||||
if(newBundle != null)
|
if (newBundle != null)
|
||||||
{
|
{
|
||||||
string[] assetNames = newBundle.GetAllAssetNames();
|
string[] assetNames = newBundle.GetAllAssetNames();
|
||||||
foreach (string name in assetNames)
|
foreach (string name in assetNames)
|
||||||
@@ -54,7 +54,7 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void UnloadAll()
|
public static void UnloadAll()
|
||||||
{
|
{
|
||||||
foreach(var valuePair in _loadedAssetBundles)
|
foreach (var valuePair in _loadedAssetBundles)
|
||||||
{
|
{
|
||||||
if (valuePair.Value != null)
|
if (valuePair.Value != null)
|
||||||
valuePair.Value.Unload(true);
|
valuePair.Value.Unload(true);
|
||||||
|
|||||||
@@ -35,18 +35,12 @@ namespace YooAsset.Editor
|
|||||||
/// 资源包视图
|
/// 资源包视图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
BundleView,
|
BundleView,
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 冗余资源试图
|
|
||||||
/// </summary>
|
|
||||||
Redundancy,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ToolbarMenu _viewModeMenu;
|
private ToolbarMenu _viewModeMenu;
|
||||||
private ReporterSummaryViewer _summaryViewer;
|
private ReporterSummaryViewer _summaryViewer;
|
||||||
private ReporterAssetListViewer _assetListViewer;
|
private ReporterAssetListViewer _assetListViewer;
|
||||||
private ReporterBundleListViewer _bundleListViewer;
|
private ReporterBundleListViewer _bundleListViewer;
|
||||||
private ReporterRedundancyListViewer _redundancyListViewer;
|
|
||||||
|
|
||||||
private EViewMode _viewMode;
|
private EViewMode _viewMode;
|
||||||
private BuildReport _buildReport;
|
private BuildReport _buildReport;
|
||||||
@@ -76,7 +70,6 @@ namespace YooAsset.Editor
|
|||||||
_viewModeMenu.menu.AppendAction(EViewMode.Summary.ToString(), ViewModeMenuAction0, ViewModeMenuFun0);
|
_viewModeMenu.menu.AppendAction(EViewMode.Summary.ToString(), ViewModeMenuAction0, ViewModeMenuFun0);
|
||||||
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), ViewModeMenuAction1, ViewModeMenuFun1);
|
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), ViewModeMenuAction1, ViewModeMenuFun1);
|
||||||
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), ViewModeMenuAction2, ViewModeMenuFun2);
|
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), ViewModeMenuAction2, ViewModeMenuFun2);
|
||||||
_viewModeMenu.menu.AppendAction(EViewMode.Redundancy.ToString(), ViewModeMenuAction3, ViewModeMenuFun3);
|
|
||||||
|
|
||||||
// 搜索栏
|
// 搜索栏
|
||||||
var searchField = root.Q<ToolbarSearchField>("SearchField");
|
var searchField = root.Q<ToolbarSearchField>("SearchField");
|
||||||
@@ -94,10 +87,6 @@ namespace YooAsset.Editor
|
|||||||
_bundleListViewer = new ReporterBundleListViewer();
|
_bundleListViewer = new ReporterBundleListViewer();
|
||||||
_bundleListViewer.InitViewer();
|
_bundleListViewer.InitViewer();
|
||||||
|
|
||||||
// 加载试图
|
|
||||||
_redundancyListViewer = new ReporterRedundancyListViewer();
|
|
||||||
_redundancyListViewer.InitViewer();
|
|
||||||
|
|
||||||
// 显示视图
|
// 显示视图
|
||||||
_viewMode = EViewMode.Summary;
|
_viewMode = EViewMode.Summary;
|
||||||
_viewModeMenu.text = EViewMode.Summary.ToString();
|
_viewModeMenu.text = EViewMode.Summary.ToString();
|
||||||
@@ -125,7 +114,6 @@ namespace YooAsset.Editor
|
|||||||
_summaryViewer.FillViewData(_buildReport);
|
_summaryViewer.FillViewData(_buildReport);
|
||||||
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
||||||
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
|
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
|
||||||
_redundancyListViewer.FillViewData(_buildReport, _searchKeyWord);
|
|
||||||
}
|
}
|
||||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||||
{
|
{
|
||||||
@@ -146,7 +134,6 @@ namespace YooAsset.Editor
|
|||||||
_summaryViewer.AttachParent(root);
|
_summaryViewer.AttachParent(root);
|
||||||
_assetListViewer.DetachParent();
|
_assetListViewer.DetachParent();
|
||||||
_bundleListViewer.DetachParent();
|
_bundleListViewer.DetachParent();
|
||||||
_redundancyListViewer.DetachParent();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ViewModeMenuAction1(DropdownMenuAction action)
|
private void ViewModeMenuAction1(DropdownMenuAction action)
|
||||||
@@ -159,7 +146,6 @@ namespace YooAsset.Editor
|
|||||||
_summaryViewer.DetachParent();
|
_summaryViewer.DetachParent();
|
||||||
_assetListViewer.AttachParent(root);
|
_assetListViewer.AttachParent(root);
|
||||||
_bundleListViewer.DetachParent();
|
_bundleListViewer.DetachParent();
|
||||||
_redundancyListViewer.DetachParent();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ViewModeMenuAction2(DropdownMenuAction action)
|
private void ViewModeMenuAction2(DropdownMenuAction action)
|
||||||
@@ -172,20 +158,6 @@ namespace YooAsset.Editor
|
|||||||
_summaryViewer.DetachParent();
|
_summaryViewer.DetachParent();
|
||||||
_assetListViewer.DetachParent();
|
_assetListViewer.DetachParent();
|
||||||
_bundleListViewer.AttachParent(root);
|
_bundleListViewer.AttachParent(root);
|
||||||
_redundancyListViewer.DetachParent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ViewModeMenuAction3(DropdownMenuAction action)
|
|
||||||
{
|
|
||||||
if (_viewMode != EViewMode.Redundancy)
|
|
||||||
{
|
|
||||||
_viewMode = EViewMode.Redundancy;
|
|
||||||
VisualElement root = this.rootVisualElement;
|
|
||||||
_viewModeMenu.text = EViewMode.Redundancy.ToString();
|
|
||||||
_summaryViewer.DetachParent();
|
|
||||||
_assetListViewer.DetachParent();
|
|
||||||
_bundleListViewer.DetachParent();
|
|
||||||
_redundancyListViewer.AttachParent(root);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private DropdownMenuAction.Status ViewModeMenuFun0(DropdownMenuAction action)
|
private DropdownMenuAction.Status ViewModeMenuFun0(DropdownMenuAction action)
|
||||||
@@ -209,13 +181,6 @@ namespace YooAsset.Editor
|
|||||||
else
|
else
|
||||||
return DropdownMenuAction.Status.Normal;
|
return DropdownMenuAction.Status.Normal;
|
||||||
}
|
}
|
||||||
private DropdownMenuAction.Status ViewModeMenuFun3(DropdownMenuAction action)
|
|
||||||
{
|
|
||||||
if (_viewMode == EViewMode.Redundancy)
|
|
||||||
return DropdownMenuAction.Status.Checked;
|
|
||||||
else
|
|
||||||
return DropdownMenuAction.Status.Normal;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -28,10 +28,9 @@ namespace YooAsset.Editor
|
|||||||
public List<ReportBundleInfo> BundleInfos = new List<ReportBundleInfo>();
|
public List<ReportBundleInfo> BundleInfos = new List<ReportBundleInfo>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 冗余的资源列表
|
/// 未被依赖的资源列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ReportRedundancyInfo> RedundancyInfos = new List<ReportRedundancyInfo>();
|
public List<ReportIndependAsset> IndependAssets = new List<ReportIndependAsset>();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包信息类
|
/// 获取资源包信息类
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class ReportIndependAsset
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 资源路径
|
||||||
|
/// </summary>
|
||||||
|
public string AssetPath;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源GUID
|
||||||
|
/// </summary>
|
||||||
|
public string AssetGUID;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源类型
|
||||||
|
/// </summary>
|
||||||
|
public string AssetType;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源文件大小
|
||||||
|
/// </summary>
|
||||||
|
public long FileSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: a72c4edf1a81c9942a9d43e9d2a77b53
|
guid: 6f187b12ce298c0429119fcf194f2621
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
|
||||||
{
|
|
||||||
[Serializable]
|
|
||||||
public class ReportRedundancyInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 资源路径
|
|
||||||
/// </summary>
|
|
||||||
public string AssetPath;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源类型
|
|
||||||
/// </summary>
|
|
||||||
public string AssetType;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源GUID
|
|
||||||
/// 说明:Meta文件记录的GUID
|
|
||||||
/// </summary>
|
|
||||||
public string AssetGUID;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源文件大小
|
|
||||||
/// </summary>
|
|
||||||
public long FileSize;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 冗余的资源包数量
|
|
||||||
/// </summary>
|
|
||||||
public int Number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 7fbb7b27f54d3b0439a951348fd9d785
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -62,6 +62,7 @@ namespace YooAsset.Editor
|
|||||||
public bool AutoCollectShaders;
|
public bool AutoCollectShaders;
|
||||||
|
|
||||||
// 构建参数
|
// 构建参数
|
||||||
|
public bool EnableSharePackRule;
|
||||||
public string EncryptionClassName;
|
public string EncryptionClassName;
|
||||||
public EFileNameStyle FileNameStyle;
|
public EFileNameStyle FileNameStyle;
|
||||||
public ECompressOption CompressOption;
|
public ECompressOption CompressOption;
|
||||||
|
|||||||
@@ -1,317 +0,0 @@
|
|||||||
#if UNITY_2019_4_OR_NEWER
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEditor;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEditor.UIElements;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
|
||||||
{
|
|
||||||
internal class ReporterRedundancyListViewer
|
|
||||||
{
|
|
||||||
private enum ESortMode
|
|
||||||
{
|
|
||||||
AssetPath,
|
|
||||||
AssetType,
|
|
||||||
FileSize,
|
|
||||||
Number,
|
|
||||||
}
|
|
||||||
|
|
||||||
private VisualTreeAsset _visualAsset;
|
|
||||||
private TemplateContainer _root;
|
|
||||||
|
|
||||||
private ToolbarButton _topBar1;
|
|
||||||
private ToolbarButton _topBar2;
|
|
||||||
private ToolbarButton _topBar3;
|
|
||||||
private ToolbarButton _topBar4;
|
|
||||||
private ListView _assetListView;
|
|
||||||
|
|
||||||
private BuildReport _buildReport;
|
|
||||||
private string _searchKeyWord;
|
|
||||||
private ESortMode _sortMode = ESortMode.AssetPath;
|
|
||||||
private bool _descendingSort = false;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 初始化页面
|
|
||||||
/// </summary>
|
|
||||||
public void InitViewer()
|
|
||||||
{
|
|
||||||
// 加载布局文件
|
|
||||||
_visualAsset = UxmlLoader.LoadWindowUXML<ReporterRedundancyListViewer>();
|
|
||||||
if (_visualAsset == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_root = _visualAsset.CloneTree();
|
|
||||||
_root.style.flexGrow = 1f;
|
|
||||||
|
|
||||||
// 顶部按钮栏
|
|
||||||
_topBar1 = _root.Q<ToolbarButton>("TopBar1");
|
|
||||||
_topBar2 = _root.Q<ToolbarButton>("TopBar2");
|
|
||||||
_topBar3 = _root.Q<ToolbarButton>("TopBar3");
|
|
||||||
_topBar4 = _root.Q<ToolbarButton>("TopBar4");
|
|
||||||
_topBar1.clicked += TopBar1_clicked;
|
|
||||||
_topBar2.clicked += TopBar2_clicked;
|
|
||||||
_topBar3.clicked += TopBar3_clicked;
|
|
||||||
_topBar4.clicked += TopBar4_clicked;
|
|
||||||
|
|
||||||
// 资源列表
|
|
||||||
_assetListView = _root.Q<ListView>("TopListView");
|
|
||||||
_assetListView.makeItem = MakeAssetListViewItem;
|
|
||||||
_assetListView.bindItem = BindAssetListViewItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 填充页面数据
|
|
||||||
/// </summary>
|
|
||||||
public void FillViewData(BuildReport buildReport, string searchKeyWord)
|
|
||||||
{
|
|
||||||
_buildReport = buildReport;
|
|
||||||
_searchKeyWord = searchKeyWord;
|
|
||||||
RefreshView();
|
|
||||||
}
|
|
||||||
private void RefreshView()
|
|
||||||
{
|
|
||||||
_assetListView.Clear();
|
|
||||||
_assetListView.ClearSelection();
|
|
||||||
_assetListView.itemsSource = FilterAndSortViewItems();
|
|
||||||
_assetListView.Rebuild();
|
|
||||||
RefreshSortingSymbol();
|
|
||||||
}
|
|
||||||
private List<ReportRedundancyInfo> FilterAndSortViewItems()
|
|
||||||
{
|
|
||||||
List<ReportRedundancyInfo> result = new List<ReportRedundancyInfo>(_buildReport.RedundancyInfos.Count);
|
|
||||||
|
|
||||||
// 过滤列表
|
|
||||||
foreach (var redundancyInfo in _buildReport.RedundancyInfos)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(_searchKeyWord) == false)
|
|
||||||
{
|
|
||||||
if (redundancyInfo.AssetPath.Contains(_searchKeyWord) == false)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
result.Add(redundancyInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 排序列表
|
|
||||||
if (_sortMode == ESortMode.AssetPath)
|
|
||||||
{
|
|
||||||
if (_descendingSort)
|
|
||||||
return result.OrderByDescending(a => a.AssetPath).ToList();
|
|
||||||
else
|
|
||||||
return result.OrderBy(a => a.AssetPath).ToList();
|
|
||||||
}
|
|
||||||
else if(_sortMode == ESortMode.AssetType)
|
|
||||||
{
|
|
||||||
if (_descendingSort)
|
|
||||||
return result.OrderByDescending(a => a.AssetType).ToList();
|
|
||||||
else
|
|
||||||
return result.OrderBy(a => a.AssetType).ToList();
|
|
||||||
}
|
|
||||||
else if (_sortMode == ESortMode.FileSize)
|
|
||||||
{
|
|
||||||
if (_descendingSort)
|
|
||||||
return result.OrderByDescending(a => a.FileSize).ToList();
|
|
||||||
else
|
|
||||||
return result.OrderBy(a => a.FileSize).ToList();
|
|
||||||
}
|
|
||||||
else if (_sortMode == ESortMode.Number)
|
|
||||||
{
|
|
||||||
if (_descendingSort)
|
|
||||||
return result.OrderByDescending(a => a.Number).ToList();
|
|
||||||
else
|
|
||||||
return result.OrderBy(a => a.Number).ToList();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void RefreshSortingSymbol()
|
|
||||||
{
|
|
||||||
_topBar1.text = $"Asset Path ({_assetListView.itemsSource.Count})";
|
|
||||||
_topBar2.text = "Asset Type";
|
|
||||||
_topBar3.text = "File Size";
|
|
||||||
_topBar4.text = "Redundancy Num";
|
|
||||||
|
|
||||||
if (_sortMode == ESortMode.AssetPath)
|
|
||||||
{
|
|
||||||
if (_descendingSort)
|
|
||||||
_topBar1.text = $"Asset Path ({_assetListView.itemsSource.Count}) ↓";
|
|
||||||
else
|
|
||||||
_topBar1.text = $"Asset Path ({_assetListView.itemsSource.Count}) ↑";
|
|
||||||
}
|
|
||||||
else if(_sortMode == ESortMode.AssetType)
|
|
||||||
{
|
|
||||||
if (_descendingSort)
|
|
||||||
_topBar2.text = "Asset Type ↓";
|
|
||||||
else
|
|
||||||
_topBar2.text = "Asset Type ↑";
|
|
||||||
}
|
|
||||||
else if (_sortMode == ESortMode.FileSize)
|
|
||||||
{
|
|
||||||
if (_descendingSort)
|
|
||||||
_topBar3.text = "File Size ↓";
|
|
||||||
else
|
|
||||||
_topBar3.text = "File Size ↑";
|
|
||||||
}
|
|
||||||
else if (_sortMode == ESortMode.Number)
|
|
||||||
{
|
|
||||||
if (_descendingSort)
|
|
||||||
_topBar4.text = "Redundancy Num ↓";
|
|
||||||
else
|
|
||||||
_topBar4.text = "Redundancy Num ↑";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 挂接到父类页面上
|
|
||||||
/// </summary>
|
|
||||||
public void AttachParent(VisualElement parent)
|
|
||||||
{
|
|
||||||
parent.Add(_root);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 从父类页面脱离开
|
|
||||||
/// </summary>
|
|
||||||
public void DetachParent()
|
|
||||||
{
|
|
||||||
_root.RemoveFromHierarchy();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 资源列表相关
|
|
||||||
private VisualElement MakeAssetListViewItem()
|
|
||||||
{
|
|
||||||
VisualElement element = new VisualElement();
|
|
||||||
element.style.flexDirection = FlexDirection.Row;
|
|
||||||
|
|
||||||
{
|
|
||||||
var label = new Label();
|
|
||||||
label.name = "Label1";
|
|
||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
|
||||||
label.style.marginLeft = 3f;
|
|
||||||
label.style.flexGrow = 1f;
|
|
||||||
label.style.width = 280;
|
|
||||||
element.Add(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
var label = new Label();
|
|
||||||
label.name = "Label2";
|
|
||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
|
||||||
label.style.marginLeft = 3f;
|
|
||||||
label.style.flexGrow = 0;
|
|
||||||
label.style.width = 125;
|
|
||||||
element.Add(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
var label = new Label();
|
|
||||||
label.name = "Label3";
|
|
||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
|
||||||
label.style.marginLeft = 3f;
|
|
||||||
label.style.flexGrow = 0;
|
|
||||||
label.style.width = 125;
|
|
||||||
element.Add(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
var label = new Label();
|
|
||||||
label.name = "Label4";
|
|
||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
|
||||||
label.style.marginLeft = 3f;
|
|
||||||
label.style.flexGrow = 0;
|
|
||||||
label.style.width = 125;
|
|
||||||
element.Add(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
private void BindAssetListViewItem(VisualElement element, int index)
|
|
||||||
{
|
|
||||||
var sourceData = _assetListView.itemsSource as List<ReportRedundancyInfo>;
|
|
||||||
var redundancyInfo = sourceData[index];
|
|
||||||
|
|
||||||
// Asset Path
|
|
||||||
var label1 = element.Q<Label>("Label1");
|
|
||||||
label1.text = redundancyInfo.AssetPath;
|
|
||||||
|
|
||||||
// Asset Type
|
|
||||||
var label2 = element.Q<Label>("Label2");
|
|
||||||
label2.text = redundancyInfo.AssetType;
|
|
||||||
|
|
||||||
// File Size
|
|
||||||
var label3 = element.Q<Label>("Label3");
|
|
||||||
label3.text = EditorUtility.FormatBytes(redundancyInfo.FileSize);
|
|
||||||
|
|
||||||
// Number
|
|
||||||
var label4 = element.Q<Label>("Label4");
|
|
||||||
label4.text = redundancyInfo.Number.ToString();
|
|
||||||
}
|
|
||||||
private void TopBar1_clicked()
|
|
||||||
{
|
|
||||||
if (_sortMode != ESortMode.AssetPath)
|
|
||||||
{
|
|
||||||
_sortMode = ESortMode.AssetPath;
|
|
||||||
_descendingSort = false;
|
|
||||||
RefreshView();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_descendingSort = !_descendingSort;
|
|
||||||
RefreshView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void TopBar2_clicked()
|
|
||||||
{
|
|
||||||
if (_sortMode != ESortMode.AssetType)
|
|
||||||
{
|
|
||||||
_sortMode = ESortMode.AssetType;
|
|
||||||
_descendingSort = false;
|
|
||||||
RefreshView();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_descendingSort = !_descendingSort;
|
|
||||||
RefreshView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void TopBar3_clicked()
|
|
||||||
{
|
|
||||||
if (_sortMode != ESortMode.FileSize)
|
|
||||||
{
|
|
||||||
_sortMode = ESortMode.FileSize;
|
|
||||||
_descendingSort = false;
|
|
||||||
RefreshView();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_descendingSort = !_descendingSort;
|
|
||||||
RefreshView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void TopBar4_clicked()
|
|
||||||
{
|
|
||||||
if (_sortMode != ESortMode.Number)
|
|
||||||
{
|
|
||||||
_sortMode = ESortMode.Number;
|
|
||||||
_descendingSort = false;
|
|
||||||
RefreshView();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_descendingSort = !_descendingSort;
|
|
||||||
RefreshView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<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;" />
|
|
||||||
<uie:ToolbarButton text="Asset Type" display-tooltip-when-elided="true" name="TopBar2" style="width: 125px; -unity-text-align: middle-left; flex-grow: 0; flex-shrink: 1;" />
|
|
||||||
<uie:ToolbarButton text="File Size" display-tooltip-when-elided="true" name="TopBar3" style="width: 125px; -unity-text-align: middle-left; flex-grow: 0; flex-shrink: 1;" />
|
|
||||||
<uie:ToolbarButton text="Redundancy Num" display-tooltip-when-elided="true" name="TopBar4" style="width: 125px; -unity-text-align: middle-left; flex-grow: 0; flex-shrink: 1;" />
|
|
||||||
</uie:Toolbar>
|
|
||||||
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1; flex-basis: 60px;" />
|
|
||||||
</ui:VisualElement>
|
|
||||||
</ui:UXML>
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: a5296d9c037ce3944b5c197cbdd78a8b
|
|
||||||
ScriptedImporter:
|
|
||||||
internalIDToNameTable: []
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
|
||||||
@@ -67,7 +67,7 @@ namespace YooAsset.Editor
|
|||||||
_items.Add(new ItemWrapper("Package Version", buildReport.Summary.BuildPackageVersion));
|
_items.Add(new ItemWrapper("Package Version", buildReport.Summary.BuildPackageVersion));
|
||||||
|
|
||||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||||
_items.Add(new ItemWrapper("Settings", string.Empty));
|
_items.Add(new ItemWrapper("Collect Settings", string.Empty));
|
||||||
_items.Add(new ItemWrapper("Unique Bundle Name", $"{buildReport.Summary.UniqueBundleName}"));
|
_items.Add(new ItemWrapper("Unique Bundle Name", $"{buildReport.Summary.UniqueBundleName}"));
|
||||||
_items.Add(new ItemWrapper("Enable Addressable", $"{buildReport.Summary.EnableAddressable}"));
|
_items.Add(new ItemWrapper("Enable Addressable", $"{buildReport.Summary.EnableAddressable}"));
|
||||||
_items.Add(new ItemWrapper("Location To Lower", $"{buildReport.Summary.LocationToLower}"));
|
_items.Add(new ItemWrapper("Location To Lower", $"{buildReport.Summary.LocationToLower}"));
|
||||||
@@ -77,6 +77,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||||
_items.Add(new ItemWrapper("Build Params", string.Empty));
|
_items.Add(new ItemWrapper("Build Params", string.Empty));
|
||||||
|
_items.Add(new ItemWrapper("Enable Share Pack Rule", $"{buildReport.Summary.EnableSharePackRule}"));
|
||||||
_items.Add(new ItemWrapper("Encryption Class Name", buildReport.Summary.EncryptionClassName));
|
_items.Add(new ItemWrapper("Encryption Class Name", buildReport.Summary.EncryptionClassName));
|
||||||
_items.Add(new ItemWrapper("FileNameStyle", $"{buildReport.Summary.FileNameStyle}"));
|
_items.Add(new ItemWrapper("FileNameStyle", $"{buildReport.Summary.FileNameStyle}"));
|
||||||
_items.Add(new ItemWrapper("CompressOption", $"{buildReport.Summary.CompressOption}"));
|
_items.Add(new ItemWrapper("CompressOption", $"{buildReport.Summary.CompressOption}"));
|
||||||
|
|||||||
8
Assets/YooAsset/Editor/Common.meta
Normal file
8
Assets/YooAsset/Editor/Common.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4cb0b75b2f649c64bb1d8203f2fbfeea
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
58
Assets/YooAsset/Editor/Common/AssetInfo.cs
Normal file
58
Assets/YooAsset/Editor/Common/AssetInfo.cs
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class AssetInfo
|
||||||
|
{
|
||||||
|
private string _fileExtension = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源路径
|
||||||
|
/// </summary>
|
||||||
|
public string AssetPath;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源GUID
|
||||||
|
/// </summary>
|
||||||
|
public string AssetGUID;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源类型
|
||||||
|
/// </summary>
|
||||||
|
public System.Type AssetType;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件格式
|
||||||
|
/// </summary>
|
||||||
|
public string FileExtension
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_fileExtension))
|
||||||
|
_fileExtension = System.IO.Path.GetExtension(AssetPath);
|
||||||
|
return _fileExtension;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AssetInfo(string assetPath)
|
||||||
|
{
|
||||||
|
AssetPath = assetPath;
|
||||||
|
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(AssetPath);
|
||||||
|
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(AssetPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为着色器资源
|
||||||
|
/// </summary>
|
||||||
|
public bool IsShaderAsset()
|
||||||
|
{
|
||||||
|
if (AssetType == typeof(UnityEngine.Shader) || AssetType == typeof(UnityEngine.ShaderVariantCollection))
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: f01d5c82be95c8f4b93aeefc0454ae5c
|
guid: 4a2e0565919d49348b8deeb14258a985
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -496,6 +496,14 @@ namespace YooAsset.Editor
|
|||||||
return fileInfo.Length;
|
return fileInfo.Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取文件的哈希值
|
||||||
|
/// </summary>
|
||||||
|
public static string GetFileCRC32(string filePath)
|
||||||
|
{
|
||||||
|
return HashUtility.FileCRC32(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 读取文件的所有文本内容
|
/// 读取文件的所有文本内容
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -90,12 +90,19 @@ namespace YooAsset
|
|||||||
string fileRootPath = chidDirectory.FullName;
|
string fileRootPath = chidDirectory.FullName;
|
||||||
string dataFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleDataFileName}";
|
string dataFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleDataFileName}";
|
||||||
string infoFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleInfoFileName}";
|
string infoFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleInfoFileName}";
|
||||||
|
string dataFileExtension = FindDataFileExtension(chidDirectory);
|
||||||
|
|
||||||
|
// 跳过断点续传的临时文件
|
||||||
|
if (dataFileExtension == ".temp")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// 注意:根据配置需求数据文件会带文件格式
|
||||||
if (_persistent.AppendFileExtension)
|
if (_persistent.AppendFileExtension)
|
||||||
{
|
{
|
||||||
string fileExtension = FindFileExtension(chidDirectory);
|
if (string.IsNullOrEmpty(dataFileExtension) == false)
|
||||||
if (string.IsNullOrEmpty(fileExtension) == false)
|
dataFilePath += dataFileExtension;
|
||||||
dataFilePath += fileExtension;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VerifyCacheFileElement element = new VerifyCacheFileElement(_cache.PackageName, cacheGUID, fileRootPath, dataFilePath, infoFilePath);
|
VerifyCacheFileElement element = new VerifyCacheFileElement(_cache.PackageName, cacheGUID, fileRootPath, dataFilePath, infoFilePath);
|
||||||
VerifyElements.Add(element);
|
VerifyElements.Add(element);
|
||||||
}
|
}
|
||||||
@@ -106,14 +113,12 @@ namespace YooAsset
|
|||||||
|
|
||||||
return isFindItem;
|
return isFindItem;
|
||||||
}
|
}
|
||||||
private string FindFileExtension(DirectoryInfo directoryInfo)
|
private string FindDataFileExtension(DirectoryInfo directoryInfo)
|
||||||
{
|
{
|
||||||
string dataFileExtension = string.Empty;
|
string dataFileExtension = string.Empty;
|
||||||
var fileInfos = directoryInfo.GetFiles();
|
var fileInfos = directoryInfo.GetFiles();
|
||||||
foreach (var fileInfo in fileInfos)
|
foreach (var fileInfo in fileInfos)
|
||||||
{
|
{
|
||||||
if (fileInfo.Extension == ".temp")
|
|
||||||
continue;
|
|
||||||
if (fileInfo.Name.StartsWith(YooAssetSettings.CacheBundleDataFileName))
|
if (fileInfo.Name.StartsWith(YooAssetSettings.CacheBundleDataFileName))
|
||||||
{
|
{
|
||||||
dataFileExtension = fileInfo.Extension;
|
dataFileExtension = fileInfo.Extension;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
Directory.Delete(FileRootPath, true);
|
Directory.Delete(FileRootPath, true);
|
||||||
}
|
}
|
||||||
catch(System.Exception e)
|
catch (System.Exception e)
|
||||||
{
|
{
|
||||||
YooLogger.Warning($"Failed delete cache bundle folder : {e}");
|
YooLogger.Warning($"Failed delete cache bundle folder : {e}");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void EditorRequestDebugReport()
|
public static void EditorRequestDebugReport()
|
||||||
{
|
{
|
||||||
if(UnityEditor.EditorApplication.isPlaying)
|
if (UnityEditor.EditorApplication.isPlaying)
|
||||||
{
|
{
|
||||||
var report = YooAssets.GetDebugReport();
|
var report = YooAssets.GetDebugReport();
|
||||||
EditorHandleDebugReportCallback?.Invoke(0, report);
|
EditorHandleDebugReportCallback?.Invoke(0, report);
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ namespace YooAsset
|
|||||||
DownloaderBase newDownloader = null;
|
DownloaderBase newDownloader = null;
|
||||||
YooLogger.Log($"Beginning to download bundle : {bundleInfo.Bundle.BundleName} URL : {bundleInfo.RemoteMainURL}");
|
YooLogger.Log($"Beginning to download bundle : {bundleInfo.Bundle.BundleName} URL : {bundleInfo.RemoteMainURL}");
|
||||||
#if UNITY_WEBGL
|
#if UNITY_WEBGL
|
||||||
if (bundleInfo.Bundle.Buildpipeline == DefaultBuildPipeline.RawFileBuildPipelineName)
|
if (bundleInfo.Bundle.Buildpipeline == EDefaultBuildPipeline.RawFileBuildPipeline.ToString())
|
||||||
{
|
{
|
||||||
FileUtility.CreateFileDirectory(bundleInfo.CachedDataFilePath);
|
FileUtility.CreateFileDirectory(bundleInfo.CachedDataFilePath);
|
||||||
System.Type requesterType = typeof(FileGeneralRequest);
|
System.Type requesterType = typeof(FileGeneralRequest);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
|
using UnityEngine;
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ namespace YooAsset
|
|||||||
if (offset > _timeout)
|
if (offset > _timeout)
|
||||||
{
|
{
|
||||||
YooLogger.Warning($"Web file request timeout : {_requestURL}");
|
YooLogger.Warning($"Web file request timeout : {_requestURL}");
|
||||||
if(_requester != null)
|
if (_requester != null)
|
||||||
_requester.Abort();
|
_requester.Abort();
|
||||||
_isAbort = true;
|
_isAbort = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ namespace YooAsset
|
|||||||
public string RequestNetError { private set; get; }
|
public string RequestNetError { private set; get; }
|
||||||
public long RequestHttpCode { private set; get; }
|
public long RequestHttpCode { private set; get; }
|
||||||
|
|
||||||
|
public AssetBundleWebRequest() { }
|
||||||
public void Create(string requestURL, BundleInfo bundleInfo, params object[] args)
|
public void Create(string requestURL, BundleInfo bundleInfo, params object[] args)
|
||||||
{
|
{
|
||||||
if (Status != ERequestStatus.None)
|
if (Status != ERequestStatus.None)
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace YooAsset
|
|||||||
public string RequestNetError { private set; get; }
|
public string RequestNetError { private set; get; }
|
||||||
public long RequestHttpCode { private set; get; }
|
public long RequestHttpCode { private set; get; }
|
||||||
|
|
||||||
|
public FileGeneralRequest() { }
|
||||||
public void Create(string requestURL, BundleInfo bundleInfo, params object[] args)
|
public void Create(string requestURL, BundleInfo bundleInfo, params object[] args)
|
||||||
{
|
{
|
||||||
if (Status != ERequestStatus.None)
|
if (Status != ERequestStatus.None)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace YooAsset
|
|||||||
private string _tempFilePath;
|
private string _tempFilePath;
|
||||||
private UnityWebRequest _webRequest;
|
private UnityWebRequest _webRequest;
|
||||||
private DownloadHandlerFileRange _downloadHandle;
|
private DownloadHandlerFileRange _downloadHandle;
|
||||||
private ulong _fileOriginLength;
|
private ulong _fileOriginLength = 0;
|
||||||
|
|
||||||
public ERequestStatus Status { private set; get; } = ERequestStatus.None;
|
public ERequestStatus Status { private set; get; } = ERequestStatus.None;
|
||||||
public float DownloadProgress { private set; get; }
|
public float DownloadProgress { private set; get; }
|
||||||
@@ -16,6 +16,7 @@ namespace YooAsset
|
|||||||
public string RequestNetError { private set; get; }
|
public string RequestNetError { private set; get; }
|
||||||
public long RequestHttpCode { private set; get; }
|
public long RequestHttpCode { private set; get; }
|
||||||
|
|
||||||
|
public FileResumeRequest() { }
|
||||||
public void Create(string requestURL, BundleInfo bundleInfo, params object[] args)
|
public void Create(string requestURL, BundleInfo bundleInfo, params object[] args)
|
||||||
{
|
{
|
||||||
if (Status != ERequestStatus.None)
|
if (Status != ERequestStatus.None)
|
||||||
|
|||||||
@@ -76,10 +76,9 @@ namespace YooAsset
|
|||||||
public EVerifyLevel CacheBootVerifyLevel = EVerifyLevel.Middle;
|
public EVerifyLevel CacheBootVerifyLevel = EVerifyLevel.Middle;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源加载每帧处理的最大时间片段
|
/// 自动销毁不再使用的资源提供者
|
||||||
/// 注意:默认值为MaxValue
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long LoadingMaxTimeSlice = long.MaxValue;
|
public bool AutoDestroyAssetProvider = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用断点续传参数
|
/// 启用断点续传参数
|
||||||
|
|||||||
@@ -5,16 +5,24 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
public abstract class AsyncOperationBase : IEnumerator
|
public abstract class AsyncOperationBase : IEnumerator, IComparable<AsyncOperationBase>
|
||||||
{
|
{
|
||||||
// 用户请求的回调
|
// 用户请求的回调
|
||||||
private Action<AsyncOperationBase> _callback;
|
private Action<AsyncOperationBase> _callback;
|
||||||
|
|
||||||
|
// 是否已经完成
|
||||||
|
internal bool IsFinish = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 所属包裹
|
/// 所属包裹
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageName { private set; get; }
|
public string PackageName { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 优先级
|
||||||
|
/// </summary>
|
||||||
|
public uint Priority { set; get; } = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 状态
|
/// 状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -91,8 +99,14 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal void SetFinish()
|
internal void SetFinish()
|
||||||
{
|
{
|
||||||
|
IsFinish = true;
|
||||||
|
|
||||||
|
// 进度百分百完成
|
||||||
Progress = 1f;
|
Progress = 1f;
|
||||||
_callback?.Invoke(this); //注意:如果完成回调内发生异常,会导致Task无限期等待
|
|
||||||
|
//注意:如果完成回调内发生异常,会导致Task无限期等待
|
||||||
|
_callback?.Invoke(this);
|
||||||
|
|
||||||
if (_taskCompletionSource != null)
|
if (_taskCompletionSource != null)
|
||||||
_taskCompletionSource.TrySetResult(null);
|
_taskCompletionSource.TrySetResult(null);
|
||||||
}
|
}
|
||||||
@@ -115,6 +129,13 @@ namespace YooAsset
|
|||||||
_callback = null;
|
_callback = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region 排序接口实现
|
||||||
|
public int CompareTo(AsyncOperationBase other)
|
||||||
|
{
|
||||||
|
return other.Priority.CompareTo(this.Priority);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region 异步编程相关
|
#region 异步编程相关
|
||||||
bool IEnumerator.MoveNext()
|
bool IEnumerator.MoveNext()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -45,29 +45,50 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_frameTime = _watch.ElapsedMilliseconds;
|
_frameTime = _watch.ElapsedMilliseconds;
|
||||||
|
|
||||||
// 添加新的异步操作
|
// 添加新增的异步操作
|
||||||
if (_newList.Count > 0)
|
if (_newList.Count > 0)
|
||||||
{
|
{
|
||||||
_operations.AddRange(_newList);
|
bool sorting = false;
|
||||||
_newList.Clear();
|
foreach (var operation in _newList)
|
||||||
|
{
|
||||||
|
if (operation.Priority > 0)
|
||||||
|
{
|
||||||
|
sorting = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新所有的异步操作
|
_operations.AddRange(_newList);
|
||||||
for (int i = _operations.Count - 1; i >= 0; i--)
|
_newList.Clear();
|
||||||
|
|
||||||
|
// 重新排序优先级
|
||||||
|
if (sorting)
|
||||||
|
_operations.Sort();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新进行中的异步操作
|
||||||
|
for (int i = 0; i < _operations.Count; i++)
|
||||||
{
|
{
|
||||||
if (IsBusy)
|
if (IsBusy)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
var operation = _operations[i];
|
var operation = _operations[i];
|
||||||
|
if (operation.IsFinish)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (operation.IsDone == false)
|
if (operation.IsDone == false)
|
||||||
operation.InternalOnUpdate();
|
operation.InternalOnUpdate();
|
||||||
|
|
||||||
if (operation.IsDone)
|
if (operation.IsDone)
|
||||||
{
|
|
||||||
// 注意:如果业务端发生异常,保证异步操作提前移除。
|
|
||||||
_operations.RemoveAt(i);
|
|
||||||
operation.SetFinish();
|
operation.SetFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 移除已经完成的异步操作
|
||||||
|
for (int i = _operations.Count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
var operation = _operations[i];
|
||||||
|
if (operation.IsFinish)
|
||||||
|
_operations.RemoveAt(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,5 +137,14 @@ namespace YooAsset
|
|||||||
operation.SetPackageName(packageName);
|
operation.SetPackageName(packageName);
|
||||||
operation.SetStart();
|
operation.SetStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开始处理异步操作类
|
||||||
|
/// </summary>
|
||||||
|
public static void StartOperation(AsyncOperationBase operation)
|
||||||
|
{
|
||||||
|
_newList.Add(operation);
|
||||||
|
operation.SetStart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,15 +45,7 @@ namespace YooAsset
|
|||||||
if (IsValidWithWarning == false)
|
if (IsValidWithWarning == false)
|
||||||
return EOperationStatus.None;
|
return EOperationStatus.None;
|
||||||
|
|
||||||
var status = Provider.Status;
|
return 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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +58,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (IsValidWithWarning == false)
|
if (IsValidWithWarning == false)
|
||||||
return string.Empty;
|
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>
|
||||||
/// 场景对象
|
/// 场景对象
|
||||||
/// </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);
|
OperationSystem.StartOperation(packageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (_createRequest != null)
|
if (_createRequest != null)
|
||||||
{
|
{
|
||||||
if (_isWaitForAsyncComplete)
|
if (_isWaitForAsyncComplete || IsForceDestroyComplete)
|
||||||
{
|
{
|
||||||
// 强制挂起主线程(注意:该操作会很耗时)
|
// 强制挂起主线程(注意:该操作会很耗时)
|
||||||
YooLogger.Warning("Suspend the main thread to load unity bundle.");
|
YooLogger.Warning("Suspend the main thread to load unity bundle.");
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ namespace YooAsset
|
|||||||
public bool IsDestroyed { private set; get; } = false;
|
public bool IsDestroyed { private set; get; } = false;
|
||||||
|
|
||||||
private readonly List<ProviderBase> _providers = new List<ProviderBase>(100);
|
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 AssetBundle CacheBundle { set; get; }
|
||||||
internal string FileLoadPath { set; get; }
|
internal string FileLoadPath { set; get; }
|
||||||
internal float DownloadProgress { set; get; }
|
internal float DownloadProgress { set; get; }
|
||||||
@@ -59,15 +61,6 @@ namespace YooAsset
|
|||||||
Status = EStatus.None;
|
Status = EStatus.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 添加附属的资源提供者
|
|
||||||
/// </summary>
|
|
||||||
public void AddProvider(ProviderBase provider)
|
|
||||||
{
|
|
||||||
if (_providers.Contains(provider) == false)
|
|
||||||
_providers.Add(provider);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 引用(引用计数递加)
|
/// 引用(引用计数递加)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -100,39 +93,45 @@ namespace YooAsset
|
|||||||
if (IsDone() == false)
|
if (IsDone() == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (RefCount > 0)
|
return RefCount <= 0;
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 在满足条件的前提下,销毁所有资源提供者
|
/// 添加附属的资源提供者
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void TryDestroyAllProviders()
|
public void AddProvider(ProviderBase provider)
|
||||||
{
|
{
|
||||||
if (IsDone() == false)
|
if (_providers.Contains(provider) == false)
|
||||||
return;
|
_providers.Add(provider);
|
||||||
|
|
||||||
// 条件1:必须等待所有Provider可以销毁
|
|
||||||
foreach (var provider in _providers)
|
|
||||||
{
|
|
||||||
if (provider.CanDestroy() == false)
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 条件2:除了自己没有其它引用
|
/// <summary>
|
||||||
if (RefCount > _providers.Count)
|
/// 尝试销毁资源提供者
|
||||||
return;
|
/// </summary>
|
||||||
|
public void TryDestroyProviders()
|
||||||
// 销毁所有Providers
|
|
||||||
{
|
{
|
||||||
|
// 获取移除列表
|
||||||
|
_removeList.Clear();
|
||||||
foreach (var provider in _providers)
|
foreach (var provider in _providers)
|
||||||
{
|
{
|
||||||
|
if (provider.CanDestroy())
|
||||||
|
{
|
||||||
|
_removeList.Add(provider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 销毁资源提供者
|
||||||
|
foreach (var provider in _removeList)
|
||||||
|
{
|
||||||
|
_providers.Remove(provider);
|
||||||
provider.Destroy();
|
provider.Destroy();
|
||||||
}
|
}
|
||||||
Impl.RemoveBundleProviders(_providers);
|
|
||||||
_providers.Clear();
|
// 移除资源提供者
|
||||||
|
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>
|
||||||
/// 主线程等待异步操作完毕
|
/// 主线程等待异步操作完毕
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -8,68 +8,82 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class UnloadSceneOperation : AsyncOperationBase
|
public sealed class UnloadSceneOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
private enum EFlag
|
|
||||||
{
|
|
||||||
Normal,
|
|
||||||
Error,
|
|
||||||
}
|
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
UnLoad,
|
CheckError,
|
||||||
|
PrepareDone,
|
||||||
|
UnLoadScene,
|
||||||
Checking,
|
Checking,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly EFlag _flag;
|
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
private Scene _scene;
|
private readonly string _error;
|
||||||
|
private readonly ProviderBase _provider;
|
||||||
private AsyncOperation _asyncOp;
|
private AsyncOperation _asyncOp;
|
||||||
|
|
||||||
internal UnloadSceneOperation(string error)
|
internal UnloadSceneOperation(string error)
|
||||||
{
|
{
|
||||||
_flag = EFlag.Error;
|
_error = error;
|
||||||
Error = error;
|
|
||||||
}
|
}
|
||||||
internal UnloadSceneOperation(Scene scene)
|
internal UnloadSceneOperation(ProviderBase provider)
|
||||||
{
|
{
|
||||||
_flag = EFlag.Normal;
|
_error = null;
|
||||||
_scene = scene;
|
_provider = provider;
|
||||||
}
|
}
|
||||||
internal override void InternalOnStart()
|
internal override void InternalOnStart()
|
||||||
{
|
{
|
||||||
if (_flag == EFlag.Normal)
|
_steps = ESteps.CheckError;
|
||||||
{
|
|
||||||
_steps = ESteps.UnLoad;
|
|
||||||
}
|
|
||||||
else if (_flag == EFlag.Error)
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException(_flag.ToString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
internal override void InternalOnUpdate()
|
internal override void InternalOnUpdate()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
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;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
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)
|
if (_steps == ESteps.Checking)
|
||||||
|
|||||||
@@ -8,23 +8,25 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
private AssetBundleRequest _cacheRequest;
|
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();
|
DebugBeginRecording();
|
||||||
|
}
|
||||||
|
internal override void InternalOnUpdate()
|
||||||
|
{
|
||||||
if (IsDone)
|
if (IsDone)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Status == EStatus.None)
|
if (_steps == ESteps.None)
|
||||||
{
|
{
|
||||||
Status = EStatus.CheckBundle;
|
_steps = ESteps.CheckBundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. 检测资源包
|
// 1. 检测资源包
|
||||||
if (Status == EStatus.CheckBundle)
|
if (_steps == ESteps.CheckBundle)
|
||||||
{
|
{
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete)
|
||||||
{
|
{
|
||||||
@@ -39,17 +41,15 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (DependBundles.IsSucceed() == false)
|
if (DependBundles.IsSucceed() == false)
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
string error = DependBundles.GetLastError();
|
||||||
LastError = DependBundles.GetLastError();
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
string error = OwnerBundle.LastError;
|
||||||
LastError = OwnerBundle.LastError;
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,13 +59,13 @@ namespace YooAsset
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EStatus.Loading;
|
_steps = ESteps.Loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 加载资源对象
|
// 2. 加载资源对象
|
||||||
if (Status == EStatus.Loading)
|
if (_steps == ESteps.Loading)
|
||||||
{
|
{
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete || IsForceDestroyComplete)
|
||||||
{
|
{
|
||||||
if (MainAssetInfo.AssetType == null)
|
if (MainAssetInfo.AssetType == null)
|
||||||
AllAssetObjects = OwnerBundle.CacheBundle.LoadAllAssets();
|
AllAssetObjects = OwnerBundle.CacheBundle.LoadAllAssets();
|
||||||
@@ -79,15 +79,15 @@ namespace YooAsset
|
|||||||
else
|
else
|
||||||
_cacheRequest = OwnerBundle.CacheBundle.LoadAllAssetsAsync(MainAssetInfo.AssetType);
|
_cacheRequest = OwnerBundle.CacheBundle.LoadAllAssetsAsync(MainAssetInfo.AssetType);
|
||||||
}
|
}
|
||||||
Status = EStatus.Checking;
|
_steps = ESteps.Checking;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 检测加载结果
|
// 3. 检测加载结果
|
||||||
if (Status == EStatus.Checking)
|
if (_steps == ESteps.Checking)
|
||||||
{
|
{
|
||||||
if (_cacheRequest != null)
|
if (_cacheRequest != null)
|
||||||
{
|
{
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete || IsForceDestroyComplete)
|
||||||
{
|
{
|
||||||
// 强制挂起主线程(注意:该操作会很耗时)
|
// 强制挂起主线程(注意:该操作会很耗时)
|
||||||
YooLogger.Warning("Suspend the main thread to load unity asset.");
|
YooLogger.Warning("Suspend the main thread to load unity asset.");
|
||||||
@@ -102,16 +102,20 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = AllAssetObjects == null ? EStatus.Failed : EStatus.Succeed;
|
if (AllAssetObjects == null)
|
||||||
if (Status == EStatus.Failed)
|
|
||||||
{
|
{
|
||||||
|
string error;
|
||||||
if (MainAssetInfo.AssetType == null)
|
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
|
else
|
||||||
LastError = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
error = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||||
YooLogger.Error(LastError);
|
YooLogger.Error(error);
|
||||||
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||||
}
|
}
|
||||||
InvokeCompletion();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,23 +8,25 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
private AssetBundleRequest _cacheRequest;
|
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();
|
DebugBeginRecording();
|
||||||
|
}
|
||||||
|
internal override void InternalOnUpdate()
|
||||||
|
{
|
||||||
if (IsDone)
|
if (IsDone)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Status == EStatus.None)
|
if (_steps == ESteps.None)
|
||||||
{
|
{
|
||||||
Status = EStatus.CheckBundle;
|
_steps = ESteps.CheckBundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. 检测资源包
|
// 1. 检测资源包
|
||||||
if (Status == EStatus.CheckBundle)
|
if (_steps == ESteps.CheckBundle)
|
||||||
{
|
{
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete)
|
||||||
{
|
{
|
||||||
@@ -39,17 +41,15 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (DependBundles.IsSucceed() == false)
|
if (DependBundles.IsSucceed() == false)
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
string error = DependBundles.GetLastError();
|
||||||
LastError = DependBundles.GetLastError();
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
string error = OwnerBundle.LastError;
|
||||||
LastError = OwnerBundle.LastError;
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,13 +59,13 @@ namespace YooAsset
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EStatus.Loading;
|
_steps = ESteps.Loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 加载资源对象
|
// 2. 加载资源对象
|
||||||
if (Status == EStatus.Loading)
|
if (_steps == ESteps.Loading)
|
||||||
{
|
{
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete || IsForceDestroyComplete)
|
||||||
{
|
{
|
||||||
if (MainAssetInfo.AssetType == null)
|
if (MainAssetInfo.AssetType == null)
|
||||||
AssetObject = OwnerBundle.CacheBundle.LoadAsset(MainAssetInfo.AssetPath);
|
AssetObject = OwnerBundle.CacheBundle.LoadAsset(MainAssetInfo.AssetPath);
|
||||||
@@ -79,15 +79,15 @@ namespace YooAsset
|
|||||||
else
|
else
|
||||||
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetAsync(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
|
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetAsync(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
|
||||||
}
|
}
|
||||||
Status = EStatus.Checking;
|
_steps = ESteps.Checking;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 检测加载结果
|
// 3. 检测加载结果
|
||||||
if (Status == EStatus.Checking)
|
if (_steps == ESteps.Checking)
|
||||||
{
|
{
|
||||||
if (_cacheRequest != null)
|
if (_cacheRequest != null)
|
||||||
{
|
{
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete || IsForceDestroyComplete)
|
||||||
{
|
{
|
||||||
// 强制挂起主线程(注意:该操作会很耗时)
|
// 强制挂起主线程(注意:该操作会很耗时)
|
||||||
YooLogger.Warning("Suspend the main thread to load unity asset.");
|
YooLogger.Warning("Suspend the main thread to load unity asset.");
|
||||||
@@ -102,16 +102,20 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = AssetObject == null ? EStatus.Failed : EStatus.Succeed;
|
if (AssetObject == null)
|
||||||
if (Status == EStatus.Failed)
|
|
||||||
{
|
{
|
||||||
|
string error;
|
||||||
if (MainAssetInfo.AssetType == null)
|
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
|
else
|
||||||
LastError = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
error = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||||
YooLogger.Error(LastError);
|
YooLogger.Error(error);
|
||||||
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||||
}
|
}
|
||||||
InvokeCompletion();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,23 +3,25 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
internal class BundledRawFileProvider : ProviderBase
|
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();
|
DebugBeginRecording();
|
||||||
|
}
|
||||||
|
internal override void InternalOnUpdate()
|
||||||
|
{
|
||||||
if (IsDone)
|
if (IsDone)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Status == EStatus.None)
|
if (_steps == ESteps.None)
|
||||||
{
|
{
|
||||||
Status = EStatus.CheckBundle;
|
_steps = ESteps.CheckBundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. 检测资源包
|
// 1. 检测资源包
|
||||||
if (Status == EStatus.CheckBundle)
|
if (_steps == ESteps.CheckBundle)
|
||||||
{
|
{
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete)
|
||||||
{
|
{
|
||||||
@@ -31,21 +33,19 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
string error = OwnerBundle.LastError;
|
||||||
LastError = OwnerBundle.LastError;
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EStatus.Checking;
|
_steps = ESteps.Checking;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 检测加载结果
|
// 2. 检测加载结果
|
||||||
if (Status == EStatus.Checking)
|
if (_steps == ESteps.Checking)
|
||||||
{
|
{
|
||||||
RawFilePath = OwnerBundle.FileLoadPath;
|
RawFilePath = OwnerBundle.FileLoadPath;
|
||||||
Status = EStatus.Succeed;
|
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||||
InvokeCompletion();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,32 +9,31 @@ namespace YooAsset
|
|||||||
internal sealed class BundledSceneProvider : ProviderBase
|
internal sealed class BundledSceneProvider : ProviderBase
|
||||||
{
|
{
|
||||||
public readonly LoadSceneMode SceneMode;
|
public readonly LoadSceneMode SceneMode;
|
||||||
private readonly string _sceneName;
|
|
||||||
private readonly bool _suspendLoad;
|
private readonly bool _suspendLoad;
|
||||||
private readonly int _priority;
|
|
||||||
private AsyncOperation _asyncOperation;
|
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;
|
SceneMode = sceneMode;
|
||||||
_sceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath);
|
SceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath);
|
||||||
_suspendLoad = suspendLoad;
|
_suspendLoad = suspendLoad;
|
||||||
_priority = priority;
|
|
||||||
}
|
}
|
||||||
public override void Update()
|
internal override void InternalOnStart()
|
||||||
{
|
{
|
||||||
DebugBeginRecording();
|
DebugBeginRecording();
|
||||||
|
}
|
||||||
|
internal override void InternalOnUpdate()
|
||||||
|
{
|
||||||
if (IsDone)
|
if (IsDone)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Status == EStatus.None)
|
if (_steps == ESteps.None)
|
||||||
{
|
{
|
||||||
Status = EStatus.CheckBundle;
|
_steps = ESteps.CheckBundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. 检测资源包
|
// 1. 检测资源包
|
||||||
if (Status == EStatus.CheckBundle)
|
if (_steps == ESteps.CheckBundle)
|
||||||
{
|
{
|
||||||
if (DependBundles.IsDone() == false)
|
if (DependBundles.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
@@ -43,57 +42,57 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (DependBundles.IsSucceed() == false)
|
if (DependBundles.IsSucceed() == false)
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
string error = DependBundles.GetLastError();
|
||||||
LastError = DependBundles.GetLastError();
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
string error = OwnerBundle.LastError;
|
||||||
LastError = OwnerBundle.LastError;
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EStatus.Loading;
|
_steps = ESteps.Loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 加载场景
|
// 2. 加载场景
|
||||||
if (Status == EStatus.Loading)
|
if (_steps == ESteps.Loading)
|
||||||
{
|
{
|
||||||
// 注意:如果场景不存在则返回NULL
|
// 注意:如果场景不存在则返回NULL
|
||||||
_asyncOperation = SceneManager.LoadSceneAsync(MainAssetInfo.AssetPath, SceneMode);
|
_asyncOperation = SceneManager.LoadSceneAsync(MainAssetInfo.AssetPath, SceneMode);
|
||||||
if (_asyncOperation != null)
|
if (_asyncOperation != null)
|
||||||
{
|
{
|
||||||
_asyncOperation.allowSceneActivation = !_suspendLoad;
|
_asyncOperation.allowSceneActivation = !_suspendLoad;
|
||||||
_asyncOperation.priority = _priority;
|
_asyncOperation.priority = 100;
|
||||||
SceneObject = SceneManager.GetSceneAt(SceneManager.sceneCount - 1);
|
SceneObject = SceneManager.GetSceneAt(SceneManager.sceneCount - 1);
|
||||||
Status = EStatus.Checking;
|
_steps = ESteps.Checking;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
string error = $"Failed to load scene : {MainAssetInfo.AssetPath}";
|
||||||
LastError = $"Failed to load scene : {_sceneName}";
|
YooLogger.Error(error);
|
||||||
YooLogger.Error(LastError);
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 检测加载结果
|
// 3. 检测加载结果
|
||||||
if (Status == EStatus.Checking)
|
if (_steps == ESteps.Checking)
|
||||||
{
|
{
|
||||||
Progress = _asyncOperation.progress;
|
Progress = _asyncOperation.progress;
|
||||||
if (_asyncOperation.isDone)
|
if (_asyncOperation.isDone)
|
||||||
{
|
{
|
||||||
Status = SceneObject.IsValid() ? EStatus.Succeed : EStatus.Failed;
|
if (SceneObject.IsValid())
|
||||||
if (Status == EStatus.Failed)
|
|
||||||
{
|
{
|
||||||
LastError = $"The load scene is invalid : {MainAssetInfo.AssetPath}";
|
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||||
YooLogger.Error(LastError);
|
}
|
||||||
|
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;
|
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();
|
DebugBeginRecording();
|
||||||
|
}
|
||||||
|
internal override void InternalOnUpdate()
|
||||||
|
{
|
||||||
if (IsDone)
|
if (IsDone)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Status == EStatus.None)
|
if (_steps == ESteps.None)
|
||||||
{
|
{
|
||||||
Status = EStatus.CheckBundle;
|
_steps = ESteps.CheckBundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. 检测资源包
|
// 1. 检测资源包
|
||||||
if (Status == EStatus.CheckBundle)
|
if (_steps == ESteps.CheckBundle)
|
||||||
{
|
{
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete)
|
||||||
{
|
{
|
||||||
@@ -39,17 +41,15 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (DependBundles.IsSucceed() == false)
|
if (DependBundles.IsSucceed() == false)
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
string error = DependBundles.GetLastError();
|
||||||
LastError = DependBundles.GetLastError();
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
string error = OwnerBundle.LastError;
|
||||||
LastError = OwnerBundle.LastError;
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,13 +59,13 @@ namespace YooAsset
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EStatus.Loading;
|
_steps = ESteps.Loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 加载资源对象
|
// 2. 加载资源对象
|
||||||
if (Status == EStatus.Loading)
|
if (_steps == ESteps.Loading)
|
||||||
{
|
{
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete || IsForceDestroyComplete)
|
||||||
{
|
{
|
||||||
if (MainAssetInfo.AssetType == null)
|
if (MainAssetInfo.AssetType == null)
|
||||||
AllAssetObjects = OwnerBundle.CacheBundle.LoadAssetWithSubAssets(MainAssetInfo.AssetPath);
|
AllAssetObjects = OwnerBundle.CacheBundle.LoadAssetWithSubAssets(MainAssetInfo.AssetPath);
|
||||||
@@ -79,15 +79,15 @@ namespace YooAsset
|
|||||||
else
|
else
|
||||||
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetWithSubAssetsAsync(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
|
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetWithSubAssetsAsync(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
|
||||||
}
|
}
|
||||||
Status = EStatus.Checking;
|
_steps = ESteps.Checking;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 检测加载结果
|
// 3. 检测加载结果
|
||||||
if (Status == EStatus.Checking)
|
if (_steps == ESteps.Checking)
|
||||||
{
|
{
|
||||||
if (_cacheRequest != null)
|
if (_cacheRequest != null)
|
||||||
{
|
{
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete || IsForceDestroyComplete)
|
||||||
{
|
{
|
||||||
// 强制挂起主线程(注意:该操作会很耗时)
|
// 强制挂起主线程(注意:该操作会很耗时)
|
||||||
YooLogger.Warning("Suspend the main thread to load unity asset.");
|
YooLogger.Warning("Suspend the main thread to load unity asset.");
|
||||||
@@ -102,16 +102,20 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = AllAssetObjects == null ? EStatus.Failed : EStatus.Succeed;
|
if (AllAssetObjects == null)
|
||||||
if (Status == EStatus.Failed)
|
|
||||||
{
|
{
|
||||||
|
string error;
|
||||||
if (MainAssetInfo.AssetType == null)
|
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
|
else
|
||||||
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
error = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||||
YooLogger.Error(LastError);
|
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 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)
|
public void SetCompleted(string error)
|
||||||
{
|
{
|
||||||
if (Status == EStatus.None)
|
if (_steps == ESteps.None)
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
LastError = error;
|
|
||||||
InvokeCompletion();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,29 +6,32 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
internal sealed class DatabaseAllAssetsProvider : ProviderBase
|
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 UNITY_EDITOR
|
||||||
if (IsDone)
|
if (IsDone)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Status == EStatus.None)
|
if (_steps == ESteps.None)
|
||||||
{
|
{
|
||||||
// 检测资源文件是否存在
|
// 检测资源文件是否存在
|
||||||
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
|
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
|
||||||
if (string.IsNullOrEmpty(guid))
|
if (string.IsNullOrEmpty(guid))
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
string error = $"Not found asset : {MainAssetInfo.AssetPath}";
|
||||||
LastError = $"Not found asset : {MainAssetInfo.AssetPath}";
|
YooLogger.Error(error);
|
||||||
YooLogger.Error(LastError);
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EStatus.CheckBundle;
|
_steps = ESteps.CheckBundle;
|
||||||
|
|
||||||
// 注意:模拟异步加载效果提前返回
|
// 注意:模拟异步加载效果提前返回
|
||||||
if (IsWaitForAsyncComplete == false)
|
if (IsWaitForAsyncComplete == false)
|
||||||
@@ -36,7 +39,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 1. 检测资源包
|
// 1. 检测资源包
|
||||||
if (Status == EStatus.CheckBundle)
|
if (_steps == ESteps.CheckBundle)
|
||||||
{
|
{
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete)
|
||||||
{
|
{
|
||||||
@@ -48,17 +51,16 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
string error = OwnerBundle.LastError;
|
||||||
LastError = OwnerBundle.LastError;
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EStatus.Loading;
|
_steps = ESteps.Loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 加载资源对象
|
// 2. 加载资源对象
|
||||||
if (Status == EStatus.Loading)
|
if (_steps == ESteps.Loading)
|
||||||
{
|
{
|
||||||
if (MainAssetInfo.AssetType == null)
|
if (MainAssetInfo.AssetType == null)
|
||||||
{
|
{
|
||||||
@@ -82,22 +84,26 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
AllAssetObjects = result.ToArray();
|
AllAssetObjects = result.ToArray();
|
||||||
}
|
}
|
||||||
Status = EStatus.Checking;
|
_steps = ESteps.Checking;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 检测加载结果
|
// 3. 检测加载结果
|
||||||
if (Status == EStatus.Checking)
|
if (_steps == ESteps.Checking)
|
||||||
{
|
{
|
||||||
Status = AllAssetObjects == null ? EStatus.Failed : EStatus.Succeed;
|
if (AllAssetObjects == null)
|
||||||
if (Status == EStatus.Failed)
|
|
||||||
{
|
{
|
||||||
|
string error;
|
||||||
if (MainAssetInfo.AssetType == null)
|
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
|
else
|
||||||
LastError = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
|
error = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
|
||||||
YooLogger.Error(LastError);
|
YooLogger.Error(error);
|
||||||
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||||
}
|
}
|
||||||
InvokeCompletion();
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,29 +6,32 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
internal sealed class DatabaseAssetProvider : ProviderBase
|
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 UNITY_EDITOR
|
||||||
if (IsDone)
|
if (IsDone)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Status == EStatus.None)
|
if (_steps == ESteps.None)
|
||||||
{
|
{
|
||||||
// 检测资源文件是否存在
|
// 检测资源文件是否存在
|
||||||
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
|
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
|
||||||
if (string.IsNullOrEmpty(guid))
|
if (string.IsNullOrEmpty(guid))
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
string error = $"Not found asset : {MainAssetInfo.AssetPath}";
|
||||||
LastError = $"Not found asset : {MainAssetInfo.AssetPath}";
|
YooLogger.Error(error);
|
||||||
YooLogger.Error(LastError);
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EStatus.CheckBundle;
|
_steps = ESteps.CheckBundle;
|
||||||
|
|
||||||
// 注意:模拟异步加载效果提前返回
|
// 注意:模拟异步加载效果提前返回
|
||||||
if (IsWaitForAsyncComplete == false)
|
if (IsWaitForAsyncComplete == false)
|
||||||
@@ -36,7 +39,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 1. 检测资源包
|
// 1. 检测资源包
|
||||||
if (Status == EStatus.CheckBundle)
|
if (_steps == ESteps.CheckBundle)
|
||||||
{
|
{
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete)
|
||||||
{
|
{
|
||||||
@@ -48,38 +51,41 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
string error = OwnerBundle.LastError;
|
||||||
LastError = OwnerBundle.LastError;
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EStatus.Loading;
|
_steps = ESteps.Loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 加载资源对象
|
// 2. 加载资源对象
|
||||||
if (Status == EStatus.Loading)
|
if (_steps == ESteps.Loading)
|
||||||
{
|
{
|
||||||
if (MainAssetInfo.AssetType == null)
|
if (MainAssetInfo.AssetType == null)
|
||||||
AssetObject = UnityEditor.AssetDatabase.LoadMainAssetAtPath(MainAssetInfo.AssetPath);
|
AssetObject = UnityEditor.AssetDatabase.LoadMainAssetAtPath(MainAssetInfo.AssetPath);
|
||||||
else
|
else
|
||||||
AssetObject = UnityEditor.AssetDatabase.LoadAssetAtPath(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
|
AssetObject = UnityEditor.AssetDatabase.LoadAssetAtPath(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
|
||||||
Status = EStatus.Checking;
|
_steps = ESteps.Checking;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 检测加载结果
|
// 3. 检测加载结果
|
||||||
if (Status == EStatus.Checking)
|
if (_steps == ESteps.Checking)
|
||||||
{
|
{
|
||||||
Status = AssetObject == null ? EStatus.Failed : EStatus.Succeed;
|
if (AssetObject == null)
|
||||||
if (Status == EStatus.Failed)
|
|
||||||
{
|
{
|
||||||
|
string error;
|
||||||
if (MainAssetInfo.AssetType == null)
|
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
|
else
|
||||||
LastError = $"Failed to load asset object : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
|
error = $"Failed to load asset object : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
|
||||||
YooLogger.Error(LastError);
|
YooLogger.Error(error);
|
||||||
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||||
}
|
}
|
||||||
InvokeCompletion();
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,29 +3,32 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
internal class DatabaseRawFileProvider : ProviderBase
|
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 UNITY_EDITOR
|
||||||
if (IsDone)
|
if (IsDone)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Status == EStatus.None)
|
if (_steps == ESteps.None)
|
||||||
{
|
{
|
||||||
// 检测资源文件是否存在
|
// 检测资源文件是否存在
|
||||||
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
|
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
|
||||||
if (string.IsNullOrEmpty(guid))
|
if (string.IsNullOrEmpty(guid))
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
string error = $"Not found asset : {MainAssetInfo.AssetPath}";
|
||||||
LastError = $"Not found asset : {MainAssetInfo.AssetPath}";
|
YooLogger.Error(error);
|
||||||
YooLogger.Error(LastError);
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EStatus.CheckBundle;
|
_steps = ESteps.CheckBundle;
|
||||||
|
|
||||||
// 注意:模拟异步加载效果提前返回
|
// 注意:模拟异步加载效果提前返回
|
||||||
if (IsWaitForAsyncComplete == false)
|
if (IsWaitForAsyncComplete == false)
|
||||||
@@ -33,7 +36,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 1. 检测资源包
|
// 1. 检测资源包
|
||||||
if (Status == EStatus.CheckBundle)
|
if (_steps == ESteps.CheckBundle)
|
||||||
{
|
{
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete)
|
||||||
{
|
{
|
||||||
@@ -45,21 +48,19 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
string error = OwnerBundle.LastError;
|
||||||
LastError = OwnerBundle.LastError;
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EStatus.Checking;
|
_steps = ESteps.Checking;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 检测加载结果
|
// 2. 检测加载结果
|
||||||
if (Status == EStatus.Checking)
|
if (_steps == ESteps.Checking)
|
||||||
{
|
{
|
||||||
RawFilePath = MainAssetInfo.AssetPath;
|
RawFilePath = MainAssetInfo.AssetPath;
|
||||||
Status = EStatus.Succeed;
|
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||||
InvokeCompletion();
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
using UnityEngine;
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
@@ -7,28 +10,31 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
public readonly LoadSceneMode SceneMode;
|
public readonly LoadSceneMode SceneMode;
|
||||||
private readonly bool _suspendLoad;
|
private readonly bool _suspendLoad;
|
||||||
private readonly int _priority;
|
|
||||||
private AsyncOperation _asyncOperation;
|
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;
|
SceneMode = sceneMode;
|
||||||
|
SceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath);
|
||||||
_suspendLoad = suspendLoad;
|
_suspendLoad = suspendLoad;
|
||||||
_priority = priority;
|
|
||||||
}
|
}
|
||||||
public override void Update()
|
internal override void InternalOnStart()
|
||||||
|
{
|
||||||
|
DebugBeginRecording();
|
||||||
|
}
|
||||||
|
internal override void InternalOnUpdate()
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
if (IsDone)
|
if (IsDone)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Status == EStatus.None)
|
if (_steps == ESteps.None)
|
||||||
{
|
{
|
||||||
Status = EStatus.CheckBundle;
|
_steps = ESteps.CheckBundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. 检测资源包
|
// 1. 检测资源包
|
||||||
if (Status == EStatus.CheckBundle)
|
if (_steps == ESteps.CheckBundle)
|
||||||
{
|
{
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete)
|
||||||
{
|
{
|
||||||
@@ -40,17 +46,16 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
string error = OwnerBundle.LastError;
|
||||||
LastError = OwnerBundle.LastError;
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EStatus.Loading;
|
_steps = ESteps.Loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 加载资源对象
|
// 2. 加载资源对象
|
||||||
if (Status == EStatus.Loading)
|
if (_steps == ESteps.Loading)
|
||||||
{
|
{
|
||||||
LoadSceneParameters loadSceneParameters = new LoadSceneParameters();
|
LoadSceneParameters loadSceneParameters = new LoadSceneParameters();
|
||||||
loadSceneParameters.loadSceneMode = SceneMode;
|
loadSceneParameters.loadSceneMode = SceneMode;
|
||||||
@@ -58,32 +63,34 @@ namespace YooAsset
|
|||||||
if (_asyncOperation != null)
|
if (_asyncOperation != null)
|
||||||
{
|
{
|
||||||
_asyncOperation.allowSceneActivation = !_suspendLoad;
|
_asyncOperation.allowSceneActivation = !_suspendLoad;
|
||||||
_asyncOperation.priority = _priority;
|
_asyncOperation.priority = 100;
|
||||||
SceneObject = SceneManager.GetSceneAt(SceneManager.sceneCount - 1);
|
SceneObject = SceneManager.GetSceneAt(SceneManager.sceneCount - 1);
|
||||||
Status = EStatus.Checking;
|
_steps = ESteps.Checking;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
string error = $"Failed to load scene : {MainAssetInfo.AssetPath}";
|
||||||
LastError = $"Failed to load scene : {MainAssetInfo.AssetPath}";
|
YooLogger.Error(error);
|
||||||
YooLogger.Error(LastError);
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 检测加载结果
|
// 3. 检测加载结果
|
||||||
if (Status == EStatus.Checking)
|
if (_steps == ESteps.Checking)
|
||||||
{
|
{
|
||||||
Progress = _asyncOperation.progress;
|
Progress = _asyncOperation.progress;
|
||||||
if (_asyncOperation.isDone)
|
if (_asyncOperation.isDone)
|
||||||
{
|
{
|
||||||
Status = SceneObject.IsValid() ? EStatus.Succeed : EStatus.Failed;
|
if (SceneObject.IsValid())
|
||||||
if (Status == EStatus.Failed)
|
|
||||||
{
|
{
|
||||||
LastError = $"The loaded scene is invalid : {MainAssetInfo.AssetPath}";
|
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||||
YooLogger.Error(LastError);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string error = $"The loaded scene is invalid : {MainAssetInfo.AssetPath}";
|
||||||
|
YooLogger.Error(error);
|
||||||
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
}
|
}
|
||||||
InvokeCompletion();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,29 +6,32 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
internal sealed class DatabaseSubAssetsProvider : ProviderBase
|
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 UNITY_EDITOR
|
||||||
if (IsDone)
|
if (IsDone)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Status == EStatus.None)
|
if (_steps == ESteps.None)
|
||||||
{
|
{
|
||||||
// 检测资源文件是否存在
|
// 检测资源文件是否存在
|
||||||
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
|
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
|
||||||
if (string.IsNullOrEmpty(guid))
|
if (string.IsNullOrEmpty(guid))
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
string error = $"Not found asset : {MainAssetInfo.AssetPath}";
|
||||||
LastError = $"Not found asset : {MainAssetInfo.AssetPath}";
|
YooLogger.Error(error);
|
||||||
YooLogger.Error(LastError);
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EStatus.CheckBundle;
|
_steps = ESteps.CheckBundle;
|
||||||
|
|
||||||
// 注意:模拟异步加载效果提前返回
|
// 注意:模拟异步加载效果提前返回
|
||||||
if (IsWaitForAsyncComplete == false)
|
if (IsWaitForAsyncComplete == false)
|
||||||
@@ -36,7 +39,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 1. 检测资源包
|
// 1. 检测资源包
|
||||||
if (Status == EStatus.CheckBundle)
|
if (_steps == ESteps.CheckBundle)
|
||||||
{
|
{
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete)
|
||||||
{
|
{
|
||||||
@@ -48,17 +51,16 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
string error = OwnerBundle.LastError;
|
||||||
LastError = OwnerBundle.LastError;
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EStatus.Loading;
|
_steps = ESteps.Loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 加载资源对象
|
// 2. 加载资源对象
|
||||||
if (Status == EStatus.Loading)
|
if (_steps == ESteps.Loading)
|
||||||
{
|
{
|
||||||
if (MainAssetInfo.AssetType == null)
|
if (MainAssetInfo.AssetType == null)
|
||||||
{
|
{
|
||||||
@@ -75,22 +77,26 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
AllAssetObjects = result.ToArray();
|
AllAssetObjects = result.ToArray();
|
||||||
}
|
}
|
||||||
Status = EStatus.Checking;
|
_steps = ESteps.Checking;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 检测加载结果
|
// 3. 检测加载结果
|
||||||
if (Status == EStatus.Checking)
|
if (_steps == ESteps.Checking)
|
||||||
{
|
{
|
||||||
Status = AllAssetObjects == null ? EStatus.Failed : EStatus.Succeed;
|
if (AllAssetObjects == null)
|
||||||
if (Status == EStatus.Failed)
|
|
||||||
{
|
{
|
||||||
|
string error;
|
||||||
if (MainAssetInfo.AssetType == null)
|
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
|
else
|
||||||
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
|
error = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
|
||||||
YooLogger.Error(LastError);
|
YooLogger.Error(error);
|
||||||
|
InvokeCompletion(error, EOperationStatus.Failed);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||||
}
|
}
|
||||||
InvokeCompletion();
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,19 +2,19 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal abstract class ProviderBase
|
internal abstract class ProviderBase : AsyncOperationBase
|
||||||
{
|
{
|
||||||
public enum EStatus
|
protected enum ESteps
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
CheckBundle,
|
CheckBundle,
|
||||||
Loading,
|
Loading,
|
||||||
Checking,
|
Checking,
|
||||||
Succeed,
|
Done,
|
||||||
Failed,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -25,7 +25,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 所属资源系统
|
/// 所属资源系统
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ResourceManager Impl { private set; get; }
|
public ResourceManager ResourceMgr { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源信息
|
/// 资源信息
|
||||||
@@ -47,27 +47,16 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public UnityEngine.SceneManagement.Scene SceneObject { protected set; get; }
|
public UnityEngine.SceneManagement.Scene SceneObject { protected set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载的场景名称
|
||||||
|
/// </summary>
|
||||||
|
public string SceneName { protected set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 原生文件路径
|
/// 原生文件路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string RawFilePath { protected set; get; }
|
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>
|
||||||
/// 引用计数
|
/// 引用计数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -78,55 +67,48 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsDestroyed { private set; get; } = false;
|
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 BundleLoaderBase OwnerBundle { private set; get; }
|
||||||
protected DependAssetBundles DependBundles { private set; get; }
|
protected DependAssetBundles DependBundles { private set; get; }
|
||||||
protected bool IsWaitForAsyncComplete { private set; get; } = false;
|
protected bool IsWaitForAsyncComplete { private set; get; } = false;
|
||||||
|
protected bool IsForceDestroyComplete { private set; get; } = false;
|
||||||
private readonly List<HandleBase> _handles = new List<HandleBase>();
|
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;
|
ProviderGUID = providerGUID;
|
||||||
MainAssetInfo = assetInfo;
|
MainAssetInfo = assetInfo;
|
||||||
|
|
||||||
// 创建资源包加载器
|
// 创建资源包加载器
|
||||||
if (impl != null)
|
if (manager != null)
|
||||||
{
|
{
|
||||||
OwnerBundle = impl.CreateOwnerAssetBundleLoader(assetInfo);
|
OwnerBundle = manager.CreateOwnerAssetBundleLoader(assetInfo);
|
||||||
OwnerBundle.Reference();
|
OwnerBundle.Reference();
|
||||||
OwnerBundle.AddProvider(this);
|
OwnerBundle.AddProvider(this);
|
||||||
|
|
||||||
var dependList = impl.CreateDependAssetBundleLoaders(assetInfo);
|
var dependList = manager.CreateDependAssetBundleLoaders(assetInfo);
|
||||||
DependBundles = new DependAssetBundles(dependList);
|
DependBundles = new DependAssetBundles(dependList);
|
||||||
DependBundles.Reference();
|
DependBundles.Reference();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 轮询更新方法
|
/// 销毁资源提供者
|
||||||
/// </summary>
|
|
||||||
public abstract void Update();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 销毁资源对象
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Destroy()
|
public void Destroy()
|
||||||
{
|
{
|
||||||
IsDestroyed = true;
|
IsDestroyed = true;
|
||||||
|
|
||||||
|
// 检测是否为正常销毁
|
||||||
|
if (IsDone == false)
|
||||||
|
{
|
||||||
|
Error = "User abort !";
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
}
|
||||||
|
|
||||||
// 释放资源包加载器
|
// 释放资源包加载器
|
||||||
if (OwnerBundle != null)
|
if (OwnerBundle != null)
|
||||||
{
|
{
|
||||||
@@ -145,14 +127,15 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool CanDestroy()
|
public bool CanDestroy()
|
||||||
{
|
{
|
||||||
if (IsDone == false)
|
// 注意:在进行资源加载过程时不可以销毁
|
||||||
|
if (_steps == ESteps.Loading || _steps == ESteps.Checking)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return RefCount <= 0;
|
return RefCount <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建操作句柄
|
/// 创建资源句柄
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public T CreateHandle<T>() where T : HandleBase
|
public T CreateHandle<T>() where T : HandleBase
|
||||||
{
|
{
|
||||||
@@ -178,12 +161,12 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 释放操作句柄
|
/// 释放资源句柄
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ReleaseHandle(HandleBase handle)
|
public void ReleaseHandle(HandleBase handle)
|
||||||
{
|
{
|
||||||
if (RefCount <= 0)
|
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)
|
if (_handles.Remove(handle) == false)
|
||||||
throw new System.Exception("Should never get here !");
|
throw new System.Exception("Should never get here !");
|
||||||
@@ -192,6 +175,18 @@ namespace YooAsset
|
|||||||
RefCount--;
|
RefCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 释放所有资源句柄
|
||||||
|
/// </summary>
|
||||||
|
public void ReleaseAllHandles()
|
||||||
|
{
|
||||||
|
for (int i = _handles.Count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
var handle = _handles[i];
|
||||||
|
handle.ReleaseInternal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 等待异步执行完毕
|
/// 等待异步执行完毕
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -200,15 +195,27 @@ namespace YooAsset
|
|||||||
IsWaitForAsyncComplete = true;
|
IsWaitForAsyncComplete = true;
|
||||||
|
|
||||||
// 注意:主动轮询更新完成同步加载
|
// 注意:主动轮询更新完成同步加载
|
||||||
Update();
|
InternalOnUpdate();
|
||||||
|
|
||||||
// 验证结果
|
// 验证结果
|
||||||
if (IsDone == false)
|
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>
|
||||||
/// 处理特殊异常
|
/// 处理特殊异常
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -217,37 +224,21 @@ namespace YooAsset
|
|||||||
if (OwnerBundle.IsDestroyed)
|
if (OwnerBundle.IsDestroyed)
|
||||||
throw new System.Exception("Should never get here !");
|
throw new System.Exception("Should never get here !");
|
||||||
|
|
||||||
Status = EStatus.Failed;
|
string error = $"The bundle {OwnerBundle.MainBundleInfo.Bundle.BundleName} has been destroyed by unity bugs !";
|
||||||
LastError = $"The bundle {OwnerBundle.MainBundleInfo.Bundle.BundleName} has been destroyed by unity bugs !";
|
YooLogger.Error(error);
|
||||||
YooLogger.Error(LastError);
|
InvokeCompletion(Error, EOperationStatus.Failed);
|
||||||
InvokeCompletion();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步操作任务
|
/// 结束流程
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Task Task
|
protected void InvokeCompletion(string error, EOperationStatus status)
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_taskCompletionSource == null)
|
|
||||||
{
|
|
||||||
_taskCompletionSource = new TaskCompletionSource<object>();
|
|
||||||
if (IsDone)
|
|
||||||
_taskCompletionSource.SetResult(null);
|
|
||||||
}
|
|
||||||
return _taskCompletionSource.Task;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region 异步编程相关
|
|
||||||
private TaskCompletionSource<object> _taskCompletionSource;
|
|
||||||
protected void InvokeCompletion()
|
|
||||||
{
|
{
|
||||||
DebugEndRecording();
|
DebugEndRecording();
|
||||||
|
|
||||||
// 进度百分百完成
|
_steps = ESteps.Done;
|
||||||
Progress = 1f;
|
Error = error;
|
||||||
|
Status = status;
|
||||||
|
|
||||||
// 注意:创建临时列表是为了防止外部逻辑在回调函数内创建或者释放资源句柄。
|
// 注意:创建临时列表是为了防止外部逻辑在回调函数内创建或者释放资源句柄。
|
||||||
// 注意:回调方法如果发生异常,会阻断列表里的后续回调方法!
|
// 注意:回调方法如果发生异常,会阻断列表里的后续回调方法!
|
||||||
@@ -259,11 +250,7 @@ namespace YooAsset
|
|||||||
hande.InvokeCallback();
|
hande.InvokeCallback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_taskCompletionSource != null)
|
|
||||||
_taskCompletionSource.TrySetResult(null);
|
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 调试信息相关
|
#region 调试信息相关
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -9,31 +9,17 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
internal class ResourceManager
|
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 readonly static Dictionary<string, SceneHandle> _sceneHandles = new Dictionary<string, SceneHandle>(100);
|
||||||
private static long _sceneCreateCount = 0;
|
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 bool _simulationOnEditor;
|
||||||
private long _loadingMaxTimeSlice;
|
private bool _autoDestroyAssetProvider;
|
||||||
private IBundleQuery _bundleQuery;
|
private IBundleQuery _bundleQuery;
|
||||||
private bool _isUnloadSafe = true;
|
|
||||||
|
|
||||||
// 计时器相关
|
|
||||||
private Stopwatch _watch;
|
|
||||||
private long _frameTime;
|
|
||||||
private bool IsBusy
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _watch.ElapsedMilliseconds - _frameTime >= _loadingMaxTimeSlice;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 所属包裹
|
/// 所属包裹
|
||||||
@@ -49,12 +35,11 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化
|
/// 初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Initialize(bool simulationOnEditor, long loadingMaxTimeSlice, IBundleQuery bundleServices)
|
public void Initialize(bool simulationOnEditor, bool autoDestroyAssetProvider, IBundleQuery bundleServices)
|
||||||
{
|
{
|
||||||
_simulationOnEditor = simulationOnEditor;
|
_simulationOnEditor = simulationOnEditor;
|
||||||
_loadingMaxTimeSlice = loadingMaxTimeSlice;
|
_autoDestroyAssetProvider = autoDestroyAssetProvider;
|
||||||
_bundleQuery = bundleServices;
|
_bundleQuery = bundleServices;
|
||||||
_watch = Stopwatch.StartNew();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -62,50 +47,24 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
_frameTime = _watch.ElapsedMilliseconds;
|
|
||||||
|
|
||||||
// 更新加载器
|
|
||||||
foreach (var loader in _loaderList)
|
foreach (var loader in _loaderList)
|
||||||
{
|
{
|
||||||
loader.Update();
|
loader.Update();
|
||||||
}
|
|
||||||
|
|
||||||
// 更新资源提供者
|
if (_autoDestroyAssetProvider)
|
||||||
// 注意:循环更新的时候,可能会扩展列表
|
loader.TryDestroyProviders();
|
||||||
_isUnloadSafe = false;
|
|
||||||
for (int i = 0; i < _providerList.Count; i++)
|
|
||||||
{
|
|
||||||
if (IsBusy)
|
|
||||||
break;
|
|
||||||
_providerList[i].Update();
|
|
||||||
}
|
}
|
||||||
_isUnloadSafe = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源回收(卸载引用计数为零的资源)
|
/// 资源回收(卸载引用计数为零的资源)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void UnloadUnusedAssets()
|
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--)
|
for (int i = _loaderList.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
BundleLoaderBase loader = _loaderList[i];
|
BundleLoaderBase loader = _loaderList[i];
|
||||||
loader.TryDestroyAllProviders();
|
loader.TryDestroyProviders();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = _loaderList.Count - 1; i >= 0; i--)
|
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>
|
||||||
/// 强制回收所有资源
|
/// 强制回收所有资源
|
||||||
|
/// 注意:加载器在销毁后关联的下载器还会继续下载!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ForceUnloadAllAssets()
|
public void ForceUnloadAllAssets()
|
||||||
{
|
{
|
||||||
#if UNITY_WEBGL
|
#if UNITY_WEBGL
|
||||||
throw new Exception($"WebGL not support invoke {nameof(ForceUnloadAllAssets)}");
|
throw new Exception($"WebGL not support invoke {nameof(ForceUnloadAllAssets)}");
|
||||||
#else
|
#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();
|
provider.Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 强制销毁资源加载器
|
||||||
foreach (var loader in _loaderList)
|
foreach (var loader in _loaderList)
|
||||||
{
|
{
|
||||||
loader.WaitForAsyncComplete();
|
loader.ForceDestroyComplete();
|
||||||
loader.Destroy();
|
loader.Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
_providerList.Clear();
|
// 清空数据
|
||||||
_providerDic.Clear();
|
_providerDic.Clear();
|
||||||
_loaderList.Clear();
|
_loaderList.Clear();
|
||||||
_loaderDic.Clear();
|
_loaderDic.Clear();
|
||||||
@@ -152,9 +176,11 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载场景
|
/// 加载场景对象
|
||||||
|
/// 注意:返回的场景句柄是唯一的,每个场景句柄对应自己的场景提供者对象。
|
||||||
|
/// 注意:业务逻辑层应该避免同时加载一个子场景。
|
||||||
/// </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)
|
if (assetInfo.IsInvalid)
|
||||||
{
|
{
|
||||||
@@ -175,14 +201,15 @@ namespace YooAsset
|
|||||||
ProviderBase provider;
|
ProviderBase provider;
|
||||||
{
|
{
|
||||||
if (_simulationOnEditor)
|
if (_simulationOnEditor)
|
||||||
provider = new DatabaseSceneProvider(this, providerGUID, assetInfo, sceneMode, suspendLoad, priority);
|
provider = new DatabaseSceneProvider(this, providerGUID, assetInfo, sceneMode, suspendLoad);
|
||||||
else
|
else
|
||||||
provider = new BundledSceneProvider(this, providerGUID, assetInfo, sceneMode, suspendLoad, priority);
|
provider = new BundledSceneProvider(this, providerGUID, assetInfo, sceneMode, suspendLoad);
|
||||||
provider.InitSpawnDebugInfo();
|
provider.InitSpawnDebugInfo();
|
||||||
_providerList.Add(provider);
|
|
||||||
_providerDic.Add(providerGUID, provider);
|
_providerDic.Add(providerGUID, provider);
|
||||||
|
OperationSystem.StartOperation(PackageName, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
provider.Priority = priority;
|
||||||
var handle = provider.CreateHandle<SceneHandle>();
|
var handle = provider.CreateHandle<SceneHandle>();
|
||||||
handle.PackageName = PackageName;
|
handle.PackageName = PackageName;
|
||||||
_sceneHandles.Add(providerGUID, handle);
|
_sceneHandles.Add(providerGUID, handle);
|
||||||
@@ -192,7 +219,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载资源对象
|
/// 加载资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AssetHandle LoadAssetAsync(AssetInfo assetInfo)
|
public AssetHandle LoadAssetAsync(AssetInfo assetInfo, uint priority)
|
||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
{
|
{
|
||||||
@@ -211,16 +238,18 @@ namespace YooAsset
|
|||||||
else
|
else
|
||||||
provider = new BundledAssetProvider(this, providerGUID, assetInfo);
|
provider = new BundledAssetProvider(this, providerGUID, assetInfo);
|
||||||
provider.InitSpawnDebugInfo();
|
provider.InitSpawnDebugInfo();
|
||||||
_providerList.Add(provider);
|
|
||||||
_providerDic.Add(providerGUID, provider);
|
_providerDic.Add(providerGUID, provider);
|
||||||
|
OperationSystem.StartOperation(PackageName, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
provider.Priority = priority;
|
||||||
return provider.CreateHandle<AssetHandle>();
|
return provider.CreateHandle<AssetHandle>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载子资源对象
|
/// 加载子资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SubAssetsHandle LoadSubAssetsAsync(AssetInfo assetInfo)
|
public SubAssetsHandle LoadSubAssetsAsync(AssetInfo assetInfo, uint priority)
|
||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
{
|
{
|
||||||
@@ -239,16 +268,18 @@ namespace YooAsset
|
|||||||
else
|
else
|
||||||
provider = new BundledSubAssetsProvider(this, providerGUID, assetInfo);
|
provider = new BundledSubAssetsProvider(this, providerGUID, assetInfo);
|
||||||
provider.InitSpawnDebugInfo();
|
provider.InitSpawnDebugInfo();
|
||||||
_providerList.Add(provider);
|
|
||||||
_providerDic.Add(providerGUID, provider);
|
_providerDic.Add(providerGUID, provider);
|
||||||
|
OperationSystem.StartOperation(PackageName, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
provider.Priority = priority;
|
||||||
return provider.CreateHandle<SubAssetsHandle>();
|
return provider.CreateHandle<SubAssetsHandle>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载所有资源对象
|
/// 加载所有资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AllAssetsHandle LoadAllAssetsAsync(AssetInfo assetInfo)
|
public AllAssetsHandle LoadAllAssetsAsync(AssetInfo assetInfo, uint priority)
|
||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
{
|
{
|
||||||
@@ -267,16 +298,18 @@ namespace YooAsset
|
|||||||
else
|
else
|
||||||
provider = new BundledAllAssetsProvider(this, providerGUID, assetInfo);
|
provider = new BundledAllAssetsProvider(this, providerGUID, assetInfo);
|
||||||
provider.InitSpawnDebugInfo();
|
provider.InitSpawnDebugInfo();
|
||||||
_providerList.Add(provider);
|
|
||||||
_providerDic.Add(providerGUID, provider);
|
_providerDic.Add(providerGUID, provider);
|
||||||
|
OperationSystem.StartOperation(PackageName, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
provider.Priority = priority;
|
||||||
return provider.CreateHandle<AllAssetsHandle>();
|
return provider.CreateHandle<AllAssetsHandle>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载原生文件
|
/// 加载原生文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RawFileHandle LoadRawFileAsync(AssetInfo assetInfo)
|
public RawFileHandle LoadRawFileAsync(AssetInfo assetInfo, uint priority)
|
||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
{
|
{
|
||||||
@@ -295,21 +328,32 @@ namespace YooAsset
|
|||||||
else
|
else
|
||||||
provider = new BundledRawFileProvider(this, providerGUID, assetInfo);
|
provider = new BundledRawFileProvider(this, providerGUID, assetInfo);
|
||||||
provider.InitSpawnDebugInfo();
|
provider.InitSpawnDebugInfo();
|
||||||
_providerList.Add(provider);
|
|
||||||
_providerDic.Add(providerGUID, provider);
|
_providerDic.Add(providerGUID, provider);
|
||||||
|
OperationSystem.StartOperation(PackageName, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
provider.Priority = priority;
|
||||||
return provider.CreateHandle<RawFileHandle>();
|
return provider.CreateHandle<RawFileHandle>();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void UnloadSubScene(ProviderBase provider)
|
internal void UnloadSubScene(string sceneName)
|
||||||
|
{
|
||||||
|
List<string> removeKeys = new List<string>();
|
||||||
|
foreach (var valuePair in _sceneHandles)
|
||||||
|
{
|
||||||
|
var sceneHandle = valuePair.Value;
|
||||||
|
if (sceneHandle.SceneName == sceneName)
|
||||||
{
|
{
|
||||||
string providerGUID = provider.ProviderGUID;
|
|
||||||
if (_sceneHandles.ContainsKey(providerGUID) == false)
|
|
||||||
throw new Exception("Should never get here !");
|
|
||||||
|
|
||||||
// 释放子场景句柄
|
// 释放子场景句柄
|
||||||
_sceneHandles[providerGUID].ReleaseInternal();
|
sceneHandle.ReleaseInternal();
|
||||||
_sceneHandles.Remove(providerGUID);
|
removeKeys.Add(valuePair.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string key in removeKeys)
|
||||||
|
{
|
||||||
|
_sceneHandles.Remove(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void UnloadAllScene()
|
private void UnloadAllScene()
|
||||||
{
|
{
|
||||||
@@ -357,14 +401,17 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
return result;
|
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);
|
_providerDic.Remove(provider.ProviderGUID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
internal bool HasAnyLoader()
|
||||||
|
{
|
||||||
|
return _loaderList.Count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
private BundleLoaderBase CreateAssetBundleLoaderInternal(BundleInfo bundleInfo)
|
private BundleLoaderBase CreateAssetBundleLoaderInternal(BundleInfo bundleInfo)
|
||||||
{
|
{
|
||||||
@@ -416,8 +463,8 @@ namespace YooAsset
|
|||||||
#region 调试信息
|
#region 调试信息
|
||||||
internal List<DebugProviderInfo> GetDebugReportInfos()
|
internal List<DebugProviderInfo> GetDebugReportInfos()
|
||||||
{
|
{
|
||||||
List<DebugProviderInfo> result = new List<DebugProviderInfo>(_providerList.Count);
|
List<DebugProviderInfo> result = new List<DebugProviderInfo>(_providerDic.Count);
|
||||||
foreach (var provider in _providerList)
|
foreach (var provider in _providerDic.Values)
|
||||||
{
|
{
|
||||||
DebugProviderInfo providerInfo = new DebugProviderInfo();
|
DebugProviderInfo providerInfo = new DebugProviderInfo();
|
||||||
providerInfo.AssetPath = provider.MainAssetInfo.AssetPath;
|
providerInfo.AssetPath = provider.MainAssetInfo.AssetPath;
|
||||||
@@ -432,15 +479,6 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
return result;
|
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
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,16 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
BundleInfo[] GetDependBundleInfos(AssetInfo assetPath);
|
BundleInfo[] GetDependBundleInfos(AssetInfo assetPath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取主资源包名称
|
||||||
|
/// </summary>
|
||||||
|
string GetMainBundleName(AssetInfo assetInfo);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取依赖的资源包名称集合
|
||||||
|
/// </summary>
|
||||||
|
string[] GetDependBundleNames(AssetInfo assetInfo);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清单是否有效
|
/// 清单是否有效
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -95,6 +95,9 @@ namespace YooAsset
|
|||||||
_failedTryAgain = failedTryAgain;
|
_failedTryAgain = failedTryAgain;
|
||||||
_timeout = timeout;
|
_timeout = timeout;
|
||||||
|
|
||||||
|
// 设置包裹名称 (fix #210)
|
||||||
|
SetPackageName(packageName);
|
||||||
|
|
||||||
// 统计下载信息
|
// 统计下载信息
|
||||||
CalculatDownloaderInfo();
|
CalculatDownloaderInfo();
|
||||||
}
|
}
|
||||||
@@ -208,12 +211,18 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (_bundleInfoList != null)
|
if (_bundleInfoList != null)
|
||||||
{
|
{
|
||||||
|
TotalDownloadBytes = 0;
|
||||||
TotalDownloadCount = _bundleInfoList.Count;
|
TotalDownloadCount = _bundleInfoList.Count;
|
||||||
foreach (var packageBundle in _bundleInfoList)
|
foreach (var packageBundle in _bundleInfoList)
|
||||||
{
|
{
|
||||||
TotalDownloadBytes += packageBundle.Bundle.FileSize;
|
TotalDownloadBytes += packageBundle.Bundle.FileSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TotalDownloadBytes = 0;
|
||||||
|
TotalDownloadCount = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -263,7 +272,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (_steps == ESteps.None)
|
if (_steps == ESteps.None)
|
||||||
{
|
{
|
||||||
OperationSystem.StartOperation(_packageName, this);
|
OperationSystem.StartOperation(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ namespace YooAsset
|
|||||||
if (_cachingOperation == null)
|
if (_cachingOperation == null)
|
||||||
{
|
{
|
||||||
_cachingOperation = new PackageCachingOperation(_impl.Persistent, _impl.Cache);
|
_cachingOperation = new PackageCachingOperation(_impl.Persistent, _impl.Cache);
|
||||||
OperationSystem.StartOperation(_impl.PackageName,_cachingOperation);
|
OperationSystem.StartOperation(_impl.PackageName, _cachingOperation);
|
||||||
}
|
}
|
||||||
|
|
||||||
Progress = _cachingOperation.Progress;
|
Progress = _cachingOperation.Progress;
|
||||||
|
|||||||
@@ -44,10 +44,15 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
public static class EditorSimulateModeHelper
|
public static class EditorSimulateModeHelper
|
||||||
{
|
{
|
||||||
/// <summary>
|
public static string SimulateBuild(string buildPipelineName, string packageName)
|
||||||
/// 编辑器下模拟构建清单
|
{
|
||||||
/// </summary>
|
throw new System.Exception("Only support in unity editor !");
|
||||||
public static string SimulateBuild(string buildPipelineName, string packageName) { throw new System.Exception("Only support in unity editor !"); }
|
}
|
||||||
|
|
||||||
|
public static string SimulateBuild(EDefaultBuildPipeline buildPipeline, string packageName)
|
||||||
|
{
|
||||||
|
throw new System.Exception("Only support in unity editor !");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -129,6 +129,29 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
|
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
||||||
|
{
|
||||||
|
if (assetInfo.IsInvalid)
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
|
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||||
|
return packageBundle.BundleName;
|
||||||
|
}
|
||||||
|
string[] IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
||||||
|
{
|
||||||
|
if (assetInfo.IsInvalid)
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
|
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
|
List<string> result = new List<string>(depends.Length);
|
||||||
|
foreach (var packageBundle in depends)
|
||||||
|
{
|
||||||
|
result.Add(packageBundle.BundleName);
|
||||||
|
}
|
||||||
|
return result.ToArray();
|
||||||
|
}
|
||||||
bool IBundleQuery.ManifestValid()
|
bool IBundleQuery.ManifestValid()
|
||||||
{
|
{
|
||||||
return _activeManifest != null;
|
return _activeManifest != null;
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (_deliveryQueryServices == null)
|
if (_deliveryQueryServices == null)
|
||||||
return false;
|
return false;
|
||||||
return _deliveryQueryServices.Query(PackageName, packageBundle.FileName);
|
return _deliveryQueryServices.Query(PackageName, packageBundle.FileName, packageBundle.FileCRC);
|
||||||
}
|
}
|
||||||
private bool IsCachedPackageBundle(PackageBundle packageBundle)
|
private bool IsCachedPackageBundle(PackageBundle packageBundle)
|
||||||
{
|
{
|
||||||
@@ -83,7 +83,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
private bool IsBuildinPackageBundle(PackageBundle packageBundle)
|
private bool IsBuildinPackageBundle(PackageBundle packageBundle)
|
||||||
{
|
{
|
||||||
return _buildinQueryServices.Query(PackageName, packageBundle.FileName);
|
return _buildinQueryServices.Query(PackageName, packageBundle.FileName, packageBundle.FileCRC);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IPlayMode接口
|
#region IPlayMode接口
|
||||||
@@ -385,6 +385,29 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
|
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
||||||
|
{
|
||||||
|
if (assetInfo.IsInvalid)
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
|
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||||
|
return packageBundle.BundleName;
|
||||||
|
}
|
||||||
|
string[] IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
||||||
|
{
|
||||||
|
if (assetInfo.IsInvalid)
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
|
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
|
List<string> result = new List<string>(depends.Length);
|
||||||
|
foreach (var packageBundle in depends)
|
||||||
|
{
|
||||||
|
result.Add(packageBundle.BundleName);
|
||||||
|
}
|
||||||
|
return result.ToArray();
|
||||||
|
}
|
||||||
bool IBundleQuery.ManifestValid()
|
bool IBundleQuery.ManifestValid()
|
||||||
{
|
{
|
||||||
return _activeManifest != null;
|
return _activeManifest != null;
|
||||||
|
|||||||
@@ -214,6 +214,29 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
|
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
||||||
|
{
|
||||||
|
if (assetInfo.IsInvalid)
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
|
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||||
|
return packageBundle.BundleName;
|
||||||
|
}
|
||||||
|
string[] IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
||||||
|
{
|
||||||
|
if (assetInfo.IsInvalid)
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
|
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
|
List<string> result = new List<string>(depends.Length);
|
||||||
|
foreach (var packageBundle in depends)
|
||||||
|
{
|
||||||
|
result.Add(packageBundle.BundleName);
|
||||||
|
}
|
||||||
|
return result.ToArray();
|
||||||
|
}
|
||||||
bool IBundleQuery.ManifestValid()
|
bool IBundleQuery.ManifestValid()
|
||||||
{
|
{
|
||||||
return _activeManifest != null;
|
return _activeManifest != null;
|
||||||
|
|||||||
@@ -65,9 +65,26 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 查询相关
|
// 查询相关
|
||||||
|
#if UNITY_WECHAT_GAME
|
||||||
|
private WeChatWASM.WXFileSystemManager _wxFileSystemMgr;
|
||||||
|
private bool IsCachedPackageBundle(PackageBundle packageBundle)
|
||||||
|
{
|
||||||
|
if (_wxFileSystemMgr == null)
|
||||||
|
_wxFileSystemMgr = WeChatWASM.WX.GetFileSystemManager();
|
||||||
|
string filePath = WeChatWASM.WX.env.USER_DATA_PATH + packageBundle.FileName;
|
||||||
|
string result = _wxFileSystemMgr.AccessSync(filePath);
|
||||||
|
return result.Equals("access:ok");
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
private bool IsCachedPackageBundle(PackageBundle packageBundle)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private bool IsBuildinPackageBundle(PackageBundle packageBundle)
|
private bool IsBuildinPackageBundle(PackageBundle packageBundle)
|
||||||
{
|
{
|
||||||
return _buildinQueryServices.Query(PackageName, packageBundle.FileName);
|
return _buildinQueryServices.Query(PackageName, packageBundle.FileName, packageBundle.FileCRC);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IPlayMode接口
|
#region IPlayMode接口
|
||||||
@@ -116,6 +133,10 @@ namespace YooAsset
|
|||||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
|
// 忽略缓存文件
|
||||||
|
if (IsCachedPackageBundle(packageBundle))
|
||||||
|
continue;
|
||||||
|
|
||||||
// 忽略APP资源
|
// 忽略APP资源
|
||||||
if (IsBuildinPackageBundle(packageBundle))
|
if (IsBuildinPackageBundle(packageBundle))
|
||||||
continue;
|
continue;
|
||||||
@@ -137,6 +158,10 @@ namespace YooAsset
|
|||||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
|
// 忽略缓存文件
|
||||||
|
if (IsCachedPackageBundle(packageBundle))
|
||||||
|
continue;
|
||||||
|
|
||||||
// 忽略APP资源
|
// 忽略APP资源
|
||||||
if (IsBuildinPackageBundle(packageBundle))
|
if (IsBuildinPackageBundle(packageBundle))
|
||||||
continue;
|
continue;
|
||||||
@@ -194,6 +219,10 @@ namespace YooAsset
|
|||||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
||||||
foreach (var packageBundle in checkList)
|
foreach (var packageBundle in checkList)
|
||||||
{
|
{
|
||||||
|
// 忽略缓存文件
|
||||||
|
if (IsCachedPackageBundle(packageBundle))
|
||||||
|
continue;
|
||||||
|
|
||||||
// 忽略APP资源
|
// 忽略APP资源
|
||||||
if (IsBuildinPackageBundle(packageBundle))
|
if (IsBuildinPackageBundle(packageBundle))
|
||||||
continue;
|
continue;
|
||||||
@@ -259,6 +288,29 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
|
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
||||||
|
{
|
||||||
|
if (assetInfo.IsInvalid)
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
|
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||||
|
return packageBundle.BundleName;
|
||||||
|
}
|
||||||
|
string[] IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
||||||
|
{
|
||||||
|
if (assetInfo.IsInvalid)
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
|
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
|
List<string> result = new List<string>(depends.Length);
|
||||||
|
foreach (var packageBundle in depends)
|
||||||
|
{
|
||||||
|
result.Add(packageBundle.BundleName);
|
||||||
|
}
|
||||||
|
return result.ToArray();
|
||||||
|
}
|
||||||
bool IBundleQuery.ManifestValid()
|
bool IBundleQuery.ManifestValid()
|
||||||
{
|
{
|
||||||
return _activeManifest != null;
|
return _activeManifest != null;
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ namespace YooAsset
|
|||||||
var editorSimulateModeImpl = new EditorSimulateModeImpl(PackageName);
|
var editorSimulateModeImpl = new EditorSimulateModeImpl(PackageName);
|
||||||
_bundleQuery = editorSimulateModeImpl;
|
_bundleQuery = editorSimulateModeImpl;
|
||||||
_playModeImpl = editorSimulateModeImpl;
|
_playModeImpl = editorSimulateModeImpl;
|
||||||
_resourceMgr.Initialize(true, parameters.LoadingMaxTimeSlice, _bundleQuery);
|
_resourceMgr.Initialize(true, parameters.AutoDestroyAssetProvider, _bundleQuery);
|
||||||
|
|
||||||
var initializeParameters = parameters as EditorSimulateModeParameters;
|
var initializeParameters = parameters as EditorSimulateModeParameters;
|
||||||
initializeOperation = editorSimulateModeImpl.InitializeAsync(assist, initializeParameters.SimulateManifestFilePath);
|
initializeOperation = editorSimulateModeImpl.InitializeAsync(assist, initializeParameters.SimulateManifestFilePath);
|
||||||
@@ -156,7 +156,7 @@ namespace YooAsset
|
|||||||
var offlinePlayModeImpl = new OfflinePlayModeImpl(PackageName);
|
var offlinePlayModeImpl = new OfflinePlayModeImpl(PackageName);
|
||||||
_bundleQuery = offlinePlayModeImpl;
|
_bundleQuery = offlinePlayModeImpl;
|
||||||
_playModeImpl = offlinePlayModeImpl;
|
_playModeImpl = offlinePlayModeImpl;
|
||||||
_resourceMgr.Initialize(false, parameters.LoadingMaxTimeSlice, _bundleQuery);
|
_resourceMgr.Initialize(false, parameters.AutoDestroyAssetProvider, _bundleQuery);
|
||||||
|
|
||||||
var initializeParameters = parameters as OfflinePlayModeParameters;
|
var initializeParameters = parameters as OfflinePlayModeParameters;
|
||||||
initializeOperation = offlinePlayModeImpl.InitializeAsync(assist);
|
initializeOperation = offlinePlayModeImpl.InitializeAsync(assist);
|
||||||
@@ -166,7 +166,7 @@ namespace YooAsset
|
|||||||
var hostPlayModeImpl = new HostPlayModeImpl(PackageName);
|
var hostPlayModeImpl = new HostPlayModeImpl(PackageName);
|
||||||
_bundleQuery = hostPlayModeImpl;
|
_bundleQuery = hostPlayModeImpl;
|
||||||
_playModeImpl = hostPlayModeImpl;
|
_playModeImpl = hostPlayModeImpl;
|
||||||
_resourceMgr.Initialize(false, parameters.LoadingMaxTimeSlice, _bundleQuery);
|
_resourceMgr.Initialize(false, parameters.AutoDestroyAssetProvider, _bundleQuery);
|
||||||
|
|
||||||
var initializeParameters = parameters as HostPlayModeParameters;
|
var initializeParameters = parameters as HostPlayModeParameters;
|
||||||
initializeOperation = hostPlayModeImpl.InitializeAsync(assist,
|
initializeOperation = hostPlayModeImpl.InitializeAsync(assist,
|
||||||
@@ -179,7 +179,7 @@ namespace YooAsset
|
|||||||
var webPlayModeImpl = new WebPlayModeImpl(PackageName);
|
var webPlayModeImpl = new WebPlayModeImpl(PackageName);
|
||||||
_bundleQuery = webPlayModeImpl;
|
_bundleQuery = webPlayModeImpl;
|
||||||
_playModeImpl = webPlayModeImpl;
|
_playModeImpl = webPlayModeImpl;
|
||||||
_resourceMgr.Initialize(false, parameters.LoadingMaxTimeSlice, _bundleQuery);
|
_resourceMgr.Initialize(false, parameters.AutoDestroyAssetProvider, _bundleQuery);
|
||||||
|
|
||||||
var initializeParameters = parameters as WebPlayModeParameters;
|
var initializeParameters = parameters as WebPlayModeParameters;
|
||||||
initializeOperation = webPlayModeImpl.InitializeAsync(assist,
|
initializeOperation = webPlayModeImpl.InitializeAsync(assist,
|
||||||
@@ -266,13 +266,6 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测参数范围
|
|
||||||
if (parameters.LoadingMaxTimeSlice < 10)
|
|
||||||
{
|
|
||||||
parameters.LoadingMaxTimeSlice = 10;
|
|
||||||
YooLogger.Warning($"{nameof(parameters.LoadingMaxTimeSlice)} minimum value is 10 milliseconds.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void InitializeOperation_Completed(AsyncOperationBase op)
|
private void InitializeOperation_Completed(AsyncOperationBase op)
|
||||||
{
|
{
|
||||||
@@ -300,7 +293,13 @@ namespace YooAsset
|
|||||||
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion = true, int timeout = 60)
|
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion = true, int timeout = 60)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize(false);
|
DebugCheckInitialize(false);
|
||||||
DebugCheckUpdateManifest();
|
|
||||||
|
// 注意:强烈建议在更新之前保持加载器为空!
|
||||||
|
if (_resourceMgr.HasAnyLoader())
|
||||||
|
{
|
||||||
|
YooLogger.Warning($"Found loaded bundle before update manifest ! Recommended to call the {nameof(ForceUnloadAllAssets)} method to release loaded bundle !");
|
||||||
|
}
|
||||||
|
|
||||||
return _playModeImpl.UpdatePackageManifestAsync(packageVersion, autoSaveVersion, timeout);
|
return _playModeImpl.UpdatePackageManifestAsync(packageVersion, autoSaveVersion, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,6 +345,7 @@ namespace YooAsset
|
|||||||
return _playModeImpl.ActiveManifest.PackageVersion;
|
return _playModeImpl.ActiveManifest.PackageVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region 资源卸载
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源回收(卸载引用计数为零的资源)
|
/// 资源回收(卸载引用计数为零的资源)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -355,6 +355,25 @@ namespace YooAsset
|
|||||||
_resourceMgr.UnloadUnusedAssets();
|
_resourceMgr.UnloadUnusedAssets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源回收(尝试卸载指定的资源)
|
||||||
|
/// </summary>
|
||||||
|
public void TryUnloadUnusedAsset(string location)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||||
|
_resourceMgr.TryUnloadUnusedAsset(assetInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源回收(尝试卸载指定的资源)
|
||||||
|
/// </summary>
|
||||||
|
public void TryUnloadUnusedAsset(AssetInfo assetInfo)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
_resourceMgr.TryUnloadUnusedAsset(assetInfo);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 强制回收所有资源
|
/// 强制回收所有资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -363,6 +382,7 @@ namespace YooAsset
|
|||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
_resourceMgr.ForceUnloadAllAssets();
|
_resourceMgr.ForceUnloadAllAssets();
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region 沙盒相关
|
#region 沙盒相关
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -521,7 +541,7 @@ namespace YooAsset
|
|||||||
public RawFileHandle LoadRawFileSync(AssetInfo assetInfo)
|
public RawFileHandle LoadRawFileSync(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
return LoadRawFileInternal(assetInfo, true);
|
return LoadRawFileInternal(assetInfo, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -532,35 +552,37 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||||
return LoadRawFileInternal(assetInfo, true);
|
return LoadRawFileInternal(assetInfo, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载原生文件
|
/// 异步加载原生文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assetInfo">资源信息</param>
|
/// <param name="assetInfo">资源信息</param>
|
||||||
public RawFileHandle LoadRawFileAsync(AssetInfo assetInfo)
|
/// <param name="priority">加载的优先级</param>
|
||||||
|
public RawFileHandle LoadRawFileAsync(AssetInfo assetInfo, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
return LoadRawFileInternal(assetInfo, false);
|
return LoadRawFileInternal(assetInfo, false, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载原生文件
|
/// 异步加载原生文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
public RawFileHandle LoadRawFileAsync(string location)
|
/// <param name="priority">加载的优先级</param>
|
||||||
|
public RawFileHandle LoadRawFileAsync(string location, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||||
return LoadRawFileInternal(assetInfo, false);
|
return LoadRawFileInternal(assetInfo, false, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private RawFileHandle LoadRawFileInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
private RawFileHandle LoadRawFileInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
|
||||||
{
|
{
|
||||||
DebugCheckRawFileLoadMethod(nameof(LoadRawFileAsync));
|
DebugCheckRawFileLoadMethod(nameof(LoadRawFileAsync));
|
||||||
var handle = _resourceMgr.LoadRawFileAsync(assetInfo);
|
var handle = _resourceMgr.LoadRawFileAsync(assetInfo, priority);
|
||||||
if (waitForAsyncComplete)
|
if (waitForAsyncComplete)
|
||||||
handle.WaitForAsyncComplete();
|
handle.WaitForAsyncComplete();
|
||||||
return handle;
|
return handle;
|
||||||
@@ -574,8 +596,8 @@ namespace YooAsset
|
|||||||
/// <param name="location">场景的定位地址</param>
|
/// <param name="location">场景的定位地址</param>
|
||||||
/// <param name="sceneMode">场景加载模式</param>
|
/// <param name="sceneMode">场景加载模式</param>
|
||||||
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
||||||
/// <param name="priority">优先级</param>
|
/// <param name="priority">加载的优先级</param>
|
||||||
public SceneHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, int priority = 100)
|
public SceneHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||||
@@ -589,8 +611,8 @@ namespace YooAsset
|
|||||||
/// <param name="assetInfo">场景的资源信息</param>
|
/// <param name="assetInfo">场景的资源信息</param>
|
||||||
/// <param name="sceneMode">场景加载模式</param>
|
/// <param name="sceneMode">场景加载模式</param>
|
||||||
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
||||||
/// <param name="priority">优先级</param>
|
/// <param name="priority">加载的优先级</param>
|
||||||
public SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, int priority = 100)
|
public SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
var handle = _resourceMgr.LoadSceneAsync(assetInfo, sceneMode, suspendLoad, priority);
|
var handle = _resourceMgr.LoadSceneAsync(assetInfo, sceneMode, suspendLoad, priority);
|
||||||
@@ -606,7 +628,7 @@ namespace YooAsset
|
|||||||
public AssetHandle LoadAssetSync(AssetInfo assetInfo)
|
public AssetHandle LoadAssetSync(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
return LoadAssetInternal(assetInfo, true);
|
return LoadAssetInternal(assetInfo, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -618,7 +640,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
||||||
return LoadAssetInternal(assetInfo, true);
|
return LoadAssetInternal(assetInfo, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -630,7 +652,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||||
return LoadAssetInternal(assetInfo, true);
|
return LoadAssetInternal(assetInfo, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -642,7 +664,7 @@ namespace YooAsset
|
|||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
Type type = typeof(UnityEngine.Object);
|
Type type = typeof(UnityEngine.Object);
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||||
return LoadAssetInternal(assetInfo, true);
|
return LoadAssetInternal(assetInfo, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -650,10 +672,11 @@ namespace YooAsset
|
|||||||
/// 异步加载资源对象
|
/// 异步加载资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assetInfo">资源信息</param>
|
/// <param name="assetInfo">资源信息</param>
|
||||||
public AssetHandle LoadAssetAsync(AssetInfo assetInfo)
|
/// <param name="priority">加载的优先级</param>
|
||||||
|
public AssetHandle LoadAssetAsync(AssetInfo assetInfo, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
return LoadAssetInternal(assetInfo, false);
|
return LoadAssetInternal(assetInfo, false, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -661,11 +684,12 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TObject">资源类型</typeparam>
|
/// <typeparam name="TObject">资源类型</typeparam>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
public AssetHandle LoadAssetAsync<TObject>(string location) where TObject : UnityEngine.Object
|
/// <param name="priority">加载的优先级</param>
|
||||||
|
public AssetHandle LoadAssetAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
||||||
return LoadAssetInternal(assetInfo, false);
|
return LoadAssetInternal(assetInfo, false, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -673,31 +697,33 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
/// <param name="type">资源类型</param>
|
/// <param name="type">资源类型</param>
|
||||||
public AssetHandle LoadAssetAsync(string location, System.Type type)
|
/// <param name="priority">加载的优先级</param>
|
||||||
|
public AssetHandle LoadAssetAsync(string location, System.Type type, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||||
return LoadAssetInternal(assetInfo, false);
|
return LoadAssetInternal(assetInfo, false, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载资源对象
|
/// 异步加载资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
public AssetHandle LoadAssetAsync(string location)
|
/// <param name="priority">加载的优先级</param>
|
||||||
|
public AssetHandle LoadAssetAsync(string location, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
Type type = typeof(UnityEngine.Object);
|
Type type = typeof(UnityEngine.Object);
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||||
return LoadAssetInternal(assetInfo, false);
|
return LoadAssetInternal(assetInfo, false, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private AssetHandle LoadAssetInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
private AssetHandle LoadAssetInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
|
||||||
{
|
{
|
||||||
DebugCheckAssetLoadMethod(nameof(LoadAssetAsync));
|
DebugCheckAssetLoadMethod(nameof(LoadAssetAsync));
|
||||||
DebugCheckAssetLoadType(assetInfo.AssetType);
|
DebugCheckAssetLoadType(assetInfo.AssetType);
|
||||||
var handle = _resourceMgr.LoadAssetAsync(assetInfo);
|
var handle = _resourceMgr.LoadAssetAsync(assetInfo, priority);
|
||||||
if (waitForAsyncComplete)
|
if (waitForAsyncComplete)
|
||||||
handle.WaitForAsyncComplete();
|
handle.WaitForAsyncComplete();
|
||||||
return handle;
|
return handle;
|
||||||
@@ -712,7 +738,7 @@ namespace YooAsset
|
|||||||
public SubAssetsHandle LoadSubAssetsSync(AssetInfo assetInfo)
|
public SubAssetsHandle LoadSubAssetsSync(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
return LoadSubAssetsInternal(assetInfo, true);
|
return LoadSubAssetsInternal(assetInfo, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -724,7 +750,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
||||||
return LoadSubAssetsInternal(assetInfo, true);
|
return LoadSubAssetsInternal(assetInfo, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -736,7 +762,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||||
return LoadSubAssetsInternal(assetInfo, true);
|
return LoadSubAssetsInternal(assetInfo, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -748,7 +774,7 @@ namespace YooAsset
|
|||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
Type type = typeof(UnityEngine.Object);
|
Type type = typeof(UnityEngine.Object);
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||||
return LoadSubAssetsInternal(assetInfo, true);
|
return LoadSubAssetsInternal(assetInfo, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -756,10 +782,11 @@ namespace YooAsset
|
|||||||
/// 异步加载子资源对象
|
/// 异步加载子资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assetInfo">资源信息</param>
|
/// <param name="assetInfo">资源信息</param>
|
||||||
public SubAssetsHandle LoadSubAssetsAsync(AssetInfo assetInfo)
|
/// <param name="priority">加载的优先级</param>
|
||||||
|
public SubAssetsHandle LoadSubAssetsAsync(AssetInfo assetInfo, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
return LoadSubAssetsInternal(assetInfo, false);
|
return LoadSubAssetsInternal(assetInfo, false, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -767,11 +794,12 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TObject">资源类型</typeparam>
|
/// <typeparam name="TObject">资源类型</typeparam>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
public SubAssetsHandle LoadSubAssetsAsync<TObject>(string location) where TObject : UnityEngine.Object
|
/// <param name="priority">加载的优先级</param>
|
||||||
|
public SubAssetsHandle LoadSubAssetsAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
||||||
return LoadSubAssetsInternal(assetInfo, false);
|
return LoadSubAssetsInternal(assetInfo, false, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -779,31 +807,33 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
/// <param name="type">子对象类型</param>
|
/// <param name="type">子对象类型</param>
|
||||||
public SubAssetsHandle LoadSubAssetsAsync(string location, System.Type type)
|
/// <param name="priority">加载的优先级</param>
|
||||||
|
public SubAssetsHandle LoadSubAssetsAsync(string location, System.Type type, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||||
return LoadSubAssetsInternal(assetInfo, false);
|
return LoadSubAssetsInternal(assetInfo, false, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载子资源对象
|
/// 异步加载子资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
public SubAssetsHandle LoadSubAssetsAsync(string location)
|
/// <param name="priority">加载的优先级</param>
|
||||||
|
public SubAssetsHandle LoadSubAssetsAsync(string location, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
Type type = typeof(UnityEngine.Object);
|
Type type = typeof(UnityEngine.Object);
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||||
return LoadSubAssetsInternal(assetInfo, false);
|
return LoadSubAssetsInternal(assetInfo, false, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private SubAssetsHandle LoadSubAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
private SubAssetsHandle LoadSubAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
|
||||||
{
|
{
|
||||||
DebugCheckAssetLoadMethod(nameof(LoadSubAssetsAsync));
|
DebugCheckAssetLoadMethod(nameof(LoadSubAssetsAsync));
|
||||||
DebugCheckAssetLoadType(assetInfo.AssetType);
|
DebugCheckAssetLoadType(assetInfo.AssetType);
|
||||||
var handle = _resourceMgr.LoadSubAssetsAsync(assetInfo);
|
var handle = _resourceMgr.LoadSubAssetsAsync(assetInfo, priority);
|
||||||
if (waitForAsyncComplete)
|
if (waitForAsyncComplete)
|
||||||
handle.WaitForAsyncComplete();
|
handle.WaitForAsyncComplete();
|
||||||
return handle;
|
return handle;
|
||||||
@@ -818,7 +848,7 @@ namespace YooAsset
|
|||||||
public AllAssetsHandle LoadAllAssetsSync(AssetInfo assetInfo)
|
public AllAssetsHandle LoadAllAssetsSync(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
return LoadAllAssetsInternal(assetInfo, true);
|
return LoadAllAssetsInternal(assetInfo, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -830,7 +860,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
||||||
return LoadAllAssetsInternal(assetInfo, true);
|
return LoadAllAssetsInternal(assetInfo, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -842,7 +872,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||||
return LoadAllAssetsInternal(assetInfo, true);
|
return LoadAllAssetsInternal(assetInfo, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -854,7 +884,7 @@ namespace YooAsset
|
|||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
Type type = typeof(UnityEngine.Object);
|
Type type = typeof(UnityEngine.Object);
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||||
return LoadAllAssetsInternal(assetInfo, true);
|
return LoadAllAssetsInternal(assetInfo, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -862,10 +892,11 @@ namespace YooAsset
|
|||||||
/// 异步加载资源包内所有资源对象
|
/// 异步加载资源包内所有资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assetInfo">资源信息</param>
|
/// <param name="assetInfo">资源信息</param>
|
||||||
public AllAssetsHandle LoadAllAssetsAsync(AssetInfo assetInfo)
|
/// <param name="priority">加载的优先级</param>
|
||||||
|
public AllAssetsHandle LoadAllAssetsAsync(AssetInfo assetInfo, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
return LoadAllAssetsInternal(assetInfo, false);
|
return LoadAllAssetsInternal(assetInfo, false, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -873,11 +904,12 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TObject">资源类型</typeparam>
|
/// <typeparam name="TObject">资源类型</typeparam>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
public AllAssetsHandle LoadAllAssetsAsync<TObject>(string location) where TObject : UnityEngine.Object
|
/// <param name="priority">加载的优先级</param>
|
||||||
|
public AllAssetsHandle LoadAllAssetsAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
||||||
return LoadAllAssetsInternal(assetInfo, false);
|
return LoadAllAssetsInternal(assetInfo, false, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -885,31 +917,33 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
/// <param name="type">子对象类型</param>
|
/// <param name="type">子对象类型</param>
|
||||||
public AllAssetsHandle LoadAllAssetsAsync(string location, System.Type type)
|
/// <param name="priority">加载的优先级</param>
|
||||||
|
public AllAssetsHandle LoadAllAssetsAsync(string location, System.Type type, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||||
return LoadAllAssetsInternal(assetInfo, false);
|
return LoadAllAssetsInternal(assetInfo, false, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载资源包内所有资源对象
|
/// 异步加载资源包内所有资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
public AllAssetsHandle LoadAllAssetsAsync(string location)
|
/// <param name="priority">加载的优先级</param>
|
||||||
|
public AllAssetsHandle LoadAllAssetsAsync(string location, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
Type type = typeof(UnityEngine.Object);
|
Type type = typeof(UnityEngine.Object);
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||||
return LoadAllAssetsInternal(assetInfo, false);
|
return LoadAllAssetsInternal(assetInfo, false, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private AllAssetsHandle LoadAllAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
private AllAssetsHandle LoadAllAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
|
||||||
{
|
{
|
||||||
DebugCheckAssetLoadMethod(nameof(LoadAllAssetsAsync));
|
DebugCheckAssetLoadMethod(nameof(LoadAllAssetsAsync));
|
||||||
DebugCheckAssetLoadType(assetInfo.AssetType);
|
DebugCheckAssetLoadType(assetInfo.AssetType);
|
||||||
var handle = _resourceMgr.LoadAllAssetsAsync(assetInfo);
|
var handle = _resourceMgr.LoadAllAssetsAsync(assetInfo, priority);
|
||||||
if (waitForAsyncComplete)
|
if (waitForAsyncComplete)
|
||||||
handle.WaitForAsyncComplete();
|
handle.WaitForAsyncComplete();
|
||||||
return handle;
|
return handle;
|
||||||
@@ -1107,16 +1141,6 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Conditional("DEBUG")]
|
|
||||||
private void DebugCheckUpdateManifest()
|
|
||||||
{
|
|
||||||
var loadedBundleInfos = _resourceMgr.GetLoadedBundleInfos();
|
|
||||||
if (loadedBundleInfos.Count > 0)
|
|
||||||
{
|
|
||||||
YooLogger.Warning($"Found loaded bundle before update manifest ! Recommended to call the {nameof(ForceUnloadAllAssets)} method to release loaded bundle !");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Conditional("DEBUG")]
|
[Conditional("DEBUG")]
|
||||||
private void DebugCheckRawFileLoadMethod(string method)
|
private void DebugCheckRawFileLoadMethod(string method)
|
||||||
{
|
{
|
||||||
@@ -1141,6 +1165,11 @@ namespace YooAsset
|
|||||||
if (type == null)
|
if (type == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (typeof(UnityEngine.Behaviour).IsAssignableFrom(type))
|
||||||
|
{
|
||||||
|
throw new Exception($"Load asset type is invalid : {type.FullName} !");
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof(UnityEngine.Object).IsAssignableFrom(type) == false)
|
if (typeof(UnityEngine.Object).IsAssignableFrom(type) == false)
|
||||||
{
|
{
|
||||||
throw new Exception($"Load asset type is invalid : {type.FullName} !");
|
throw new Exception($"Load asset type is invalid : {type.FullName} !");
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询是否为应用程序内置的资源文件
|
/// 查询是否为应用程序内置的资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool Query(string packageName, string fileName);
|
/// <param name="packageName">包裹名称</param>
|
||||||
|
/// <param name="fileName">文件名称(包含文件的后缀格式)</param>
|
||||||
|
/// <param name="fileCRC">文件哈希值</param>
|
||||||
|
/// <returns>返回查询结果</returns>
|
||||||
|
bool Query(string packageName, string fileName, string fileCRC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,11 +6,18 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询是否为开发者分发的资源文件
|
/// 查询是否为开发者分发的资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool Query(string packageName, string fileName);
|
/// <param name="packageName">包裹名称</param>
|
||||||
|
/// <param name="fileName">文件名称(包含文件的后缀格式)</param>
|
||||||
|
/// <param name="fileCRC">文件哈希值</param>
|
||||||
|
/// <returns>返回查询结果</returns>
|
||||||
|
bool Query(string packageName, string fileName, string fileCRC);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取分发资源文件的路径
|
/// 获取分发资源文件的路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="packageName">包裹名称</param>
|
||||||
|
/// <param name="fileName">文件名称(包含文件的后缀格式)</param>
|
||||||
|
/// <returns>返回资源文件的路径</returns>
|
||||||
string GetFilePath(string packageName, string fileName);
|
string GetFilePath(string packageName, string fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected override byte[] HashFinal()
|
protected override byte[] HashFinal()
|
||||||
{
|
{
|
||||||
if(BitConverter.IsLittleEndian)
|
if (BitConverter.IsLittleEndian)
|
||||||
return new[] { (byte)_currentCrc, (byte)(_currentCrc >> 8), (byte)(_currentCrc >> 16), (byte)(_currentCrc >> 24) };
|
return new[] { (byte)_currentCrc, (byte)(_currentCrc >> 8), (byte)(_currentCrc >> 16), (byte)(_currentCrc >> 24) };
|
||||||
else
|
else
|
||||||
return new[] { (byte)(_currentCrc >> 24), (byte)(_currentCrc >> 16), (byte)(_currentCrc >> 8), (byte)_currentCrc };
|
return new[] { (byte)(_currentCrc >> 24), (byte)(_currentCrc >> 16), (byte)(_currentCrc >> 8), (byte)_currentCrc };
|
||||||
|
|||||||
@@ -12,6 +12,14 @@ namespace YooAsset
|
|||||||
private static GameObject _driver = null;
|
private static GameObject _driver = null;
|
||||||
private static readonly List<ResourcePackage> _packages = new List<ResourcePackage>();
|
private static readonly List<ResourcePackage> _packages = new List<ResourcePackage>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否已经初始化
|
||||||
|
/// </summary>
|
||||||
|
public static bool Initialized
|
||||||
|
{
|
||||||
|
get { return _isInitialize; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化资源系统
|
/// 初始化资源系统
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -90,7 +98,7 @@ namespace YooAsset
|
|||||||
public static ResourcePackage CreatePackage(string packageName)
|
public static ResourcePackage CreatePackage(string packageName)
|
||||||
{
|
{
|
||||||
CheckException(packageName);
|
CheckException(packageName);
|
||||||
if (HasPackage(packageName))
|
if (ContainsPackage(packageName))
|
||||||
throw new Exception($"Package {packageName} already existed !");
|
throw new Exception($"Package {packageName} already existed !");
|
||||||
|
|
||||||
YooLogger.Log($"Create resource package : {packageName}");
|
YooLogger.Log($"Create resource package : {packageName}");
|
||||||
@@ -142,7 +150,7 @@ namespace YooAsset
|
|||||||
/// 检测资源包是否存在
|
/// 检测资源包是否存在
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="packageName">资源包名称</param>
|
/// <param name="packageName">资源包名称</param>
|
||||||
public static bool HasPackage(string packageName)
|
public static bool ContainsPackage(string packageName)
|
||||||
{
|
{
|
||||||
CheckException(packageName);
|
CheckException(packageName);
|
||||||
var package = GetPackageInternal(packageName);
|
var package = GetPackageInternal(packageName);
|
||||||
|
|||||||
@@ -138,20 +138,20 @@ namespace YooAsset
|
|||||||
/// 异步加载原生文件
|
/// 异步加载原生文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assetInfo">资源信息</param>
|
/// <param name="assetInfo">资源信息</param>
|
||||||
public static RawFileHandle LoadRawFileAsync(AssetInfo assetInfo)
|
public static RawFileHandle LoadRawFileAsync(AssetInfo assetInfo, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.LoadRawFileAsync(assetInfo);
|
return _defaultPackage.LoadRawFileAsync(assetInfo, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载原生文件
|
/// 异步加载原生文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
public static RawFileHandle LoadRawFileAsync(string location)
|
public static RawFileHandle LoadRawFileAsync(string location, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.LoadRawFileAsync(location);
|
return _defaultPackage.LoadRawFileAsync(location, priority);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ namespace YooAsset
|
|||||||
/// <param name="sceneMode">场景加载模式</param>
|
/// <param name="sceneMode">场景加载模式</param>
|
||||||
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
||||||
/// <param name="priority">优先级</param>
|
/// <param name="priority">优先级</param>
|
||||||
public static SceneHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, int priority = 100)
|
public static SceneHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, uint priority = 100)
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.LoadSceneAsync(location, sceneMode, suspendLoad, priority);
|
return _defaultPackage.LoadSceneAsync(location, sceneMode, suspendLoad, priority);
|
||||||
@@ -176,7 +176,7 @@ namespace YooAsset
|
|||||||
/// <param name="sceneMode">场景加载模式</param>
|
/// <param name="sceneMode">场景加载模式</param>
|
||||||
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
||||||
/// <param name="priority">优先级</param>
|
/// <param name="priority">优先级</param>
|
||||||
public static SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, int priority = 100)
|
public static SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, uint priority = 100)
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.LoadSceneAsync(assetInfo, sceneMode, suspendLoad, priority);
|
return _defaultPackage.LoadSceneAsync(assetInfo, sceneMode, suspendLoad, priority);
|
||||||
@@ -231,10 +231,10 @@ namespace YooAsset
|
|||||||
/// 异步加载资源对象
|
/// 异步加载资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assetInfo">资源信息</param>
|
/// <param name="assetInfo">资源信息</param>
|
||||||
public static AssetHandle LoadAssetAsync(AssetInfo assetInfo)
|
public static AssetHandle LoadAssetAsync(AssetInfo assetInfo, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.LoadAssetAsync(assetInfo);
|
return _defaultPackage.LoadAssetAsync(assetInfo, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -242,10 +242,10 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TObject">资源类型</typeparam>
|
/// <typeparam name="TObject">资源类型</typeparam>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
public static AssetHandle LoadAssetAsync<TObject>(string location) where TObject : UnityEngine.Object
|
public static AssetHandle LoadAssetAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.LoadAssetAsync<TObject>(location);
|
return _defaultPackage.LoadAssetAsync<TObject>(location, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -253,20 +253,20 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
/// <param name="type">资源类型</param>
|
/// <param name="type">资源类型</param>
|
||||||
public static AssetHandle LoadAssetAsync(string location, System.Type type)
|
public static AssetHandle LoadAssetAsync(string location, System.Type type, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.LoadAssetAsync(location, type);
|
return _defaultPackage.LoadAssetAsync(location, type, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载资源对象
|
/// 异步加载资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
public static AssetHandle LoadAssetAsync(string location)
|
public static AssetHandle LoadAssetAsync(string location, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.LoadAssetAsync(location);
|
return _defaultPackage.LoadAssetAsync(location, priority);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -318,10 +318,10 @@ namespace YooAsset
|
|||||||
/// 异步加载子资源对象
|
/// 异步加载子资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assetInfo">资源信息</param>
|
/// <param name="assetInfo">资源信息</param>
|
||||||
public static SubAssetsHandle LoadSubAssetsAsync(AssetInfo assetInfo)
|
public static SubAssetsHandle LoadSubAssetsAsync(AssetInfo assetInfo, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.LoadSubAssetsAsync(assetInfo);
|
return _defaultPackage.LoadSubAssetsAsync(assetInfo, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -329,10 +329,10 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TObject">资源类型</typeparam>
|
/// <typeparam name="TObject">资源类型</typeparam>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
public static SubAssetsHandle LoadSubAssetsAsync<TObject>(string location) where TObject : UnityEngine.Object
|
public static SubAssetsHandle LoadSubAssetsAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.LoadSubAssetsAsync<TObject>(location);
|
return _defaultPackage.LoadSubAssetsAsync<TObject>(location, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -340,20 +340,20 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
/// <param name="type">子对象类型</param>
|
/// <param name="type">子对象类型</param>
|
||||||
public static SubAssetsHandle LoadSubAssetsAsync(string location, System.Type type)
|
public static SubAssetsHandle LoadSubAssetsAsync(string location, System.Type type, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.LoadSubAssetsAsync(location, type);
|
return _defaultPackage.LoadSubAssetsAsync(location, type, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载子资源对象
|
/// 异步加载子资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
public static SubAssetsHandle LoadSubAssetsAsync(string location)
|
public static SubAssetsHandle LoadSubAssetsAsync(string location, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.LoadSubAssetsAsync(location);
|
return _defaultPackage.LoadSubAssetsAsync(location, priority);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -405,10 +405,10 @@ namespace YooAsset
|
|||||||
/// 异步加载资源包内所有资源对象
|
/// 异步加载资源包内所有资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assetInfo">资源信息</param>
|
/// <param name="assetInfo">资源信息</param>
|
||||||
public static AllAssetsHandle LoadAllAssetsAsync(AssetInfo assetInfo)
|
public static AllAssetsHandle LoadAllAssetsAsync(AssetInfo assetInfo, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.LoadAllAssetsAsync(assetInfo);
|
return _defaultPackage.LoadAllAssetsAsync(assetInfo, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -416,10 +416,10 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TObject">资源类型</typeparam>
|
/// <typeparam name="TObject">资源类型</typeparam>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
public static AllAssetsHandle LoadAllAssetsAsync<TObject>(string location) where TObject : UnityEngine.Object
|
public static AllAssetsHandle LoadAllAssetsAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.LoadAllAssetsAsync<TObject>(location);
|
return _defaultPackage.LoadAllAssetsAsync<TObject>(location, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -427,20 +427,20 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
/// <param name="type">子对象类型</param>
|
/// <param name="type">子对象类型</param>
|
||||||
public static AllAssetsHandle LoadAllAssetsAsync(string location, System.Type type)
|
public static AllAssetsHandle LoadAllAssetsAsync(string location, System.Type type, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.LoadAllAssetsAsync(location, type);
|
return _defaultPackage.LoadAllAssetsAsync(location, type, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载资源包内所有资源对象
|
/// 异步加载资源包内所有资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
public static AllAssetsHandle LoadAllAssetsAsync(string location)
|
public static AllAssetsHandle LoadAllAssetsAsync(string location, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.LoadAllAssetsAsync(location);
|
return _defaultPackage.LoadAllAssetsAsync(location, priority);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public static class ShaderVariantCollector
|
|||||||
CollectResult collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(EBuildMode.DryRunBuild, _packageName);
|
CollectResult collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(EBuildMode.DryRunBuild, _packageName);
|
||||||
foreach (var assetInfo in collectResult.CollectAssets)
|
foreach (var assetInfo in collectResult.CollectAssets)
|
||||||
{
|
{
|
||||||
string[] depends = AssetDatabase.GetDependencies(assetInfo.AssetPath, true);
|
string[] depends = AssetDatabase.GetDependencies(assetInfo.AssetInfo.AssetPath, true);
|
||||||
foreach (var dependAsset in depends)
|
foreach (var dependAsset in depends)
|
||||||
{
|
{
|
||||||
if (allAssets.Contains(dependAsset) == false)
|
if (allAssets.Contains(dependAsset) == false)
|
||||||
|
|||||||
@@ -100,11 +100,11 @@ MonoBehaviour:
|
|||||||
FilterRuleName: CollectAll
|
FilterRuleName: CollectAll
|
||||||
AssetTags:
|
AssetTags:
|
||||||
UserData:
|
UserData:
|
||||||
- CollectPath: Assets/Samples/Space Shooter/GameRes/UISprite
|
- CollectPath: Assets/Samples/Space Shooter/GameRes/UIAtlas
|
||||||
CollectorGUID: 01865ad6f7c806147b6cb37f2d83bc96
|
CollectorGUID: 80caf8bc3d0ac5b48a5cab7765a68205
|
||||||
CollectorType: 0
|
CollectorType: 0
|
||||||
AddressRuleName: AddressByFileName
|
AddressRuleName: AddressByFileName
|
||||||
PackRuleName: PackTopDirectory
|
PackRuleName: PackSeparately
|
||||||
FilterRuleName: CollectAll
|
FilterRuleName: CollectAll
|
||||||
AssetTags:
|
AssetTags:
|
||||||
UserData:
|
UserData:
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
@@ -3,7 +3,7 @@ guid: 9871e4d5e19cea6419d057b79ce1a1a8
|
|||||||
TextureImporter:
|
TextureImporter:
|
||||||
internalIDToNameTable: []
|
internalIDToNameTable: []
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 11
|
serializedVersion: 12
|
||||||
mipmaps:
|
mipmaps:
|
||||||
mipMapMode: 0
|
mipMapMode: 0
|
||||||
enableMipMap: 0
|
enableMipMap: 0
|
||||||
@@ -23,6 +23,7 @@ TextureImporter:
|
|||||||
isReadable: 0
|
isReadable: 0
|
||||||
streamingMipmaps: 0
|
streamingMipmaps: 0
|
||||||
streamingMipmapsPriority: 0
|
streamingMipmapsPriority: 0
|
||||||
|
vTOnly: 0
|
||||||
grayScaleToAlpha: 0
|
grayScaleToAlpha: 0
|
||||||
generateCubemap: 6
|
generateCubemap: 6
|
||||||
cubemapConvolution: 0
|
cubemapConvolution: 0
|
||||||
@@ -54,10 +55,14 @@ TextureImporter:
|
|||||||
textureType: 8
|
textureType: 8
|
||||||
textureShape: 1
|
textureShape: 1
|
||||||
singleChannelComponent: 0
|
singleChannelComponent: 0
|
||||||
|
flipbookRows: 1
|
||||||
|
flipbookColumns: 1
|
||||||
maxTextureSizeSet: 0
|
maxTextureSizeSet: 0
|
||||||
compressionQualitySet: 0
|
compressionQualitySet: 0
|
||||||
textureFormatSet: 0
|
textureFormatSet: 0
|
||||||
|
ignorePngGamma: 0
|
||||||
applyGammaDecoding: 1
|
applyGammaDecoding: 1
|
||||||
|
cookieLightType: 1
|
||||||
platformSettings:
|
platformSettings:
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
buildTarget: DefaultTexturePlatform
|
buildTarget: DefaultTexturePlatform
|
||||||
@@ -95,6 +100,18 @@ TextureImporter:
|
|||||||
overridden: 0
|
overridden: 0
|
||||||
androidETC2FallbackOverride: 0
|
androidETC2FallbackOverride: 0
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: iPhone
|
||||||
|
maxTextureSize: 1024
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
spriteSheet:
|
spriteSheet:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
sprites: []
|
sprites: []
|
||||||
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
@@ -3,7 +3,7 @@ guid: b1e9e5e05f0067f469e748e46985c269
|
|||||||
TextureImporter:
|
TextureImporter:
|
||||||
internalIDToNameTable: []
|
internalIDToNameTable: []
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 11
|
serializedVersion: 12
|
||||||
mipmaps:
|
mipmaps:
|
||||||
mipMapMode: 0
|
mipMapMode: 0
|
||||||
enableMipMap: 0
|
enableMipMap: 0
|
||||||
@@ -23,6 +23,7 @@ TextureImporter:
|
|||||||
isReadable: 0
|
isReadable: 0
|
||||||
streamingMipmaps: 0
|
streamingMipmaps: 0
|
||||||
streamingMipmapsPriority: 0
|
streamingMipmapsPriority: 0
|
||||||
|
vTOnly: 0
|
||||||
grayScaleToAlpha: 0
|
grayScaleToAlpha: 0
|
||||||
generateCubemap: 6
|
generateCubemap: 6
|
||||||
cubemapConvolution: 0
|
cubemapConvolution: 0
|
||||||
@@ -54,10 +55,14 @@ TextureImporter:
|
|||||||
textureType: 8
|
textureType: 8
|
||||||
textureShape: 1
|
textureShape: 1
|
||||||
singleChannelComponent: 0
|
singleChannelComponent: 0
|
||||||
|
flipbookRows: 1
|
||||||
|
flipbookColumns: 1
|
||||||
maxTextureSizeSet: 0
|
maxTextureSizeSet: 0
|
||||||
compressionQualitySet: 0
|
compressionQualitySet: 0
|
||||||
textureFormatSet: 0
|
textureFormatSet: 0
|
||||||
|
ignorePngGamma: 0
|
||||||
applyGammaDecoding: 1
|
applyGammaDecoding: 1
|
||||||
|
cookieLightType: 1
|
||||||
platformSettings:
|
platformSettings:
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
buildTarget: DefaultTexturePlatform
|
buildTarget: DefaultTexturePlatform
|
||||||
@@ -95,6 +100,18 @@ TextureImporter:
|
|||||||
overridden: 0
|
overridden: 0
|
||||||
androidETC2FallbackOverride: 0
|
androidETC2FallbackOverride: 0
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: iPhone
|
||||||
|
maxTextureSize: 1024
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
spriteSheet:
|
spriteSheet:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
sprites: []
|
sprites: []
|
||||||
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user