Compare commits

...

21 Commits

Author SHA1 Message Date
何冠峰
748e74e515 Update CHANGELOG.md 2024-12-30 17:13:07 +08:00
何冠峰
d1d3ad9869 Update package.json 2024-12-30 17:12:59 +08:00
何冠峰
f9b72a22ae fix #423 2024-12-30 16:27:50 +08:00
何冠峰
766cf90a19 fix #422 2024-12-30 10:27:04 +08:00
何冠峰
8a2dc86cf7 update code summary 2024-12-27 18:37:29 +08:00
何冠峰
5ca54b88fa update download system 2024-12-27 17:51:21 +08:00
何冠峰
7257c8778d Merge pull request #332 from Pro-Ly/dev
fix url path special cases
2024-12-27 17:45:00 +08:00
何冠峰
dc21696ae1 update extension sample
新增示例代码HandleBaseExtension
2024-12-27 17:34:22 +08:00
何冠峰
7f566e5388 update extension sample
重新整理目录结构
2024-12-27 17:29:00 +08:00
何冠峰
fe352ceb84 update operation system
新增字段PackageName
2024-12-27 17:23:55 +08:00
何冠峰
10750a0123 update space shooter 2024-12-27 17:08:59 +08:00
何冠峰
f2e6da649b update resource package
重构了下载器的委托方法
2024-12-27 17:08:39 +08:00
何冠峰
9737cd06dd Merge pull request #392 from absences/newv
upgrade deprecated event in newer version
2024-12-27 16:06:24 +08:00
何冠峰
df8cf4d9ca update extension sample 2024-12-27 16:04:01 +08:00
何冠峰
36b4cbb8c2 Update DefaultAddressRule.cs 2024-12-27 16:03:47 +08:00
何冠峰
bae84f65da Merge pull request #370 from BoysheO/patch-1
append an addressRule
2024-12-27 15:50:14 +08:00
何冠峰
313ec2d100 Merge pull request #418 from GodChouyu/dev
Fix a bug when initializing DefaultWebRemoteFileSystem.
2024-12-27 15:16:38 +08:00
GodChouyu
25c5683a09 Fix a bug when initializing DefaultWebRemoteFileSystem. 2024-12-27 10:16:57 +08:00
unknown
02250c3352 upgrade deprecated method in newer version 2024-11-12 14:40:49 +08:00
BoysheO
9e2030c83d Update DefaultAddressRule.cs
添加一个寻址规则,效果极好
2024-09-10 11:36:46 +08:00
Pro-Ly
be3fa0b688 fix url path special cases 2024-07-31 23:28:47 +08:00
96 changed files with 423 additions and 77 deletions

View File

@@ -2,6 +2,39 @@
All notable changes to this package will be documented in this file.
## [2.2.7-preview] - 2024-12-30
### Improvements
- 重构了下载器的委托方法。
- YooAssetSettings配置文件新增Package Manifest Prefix参数。
```csharp
/// <summary>
/// 资源清单前缀名称(默认为空)
/// </summary>
public string PackageManifestPrefix = string.Empty;
```
### Fixed
- (#422) 修复了同步加载场景的NotImplementedException异常报错。
- (#418) 修复了web远程文件系统初始化不正确的问题
- (#392) 修复了引擎版本代码兼容相关的警告。
- (#332) 修复了当用户的设备中有特殊字符时URL路径无法被正确识别的问题。
### Added
- 新增代码字段AsyncOperationBase.PackageName
### Changed
- 重命名DownloaderOperation.OnDownloadOver()方法为DownloaderFinish()
- 重命名DownloaderOperation.OnDownloadProgress()方法为DownloadUpdate()
- 重命名DownloaderOperation.OnDownloadError()方法为DownloadError()
- 重命名DownloaderOperation.OnStartDownloadFile()方法为DownloadFileBegin()
## [2.2.6-preview] - 2024-12-27
### Improvements

View File

@@ -116,7 +116,7 @@ namespace YooAsset.Editor
buildReport.IndependAssets = new List<ReportIndependAsset>(buildMapContext.IndependAssets);
// 序列化文件
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
string fileName = YooAssetSettingsData.GetBuildReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
string filePath = $"{packageOutputDirectory}/{fileName}";
BuildReport.Serialize(filePath, buildReport);
BuildLogger.Log($"Create build report file: {filePath}");

View File

@@ -205,7 +205,9 @@ namespace YooAsset.Editor
_packageListView = root.Q<ListView>("PackageListView");
_packageListView.makeItem = MakePackageListViewItem;
_packageListView.bindItem = BindPackageListViewItem;
#if UNITY_2020_1_OR_NEWER
#if UNITY_2022_3_OR_NEWER
_packageListView.selectionChanged += PackageListView_onSelectionChange;
#elif UNITY_2020_1_OR_NEWER
_packageListView.onSelectionChange += PackageListView_onSelectionChange;
#else
_packageListView.onSelectionChanged += PackageListView_onSelectionChange;
@@ -250,7 +252,9 @@ namespace YooAsset.Editor
_groupListView = root.Q<ListView>("GroupListView");
_groupListView.makeItem = MakeGroupListViewItem;
_groupListView.bindItem = BindGroupListViewItem;
#if UNITY_2020_1_OR_NEWER
#if UNITY_2022_3_OR_NEWER
_groupListView.selectionChanged += GroupListView_onSelectionChange;
#elif UNITY_2020_1_OR_NEWER
_groupListView.onSelectionChange += GroupListView_onSelectionChange;
#else
_groupListView.onSelectionChanged += GroupListView_onSelectionChange;

View File

@@ -35,7 +35,9 @@ namespace YooAsset.Editor
_assetListView = _root.Q<ListView>("TopListView");
_assetListView.makeItem = MakeAssetListViewItem;
_assetListView.bindItem = BindAssetListViewItem;
#if UNITY_2020_1_OR_NEWER
#if UNITY_2022_3_OR_NEWER
_assetListView.selectionChanged += AssetListView_onSelectionChange;
#elif UNITY_2020_1_OR_NEWER
_assetListView.onSelectionChange += AssetListView_onSelectionChange;
#else
_assetListView.onSelectionChanged += AssetListView_onSelectionChange;

View File

@@ -35,7 +35,9 @@ namespace YooAsset.Editor
_bundleListView = _root.Q<ListView>("TopListView");
_bundleListView.makeItem = MakeBundleListViewItem;
_bundleListView.bindItem = BindBundleListViewItem;
#if UNITY_2020_1_OR_NEWER
#if UNITY_2022_3_OR_NEWER
_bundleListView.selectionChanged += BundleListView_onSelectionChange;
#elif UNITY_2020_1_OR_NEWER
_bundleListView.onSelectionChange += BundleListView_onSelectionChange;
#else
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange;

View File

@@ -58,7 +58,9 @@ namespace YooAsset.Editor
_assetListView = _root.Q<ListView>("TopListView");
_assetListView.makeItem = MakeAssetListViewItem;
_assetListView.bindItem = BindAssetListViewItem;
#if UNITY_2020_1_OR_NEWER
#if UNITY_2022_3_OR_NEWER
_assetListView.selectionChanged += AssetListView_onSelectionChange;
#elif UNITY_2020_1_OR_NEWER
_assetListView.onSelectionChange += AssetListView_onSelectionChange;
#else
_assetListView.onSelectionChanged += AssetListView_onSelectionChange;

View File

@@ -66,7 +66,9 @@ namespace YooAsset.Editor
_bundleListView = _root.Q<ListView>("TopListView");
_bundleListView.makeItem = MakeBundleListViewItem;
_bundleListView.bindItem = BindBundleListViewItem;
#if UNITY_2020_1_OR_NEWER
#if UNITY_2022_3_OR_NEWER
_bundleListView.selectionChanged += BundleListView_onSelectionChange;
#elif UNITY_2020_1_OR_NEWER
_bundleListView.onSelectionChange += BundleListView_onSelectionChange;
#else
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange;

View File

@@ -25,26 +25,32 @@ namespace YooAsset
/// </summary>
public static string ConvertToWWWPath(string path)
{
string url;
// 获取对应平台的URL地址
#if UNITY_EDITOR
return StringUtility.Format("file:///{0}", path);
url = StringUtility.Format("file:///{0}", path);
#elif UNITY_WEBGL
return path;
url = path;
#elif UNITY_IPHONE
return StringUtility.Format("file://{0}", path);
url = StringUtility.Format("file://{0}", path);
#elif UNITY_ANDROID
if (path.StartsWith("jar:file://"))
return path;
url = path;
else
return StringUtility.Format("jar:file://{0}", path);
url = StringUtility.Format("jar:file://{0}", path);
#elif UNITY_STANDALONE_OSX
return new System.Uri(path).ToString();
url = new System.Uri(path).ToString();
#elif UNITY_STANDALONE
return StringUtility.Format("file:///{0}", path);
url = StringUtility.Format("file:///{0}", path);
#elif UNITY_OPENHARMONY
return StringUtility.Format("file://{0}", path);
url = StringUtility.Format("file://{0}", path);
#else
throw new System.NotImplementedException();
throw new System.NotImplementedException();
#endif
// For some special cases when users have special characters in their devices, url paths can not be identified correctly.
return url.Replace("+", "%2B").Replace("#", "%23").Replace("?", "%3F");
}
/// <summary>
@@ -52,7 +58,7 @@ namespace YooAsset
/// </summary>
public static bool IsRequestLocalFile(string url)
{
//TODO : UNITY_STANDALONE_OSX平台目前无法确定
//TODO UNITY_STANDALONE_OSX平台目前无法确定
if (url.StartsWith("file:"))
return true;
if (url.StartsWith("jar:file:"))

View File

@@ -71,7 +71,7 @@ namespace YooAsset
{
if (IsWaitForAsyncComplete)
{
// 场景加载无法强制异步转同步
//注意:场景加载无法强制异步转同步
YooLogger.Error("The scene is loading asyn !");
}
else
@@ -104,6 +104,11 @@ namespace YooAsset
}
}
}
internal override void InternalWaitForAsyncComplete()
{
//TODO 场景加载不支持异步转同步,为了支持同步加载方法需要实现该方法!
InternalOnUpdate();
}
public override void UnSuspendLoad()
{
_suspendLoad = false;

View File

@@ -76,7 +76,7 @@ namespace YooAsset
{
if (IsWaitForAsyncComplete)
{
// 场景加载无法强制异步转同步
// 注意:场景加载无法强制异步转同步
YooLogger.Error("The scene is loading asyn !");
}
else
@@ -110,6 +110,11 @@ namespace YooAsset
}
#endif
}
internal override void InternalWaitForAsyncComplete()
{
//TODO 场景加载不支持异步转同步,为了支持同步加载方法需要实现该方法!
InternalOnUpdate();
}
public override void UnSuspendLoad()
{
_suspendLoad = false;

View File

@@ -133,7 +133,7 @@ namespace YooAsset
// 重新尝试下载
if (_steps == ESteps.TryAgain)
{
//TODO : 拷贝本地文件失败后不再尝试!
//TODO 拷贝本地文件失败后不再尝试!
if (_isReuqestLocalFile)
{
Status = EOperationStatus.Failed;
@@ -166,7 +166,7 @@ namespace YooAsset
}
internal override void InternalWaitForAsyncComplete()
{
//TODO : 防止下载器挂起陷入无限死循环!
//TODO 防止下载器挂起陷入无限死循环!
if (_steps == ESteps.None)
{
InternalOnStart();
@@ -174,7 +174,7 @@ namespace YooAsset
while (true)
{
//TODO : 如果是导入或解压本地文件,执行等待完毕
//TODO 如果是导入或解压本地文件,执行等待完毕
if (_isReuqestLocalFile)
{
InternalOnUpdate();

View File

@@ -155,7 +155,7 @@ namespace YooAsset
// 重新尝试下载
if (_steps == ESteps.TryAgain)
{
//TODO : 拷贝本地文件失败后不再尝试!
//TODO 拷贝本地文件失败后不再尝试!
if (_isReuqestLocalFile)
{
Status = EOperationStatus.Failed;
@@ -188,7 +188,7 @@ namespace YooAsset
}
internal override void InternalWaitForAsyncComplete()
{
//TODO : 防止下载器挂起陷入无限死循环!
//TODO 防止下载器挂起陷入无限死循环!
if (_steps == ESteps.None)
{
InternalOnStart();
@@ -196,7 +196,7 @@ namespace YooAsset
while (true)
{
//TODO : 如果是导入或解压本地文件,执行等待完毕
//TODO 如果是导入或解压本地文件,执行等待完毕
if (_isReuqestLocalFile)
{
InternalOnUpdate();

View File

@@ -70,7 +70,7 @@ namespace YooAsset
{
while (true)
{
//TODO : 等待子线程验证文件完毕,该操作会挂起主线程
//TODO 等待子线程验证文件完毕,该操作会挂起主线程
InternalOnUpdate();
if (IsDone)
break;

View File

@@ -129,7 +129,7 @@ namespace YooAsset
/// <param name="disableUnityWebCache">禁用Unity的网络缓存</param>
public static FileSystemParameters CreateDefaultWebRemoteFileSystemParameters(IRemoteServices remoteServices, bool disableUnityWebCache = false)
{
string fileSystemClass = typeof(DefaultWebServerFileSystem).FullName;
string fileSystemClass = typeof(DefaultWebRemoteFileSystem).FullName;
var fileSystemParams = new FileSystemParameters(fileSystemClass, null);
fileSystemParams.AddParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
fileSystemParams.AddParameter(FileSystemParametersDefine.DISABLE_UNITY_WEB_CACHE, disableUnityWebCache);

View File

@@ -42,6 +42,17 @@ namespace YooAsset
/// </summary>
public float Progress { get; protected set; }
/// <summary>
/// 所属包裹名称
/// </summary>
public string PackageName
{
get
{
return _packageName;
}
}
/// <summary>
/// 是否已经完成
/// </summary>
@@ -98,10 +109,6 @@ namespace YooAsset
throw new System.NotImplementedException(this.GetType().Name);
}
internal string GetPackageName()
{
return _packageName;
}
internal void SetPackageName(string packageName)
{
_packageName = packageName;

View File

@@ -112,7 +112,7 @@ namespace YooAsset
// 终止临时队列里的任务
foreach (var operation in _newList)
{
if (operation.GetPackageName() == packageName)
if (operation.PackageName == packageName)
{
operation.SetAbort();
}
@@ -121,7 +121,7 @@ namespace YooAsset
// 终止正在进行的任务
foreach (var operation in _operations)
{
if (operation.GetPackageName() == packageName)
if (operation.PackageName == packageName)
{
operation.SetAbort();
}

View File

@@ -74,7 +74,7 @@ namespace YooAsset
}
#if UNITY_2023_3_OR_NEWER
//TODO : 官方BUG
//TODO 官方BUG
// BUG环境Windows平台Unity2022.3.41f1版本,编辑器模式。
// BUG描述异步实例化Prefab预制体有概率丢失Mono脚本里序列化的数组里某个成员
//_steps = ESteps.CloneAsync;

View File

@@ -0,0 +1,97 @@

namespace YooAsset
{
/// <summary>
/// 下载器结束
/// </summary>
public struct DownloaderFinishData
{
/// <summary>
/// 所属包裹名称
/// </summary>
public string PackageName;
/// <summary>
/// 是否成功
/// </summary>
public bool Succeed;
}
/// <summary>
/// 下载器相关的更新数据
/// </summary>
public struct DownloadUpdateData
{
/// <summary>
/// 所属包裹名称
/// </summary>
public string PackageName;
/// <summary>
/// 下载进度 (0-1f)
/// </summary>
public float Progress;
/// <summary>
/// 下载文件总数
/// </summary>
public int TotalDownloadCount;
/// <summary>
/// 当前完成的下载文件数量
/// </summary>
public int CurrentDownloadCount;
/// <summary>
/// 下载数据总大小(单位:字节)
/// </summary>
public long TotalDownloadBytes;
/// <summary>
/// 当前完成的下载数据大小(单位:字节)
/// </summary>
public long CurrentDownloadBytes;
}
/// <summary>
/// 下载器相关的错误数据
/// </summary>
public struct DownloadErrorData
{
/// <summary>
/// 所属包裹名称
/// </summary>
public string PackageName;
/// <summary>
/// 下载失败的文件名称
/// </summary>
public string FileName;
/// <summary>
/// 错误信息
/// </summary>
public string ErrorInfo;
}
/// <summary>
/// 下载器相关的文件数据
/// </summary>
public struct DownloadFileData
{
/// <summary>
/// 所属包裹名称
/// </summary>
public string PackageName;
/// <summary>
/// 下载的文件名称
/// </summary>
public string FileName;
/// <summary>
/// 下载的文件大小
/// </summary>
public long FileSize;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6602c4be2ef295546b7bbb328de8fb0c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -15,10 +15,27 @@ namespace YooAsset
private const int MAX_LOADER_COUNT = 64;
public delegate void OnDownloadOver(bool isSucceed);
public delegate void OnDownloadProgress(int totalDownloadCount, int currentDownloadCount, long totalDownloadBytes, long currentDownloadBytes);
public delegate void OnDownloadError(string fileName, string error);
public delegate void OnStartDownloadFile(string fileName, long sizeBytes);
#region
/// <summary>
/// 下载器结束
/// </summary>
public delegate void DownloaderFinish(DownloaderFinishData data);
/// <summary>
/// 下载进度更新
/// </summary>
public delegate void DownloadUpdate(DownloadUpdateData data);
/// <summary>
/// 下载发生错误
/// </summary>
public delegate void DownloadError(DownloadErrorData data);
/// <summary>
/// 开始下载某个文件
/// </summary>
public delegate void DownloadFileBegin(DownloadFileData data);
#endregion
private readonly string _packageName;
private readonly int _downloadingMaxNumber;
@@ -67,23 +84,23 @@ namespace YooAsset
/// <summary>
/// 当下载器结束(无论成功或失败)
/// </summary>
public OnDownloadOver OnDownloadOverCallback { set; get; }
public DownloaderFinish DownloadFinishCallback { set; get; }
/// <summary>
/// 当下载进度发生变化
/// </summary>
public OnDownloadProgress OnDownloadProgressCallback { set; get; }
public DownloadUpdate DownloadUpdateCallback { set; get; }
/// <summary>
/// 当某个文件下载失败
/// 当下载器发生错误
/// </summary>
public OnDownloadError OnDownloadErrorCallback { set; get; }
public DownloadError DownloadErrorCallback { set; get; }
/// <summary>
/// 当开始下载某个文件
/// </summary>
public OnStartDownloadFile OnStartDownloadFileCallback { set; get; }
public DownloadFileBegin DownloadFileBeginCallback { set; get; }
internal DownloaderOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
{
@@ -160,7 +177,18 @@ namespace YooAsset
_lastDownloadBytes = downloadBytes;
_lastDownloadCount = _cachedDownloadCount;
Progress = (float)_lastDownloadBytes / TotalDownloadBytes;
OnDownloadProgressCallback?.Invoke(TotalDownloadCount, _lastDownloadCount, TotalDownloadBytes, _lastDownloadBytes);
if (DownloadUpdateCallback != null)
{
var data = new DownloadUpdateData();
data.PackageName = _packageName;
data.Progress = Progress;
data.TotalDownloadCount = TotalDownloadCount;
data.CurrentDownloadCount = _lastDownloadCount;
data.TotalDownloadBytes = TotalDownloadBytes;
data.CurrentDownloadBytes = _lastDownloadBytes;
DownloadUpdateCallback.Invoke(data);
}
}
// 动态创建新的下载器到最大数量限制
@@ -177,7 +205,15 @@ namespace YooAsset
var downloader = bundleInfo.CreateDownloader(_failedTryAgain, _timeout);
_downloaders.Add(downloader);
_bundleInfoList.RemoveAt(index);
OnStartDownloadFileCallback?.Invoke(bundleInfo.Bundle.BundleName, bundleInfo.Bundle.FileSize);
if (DownloadFileBeginCallback != null)
{
var data = new DownloadFileData();
data.PackageName = _packageName;
data.FileName = bundleInfo.Bundle.BundleName;
data.FileSize = bundleInfo.Bundle.FileSize;
DownloadFileBeginCallback.Invoke(data);
}
}
}
@@ -191,15 +227,37 @@ namespace YooAsset
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"Failed to download file : {bundleName}";
OnDownloadErrorCallback?.Invoke(bundleName, failedDownloader.Error);
OnDownloadOverCallback?.Invoke(false);
if (DownloadErrorCallback != null)
{
var data = new DownloadErrorData();
data.PackageName = _packageName;
data.FileName = bundleName;
data.ErrorInfo = failedDownloader.Error;
DownloadErrorCallback.Invoke(data);
}
if (DownloadFinishCallback != null)
{
var data = new DownloaderFinishData();
data.PackageName = _packageName;
data.Succeed = false;
DownloadFinishCallback.Invoke(data);
}
}
else
{
// 结算成功
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
OnDownloadOverCallback?.Invoke(true);
if (DownloadFinishCallback != null)
{
var data = new DownloaderFinishData();
data.PackageName = _packageName;
data.Succeed = true;
DownloadFinishCallback.Invoke(data);
}
}
}
}

View File

@@ -385,7 +385,7 @@ namespace YooAsset
if (_steps == ESteps.InitWebRemoteFileSystem)
{
if (_initWebRemoteFileSystemOp == null)
_initWebRemoteFileSystemOp = _impl.WebServerFileSystem.InitializeFileSystemAsync();
_initWebRemoteFileSystemOp = _impl.WebRemoteFileSystem.InitializeFileSystemAsync();
Progress = _initWebRemoteFileSystemOp.Progress;
if (_initWebRemoteFileSystemOp.IsDone == false)

View File

@@ -209,7 +209,7 @@ namespace YooAsset
}
/// <summary>
/// 向网络端请求最新的资源版本
/// 请求最新的资源版本
/// </summary>
/// <param name="appendTimeTicks">在URL末尾添加时间戳</param>
/// <param name="timeout">超时时间默认值60秒</param>
@@ -220,9 +220,9 @@ namespace YooAsset
}
/// <summary>
/// 向网络端请求并更新清单
/// 加载指定版本的资源清单
/// </summary>
/// <param name="packageVersion">更新的包裹版本</param>
/// <param name="packageVersion">包裹版本</param>
/// <param name="timeout">超时时间默认值60秒</param>
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, int timeout = 60)
{
@@ -240,7 +240,7 @@ namespace YooAsset
/// <summary>
/// 预下载指定版本的包裹资源
/// </summary>
/// <param name="packageVersion">下载的包裹版本</param>
/// <param name="packageVersion">包裹版本</param>
/// <param name="timeout">超时时间默认值60秒</param>
public PreDownloadContentOperation PreDownloadContentAsync(string packageVersion, int timeout = 60)
{
@@ -272,7 +272,7 @@ namespace YooAsset
#region
/// <summary>
/// 获取当前激活包裹的版本信息
/// 获取当前加载包裹的版本信息
/// </summary>
public string GetPackageVersion()
{
@@ -281,7 +281,7 @@ namespace YooAsset
}
/// <summary>
/// 获取当前激活包裹的备注信息
/// 获取当前加载包裹的备注信息
/// </summary>
public string GetPackageNote()
{
@@ -290,7 +290,7 @@ namespace YooAsset
}
/// <summary>
/// 获取当前激活包裹的详细信息
/// 获取当前加载包裹的详细信息
/// </summary>
public PackageDetails GetPackageDetails()
{

View File

@@ -6,10 +6,15 @@ namespace YooAsset
internal class YooAssetSettings : ScriptableObject
{
/// <summary>
/// 默认的YooAsset文件夹名称
/// YooAsset文件夹名称
/// </summary>
public string DefaultYooFolderName = "yoo";
/// <summary>
/// 资源清单前缀名称(默认为空)
/// </summary>
public string PackageManifestPrefix = string.Empty;
/// <summary>
/// 清单文件头标记

View File

@@ -36,9 +36,12 @@ namespace YooAsset
/// <summary>
/// 获取构建报告文件名
/// </summary>
public static string GetReportFileName(string packageName, string packageVersion)
public static string GetBuildReportFileName(string packageName, string packageVersion)
{
return $"{packageName}_{packageVersion}.report";
if (string.IsNullOrEmpty(Setting.PackageManifestPrefix))
return $"{packageName}_{packageVersion}.report";
else
return $"{Setting.PackageManifestPrefix}_{packageName}_{packageVersion}.report";
}
/// <summary>
@@ -46,7 +49,10 @@ namespace YooAsset
/// </summary>
public static string GetManifestBinaryFileName(string packageName, string packageVersion)
{
return $"{packageName}_{packageVersion}.bytes";
if (string.IsNullOrEmpty(Setting.PackageManifestPrefix))
return $"{packageName}_{packageVersion}.bytes";
else
return $"{Setting.PackageManifestPrefix}_{packageName}_{packageVersion}.bytes";
}
/// <summary>
@@ -54,7 +60,10 @@ namespace YooAsset
/// </summary>
public static string GetManifestJsonFileName(string packageName, string packageVersion)
{
return $"{packageName}_{packageVersion}.json";
if (string.IsNullOrEmpty(Setting.PackageManifestPrefix))
return $"{packageName}_{packageVersion}.json";
else
return $"{Setting.PackageManifestPrefix}_{packageName}_{packageVersion}.json";
}
/// <summary>
@@ -62,7 +71,10 @@ namespace YooAsset
/// </summary>
public static string GetPackageHashFileName(string packageName, string packageVersion)
{
return $"{packageName}_{packageVersion}.hash";
if (string.IsNullOrEmpty(Setting.PackageManifestPrefix))
return $"{packageName}_{packageVersion}.hash";
else
return $"{Setting.PackageManifestPrefix}_{packageName}_{packageVersion}.hash";
}
/// <summary>
@@ -70,7 +82,10 @@ namespace YooAsset
/// </summary>
public static string GetPackageVersionFileName(string packageName)
{
return $"{packageName}.version";
if (string.IsNullOrEmpty(Setting.PackageManifestPrefix))
return $"{packageName}.version";
else
return $"{Setting.PackageManifestPrefix}_{packageName}.version";
}
#region

View File

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

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using YooAsset.Editor;
[DisplayName("定位地址: 文件名.智能尾缀")]
public class AddressByFileNameAndExt : IAddressRule
{
public string GetAssetAddress(AddressRuleData data)
{
var ext = Path.GetExtension(data.AssetPath);
if (ext == ".asset")
{
var a = UnityEditor.AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(data.AssetPath);
if (a == null) return ".errortype";
var type = a.GetType();
var dt = Path.GetFileNameWithoutExtension(data.AssetPath);
return dt + $".{type.Name.ToLowerInvariant()}";
}
return Path.GetFileName(data.AssetPath);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 73aae15a0e1aec742a7e8f05755a2013
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using YooAsset;
public static class HandleBaseExtension
{
public static bool IsSucceed(this HandleBase thisHandle)
{
return thisHandle.IsDone && thisHandle.Status == EOperationStatus.Succeed;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 03c367406c5062c41ba3290201be20c2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

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

View File

@@ -1,4 +1,5 @@
using UniFramework.Event;
using YooAsset;
public class PatchEventDefine
{
@@ -36,7 +37,7 @@ public class PatchEventDefine
{
public int TotalCount;
public long TotalSizeBytes;
public static void SendEventMessage(int totalCount, long totalSizeBytes)
{
var msg = new FoundUpdateFiles();
@@ -55,14 +56,14 @@ public class PatchEventDefine
public int CurrentDownloadCount;
public long TotalDownloadSizeBytes;
public long CurrentDownloadSizeBytes;
public static void SendEventMessage(int totalDownloadCount, int currentDownloadCount, long totalDownloadSizeBytes, long currentDownloadSizeBytes)
public static void SendEventMessage(DownloadUpdateData updateData)
{
var msg = new DownloadProgressUpdate();
msg.TotalDownloadCount = totalDownloadCount;
msg.CurrentDownloadCount = currentDownloadCount;
msg.TotalDownloadSizeBytes = totalDownloadSizeBytes;
msg.CurrentDownloadSizeBytes = currentDownloadSizeBytes;
msg.TotalDownloadCount = updateData.TotalDownloadCount;
msg.CurrentDownloadCount = updateData.CurrentDownloadCount;
msg.TotalDownloadSizeBytes = updateData.TotalDownloadBytes;
msg.CurrentDownloadSizeBytes = updateData.CurrentDownloadBytes;
UniEvent.SendMessage(msg);
}
}
@@ -99,11 +100,11 @@ public class PatchEventDefine
public string FileName;
public string Error;
public static void SendEventMessage(string fileName, string error)
public static void SendEventMessage(DownloadErrorData errorData)
{
var msg = new WebFileDownloadFailed();
msg.FileName = fileName;
msg.Error = error;
msg.FileName = errorData.FileName;
msg.Error = errorData.ErrorInfo;
UniEvent.SendMessage(msg);
}
}

View File

@@ -29,8 +29,8 @@ public class FsmDownloadPackageFiles : IStateNode
private IEnumerator BeginDownload()
{
var downloader = (ResourceDownloaderOperation)_machine.GetBlackboardValue("Downloader");
downloader.OnDownloadErrorCallback = PatchEventDefine.WebFileDownloadFailed.SendEventMessage;
downloader.OnDownloadProgressCallback = PatchEventDefine.DownloadProgressUpdate.SendEventMessage;
downloader.DownloadErrorCallback = PatchEventDefine.WebFileDownloadFailed.SendEventMessage;
downloader.DownloadUpdateCallback = PatchEventDefine.DownloadProgressUpdate.SendEventMessage;
downloader.BeginDownload();
yield return downloader;

View File

@@ -1,7 +1,7 @@
{
"name": "com.tuyoogame.yooasset",
"displayName": "YooAsset",
"version": "2.2.6-preview",
"version": "2.2.7-preview",
"unity": "2019.4",
"description": "unity3d resources management system.",
"author": {