update file system

This commit is contained in:
何冠峰
2025-02-26 19:31:06 +08:00
parent e4d69d869b
commit 0cdcfe7f52
10 changed files with 114 additions and 24 deletions

View File

@@ -34,11 +34,19 @@ namespace YooAsset
DownloadedBytes = 0;
DownloadProgress = 0;
}
public void Release()
/// <summary>
/// 减少引用计数
/// </summary>
public virtual void Release()
{
RefCount--;
}
public void Reference()
/// <summary>
/// 增加引用计数
/// </summary>
public virtual void Reference()
{
RefCount++;
}

View File

@@ -1,5 +1,4 @@
using UnityEngine;
using UnityEngine.Networking;
namespace YooAsset
{

View File

@@ -0,0 +1,71 @@

namespace YooAsset
{
internal class DownloadFileWrapper : FSDownloadFileOperation
{
private enum ESteps
{
None,
Download,
Done,
}
private readonly FSDownloadFileOperation _downloadFileOp;
private ESteps _steps = ESteps.None;
internal DownloadFileWrapper(FSDownloadFileOperation downloadFileOp) : base(downloadFileOp.Bundle)
{
_downloadFileOp = downloadFileOp;
}
internal override void InternalStart()
{
_steps = ESteps.Download;
}
internal override void InternalUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.Download)
{
if (IsWaitForAsyncComplete)
_downloadFileOp.WaitForAsyncComplete();
if (_downloadFileOp.Status == EOperationStatus.None)
return;
_downloadFileOp.UpdateOperation();
Progress = _downloadFileOp.Progress;
DownloadedBytes = _downloadFileOp.DownloadedBytes;
DownloadProgress = _downloadFileOp.DownloadProgress;
if (_downloadFileOp.IsDone == false)
return;
_steps = ESteps.Done;
Status = _downloadFileOp.Status;
Error = _downloadFileOp.Error;
HttpCode = _downloadFileOp.HttpCode;
}
}
internal override void InternalWaitForAsyncComplete()
{
while (true)
{
if (ExecuteWhileDone())
{
_steps = ESteps.Done;
break;
}
}
}
public override void Release()
{
_downloadFileOp.Release();
}
public override void Reference()
{
_downloadFileOp.Reference();
}
}
}

View File

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