Compare commits

...

8 Commits

Author SHA1 Message Date
Pro-Ly c121bcdf9a
Merge be3fa0b688 into e76a782a80 2024-12-11 10:34:11 +08:00
何冠峰 e76a782a80 Update ResourcePackage.cs 2024-12-11 10:04:33 +08:00
何冠峰 0f7c5b2564 Update ResourcePackage.cs 2024-12-10 18:41:09 +08:00
何冠峰 fcf0f34d5a update resource manager 2024-12-10 18:00:13 +08:00
何冠峰 acf2301028 refactor : wait for sync complete 2024-12-10 16:48:08 +08:00
何冠峰 9bc0577423 Update DefaultIgnoreRule.cs
忽略Gizmos和编辑器资源
2024-12-10 15:18:34 +08:00
何冠峰 d037ce5b86 Update LoadBundleFileOperation.cs 2024-12-10 15:17:49 +08:00
Pro-Ly be3fa0b688 fix url path special cases 2024-07-31 23:28:47 +08:00
15 changed files with 101 additions and 33 deletions

View File

@ -33,6 +33,14 @@ namespace YooAsset.Editor
if (AssetDatabase.IsValidFolder(assetInfo.AssetPath))
return true;
// 忽略编辑器图标资源
if (assetInfo.AssetPath.Contains("/Gizmos/"))
return true;
// 忽略编辑器专属资源
if (assetInfo.AssetPath.Contains("/Editor/") || assetInfo.AssetPath.Contains("/Editor Resources/"))
return true;
// 忽略编辑器下的类型资源
if (assetInfo.AssetType == typeof(LightingDataAsset))
return true;

View File

@ -25,26 +25,28 @@ namespace YooAsset
/// </summary>
public static string ConvertToWWWPath(string path)
{
string urlPath;
#if UNITY_EDITOR
return StringUtility.Format("file:///{0}", path);
urlPath = StringUtility.Format("file:///{0}", path);
#elif UNITY_WEBGL
return path;
urlPath = path;
#elif UNITY_IPHONE
return StringUtility.Format("file://{0}", path);
urlPath = StringUtility.Format("file://{0}", path);
#elif UNITY_ANDROID
if (path.StartsWith("jar:file://"))
return path;
urlPath = path;
else
return StringUtility.Format("jar:file://{0}", path);
urlPath = StringUtility.Format("jar:file://{0}", path);
#elif UNITY_STANDALONE_OSX
return new System.Uri(path).ToString();
urlPath = new System.Uri(path).ToString();
#elif UNITY_STANDALONE
return StringUtility.Format("file:///{0}", path);
urlPath = StringUtility.Format("file:///{0}", path);
#elif UNITY_OPENHARMONY
return StringUtility.Format("file://{0}", path);
urlPath = StringUtility.Format("file://{0}", path);
#else
throw new System.NotImplementedException();
#endif
return urlPath.Replace("+", "%2B").Replace("#", "%23").Replace("?", "%3F");
}
}
}

View File

@ -94,6 +94,9 @@ namespace YooAsset
// 等待验证完成
if (_steps == ESteps.CheckVerifyTempFile)
{
if (IsWaitForAsyncComplete)
_verifyOperation.WaitForAsyncComplete();
if (_verifyOperation.IsDone == false)
return;
@ -154,9 +157,6 @@ namespace YooAsset
while (true)
{
if (_verifyOperation != null)
_verifyOperation.WaitForAsyncComplete();
// 注意:如果是导入或解压本地文件,执行等待完毕
if (isReuqestLocalFile)
{
@ -305,6 +305,9 @@ namespace YooAsset
// 等待验证完成
if (_steps == ESteps.CheckVerifyTempFile)
{
if (IsWaitForAsyncComplete)
_verifyOperation.WaitForAsyncComplete();
if (_verifyOperation.IsDone == false)
return;
@ -364,9 +367,6 @@ namespace YooAsset
while (true)
{
if (_verifyOperation != null)
_verifyOperation.WaitForAsyncComplete();
// 注意:如果是导入或解压本地文件,执行等待完毕
if (isReuqestLocalFile)
{

View File

@ -58,6 +58,9 @@ namespace YooAsset
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, downloadParam);
}
if (IsWaitForAsyncComplete)
_downloadFileOp.WaitForAsyncComplete();
DownloadProgress = _downloadFileOp.DownloadProgress;
DownloadedBytes = _downloadFileOp.DownloadedBytes;
if (_downloadFileOp.IsDone == false)
@ -198,9 +201,6 @@ namespace YooAsset
{
while (true)
{
if (_downloadFileOp != null)
_downloadFileOp.WaitForAsyncComplete();
if (ExecuteWhileDone())
{
if (_downloadFileOp != null && _downloadFileOp.Status == EOperationStatus.Failed)
@ -274,6 +274,9 @@ namespace YooAsset
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, downloadParam);
}
if (IsWaitForAsyncComplete)
_downloadFileOp.WaitForAsyncComplete();
DownloadProgress = _downloadFileOp.DownloadProgress;
DownloadedBytes = _downloadFileOp.DownloadedBytes;
if (_downloadFileOp.IsDone == false)
@ -313,9 +316,6 @@ namespace YooAsset
{
while (true)
{
if (_downloadFileOp != null)
_downloadFileOp.WaitForAsyncComplete();
if (ExecuteWhileDone())
{
if (_downloadFileOp != null && _downloadFileOp.Status == EOperationStatus.Failed)

View File

@ -16,6 +16,7 @@ namespace YooAsset
DownloadProgress = 1f;
DownloadedBytes = _bundle.FileSize;
Status = EOperationStatus.Succeed;
Result = new VirtualBundle(_fileSystem, _bundle);
}
internal override void InternalOnUpdate()
{

View File

@ -147,7 +147,7 @@ namespace YooAsset
// 当执行次数用完时
_whileFrame--;
if (_whileFrame == 0)
if (_whileFrame <= 0)
{
Status = EOperationStatus.Failed;
Error = $"Operation {this.GetType().Name} failed to wait for async complete !";

View File

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

View File

@ -0,0 +1,15 @@

namespace YooAsset
{
internal class VirtualBundle
{
private readonly IFileSystem _fileSystem;
private readonly PackageBundle _packageBundle;
internal VirtualBundle(IFileSystem fileSystem, PackageBundle packageBundle)
{
_fileSystem = fileSystem;
_packageBundle = packageBundle;
}
}
}

View File

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

View File

@ -69,17 +69,29 @@ namespace YooAsset
if (_loadBundleOp == null)
_loadBundleOp = BundleFileInfo.LoadBundleFile();
if (IsWaitForAsyncComplete)
_loadBundleOp.WaitForAsyncComplete();
DownloadProgress = _loadBundleOp.DownloadProgress;
DownloadedBytes = _loadBundleOp.DownloadedBytes;
if (_loadBundleOp.IsDone == false)
return;
if (_loadBundleOp.Status == EOperationStatus.Succeed)
{
if (_loadBundleOp.Result == null)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"The bundle loader result is null ! {BundleFileInfo.Bundle.BundleName}";
}
else
{
_steps = ESteps.Done;
Result = _loadBundleOp.Result;
Status = EOperationStatus.Succeed;
}
}
else
{
_steps = ESteps.Done;
@ -92,9 +104,6 @@ namespace YooAsset
{
while (true)
{
if (_loadBundleOp != null)
_loadBundleOp.WaitForAsyncComplete();
if (ExecuteWhileDone())
{
_steps = ESteps.Done;

View File

@ -36,6 +36,14 @@ namespace YooAsset
if (_steps == ESteps.CheckDepend)
{
if (IsWaitForAsyncComplete)
{
foreach (var loader in Depends)
{
loader.WaitForAsyncComplete();
}
}
foreach (var loader in Depends)
{
if (loader.IsDone == false)
@ -73,11 +81,6 @@ namespace YooAsset
{
while (true)
{
foreach (var loader in Depends)
{
loader.WaitForAsyncComplete();
}
if (ExecuteWhileDone())
{
_steps = ESteps.Done;

View File

@ -96,6 +96,7 @@ namespace YooAsset
{
if (LoadDependBundleFileOp != null)
LoadDependBundleFileOp.WaitForAsyncComplete();
if (LoadBundleFileOp != null)
LoadBundleFileOp.WaitForAsyncComplete();

View File

@ -176,6 +176,16 @@ namespace YooAsset
}
#endif
}
// 检测文件系统参数
if (_playMode == EPlayMode.WebPlayMode)
{
var webPlayModeParams = parameters as WebPlayModeParameters;
var fileSystemClassName = webPlayModeParams.WebFileSystemParameters.FileSystemClass;
if (fileSystemClassName == typeof(DefaultCacheFileSystem).FullName
|| fileSystemClassName == typeof(DefaultBuildinFileSystem).FullName)
throw new Exception($"{fileSystemClassName} not support {nameof(EPlayMode.WebPlayMode)}");
}
}
private void InitializeOperation_Completed(AsyncOperationBase op)
{