update extension sample

This commit is contained in:
何冠峰
2024-12-25 17:24:48 +08:00
parent 16117b67f1
commit 8d1f0d2010
7 changed files with 157 additions and 33 deletions
@@ -126,15 +126,19 @@ internal class ByteGameFileSystem : IFileSystem
}
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
{
var operation = new BGFSLoadBundleOperation(this, bundle);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
public virtual void UnloadBundleFile(PackageBundle bundle, object result)
{
AssetBundle assetBundle = result as AssetBundle;
if (assetBundle != null)
assetBundle.Unload(true);
if (bundle.BundleType == (int)EBuildBundleType.AssetBundle)
{
var operation = new BGFSLoadBundleOperation(this, bundle);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
else
{
string error = $"{nameof(ByteGameFileSystem)} not support load bundle type : {bundle.BundleType}";
var operation = new FSLoadBundleCompleteOperation(error);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
}
public virtual void SetParameter(string name, object value)
@@ -190,15 +194,19 @@ internal class ByteGameFileSystem : IFileSystem
return false;
}
public virtual byte[] ReadFileData(PackageBundle bundle)
public virtual string GetBundleFilePath(PackageBundle bundle)
{
throw new System.NotImplementedException();
}
public virtual string ReadFileText(PackageBundle bundle)
public virtual byte[] ReadBundleFileData(PackageBundle bundle)
{
throw new System.NotImplementedException();
}
public virtual string ReadBundleFileText(PackageBundle bundle)
{
throw new System.NotImplementedException();
}
#region 内部方法
private string GetCacheFileLoadPath(PackageBundle bundle)
{
@@ -1,6 +1,7 @@
#if UNITY_WEBGL && BYTEMINIGAME
using UnityEngine;
using UnityEngine.Networking;
using WeChatWASM;
using YooAsset;
internal class BGFSLoadBundleOperation : FSLoadBundleOperation
@@ -48,9 +49,19 @@ internal class BGFSLoadBundleOperation : FSLoadBundleOperation
if (CheckRequestResult())
{
_steps = ESteps.Done;
Result = (_webRequest.downloadHandler as DownloadHandlerAssetBundle).assetBundle;
Status = EOperationStatus.Succeed;
var assetBundle = (_webRequest.downloadHandler as DownloadHandlerAssetBundle).assetBundle;
if (assetBundle == null)
{
_steps = ESteps.Done;
Error = $"{nameof(DownloadHandlerAssetBundle)} loaded asset bundle is null !";
Status = EOperationStatus.Failed;
}
else
{
_steps = ESteps.Done;
Result = new AssetBundleResult(_fileSystem, _bundle, assetBundle, null);
Status = EOperationStatus.Succeed;
}
}
else
{