【m】框架大更新

This commit is contained in:
2025-10-31 11:18:23 +08:00
parent ae6e7c804b
commit 8e1d52ddbf
1883 changed files with 213934 additions and 640 deletions

View File

@@ -0,0 +1,42 @@
#if UNITY_ANDROID && GOOGLE_PLAY
using System.Collections.Generic;
using UnityEngine;
using YooAsset;
using System.Linq;
using System;
public static class GooglePlayFileSystemCreater
{
public static FileSystemParameters CreateFileSystemParameters(string packageRoot)
{
string fileSystemClass = $"{nameof(GooglePlayFileSystem)},YooAsset.MiniGame";
var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot);
return fileSystemParams;
}
}
/// <summary>
/// 兼容谷歌Play Asset Delivery的文件系统
/// </summary>
internal class GooglePlayFileSystem : DefaultBuildinFileSystem
{
public GooglePlayFileSystem()
{
}
public override FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
{
if (bundle.BundleType == (int)EBuildBundleType.AssetBundle)
{
var operation = new GPFSLoadAssetBundleOperation(this, bundle);
return operation;
}
else
{
string error = $"{nameof(GooglePlayFileSystem)} not support load bundle type : {bundle.BundleType}";
var operation = new FSLoadBundleCompleteOperation(error);
return operation;
}
}
}
#endif

View File

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

View File

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

View File

@@ -0,0 +1,85 @@
#if UNITY_ANDROID && GOOGLE_PLAY
using System.IO;
using UnityEngine;
using YooAsset;
using Google.Play.AssetDelivery;
internal class GPFSLoadAssetBundleOperation : FSLoadBundleOperation
{
private enum ESteps
{
None,
LoadAssetBundle,
CheckResult,
Done,
}
private readonly GooglePlayFileSystem _fileSystem;
private readonly PackageBundle _bundle;
private PlayAssetBundleRequest _bundleRequest;
private ESteps _steps = ESteps.None;
internal GPFSLoadAssetBundleOperation(GooglePlayFileSystem fileSystem, PackageBundle bundle)
{
_fileSystem = fileSystem;
_bundle = bundle;
}
internal override void InternalStart()
{
DownloadProgress = 1f;
DownloadedBytes = _bundle.FileSize;
_steps = ESteps.LoadAssetBundle;
}
internal override void InternalUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.LoadAssetBundle)
{
if (_bundle.Encrypted)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"The {nameof(GooglePlayFileSystem)} not support bundle encrypted !";
YooLogger.Error(Error);
return;
}
_bundleRequest = PlayAssetDelivery.RetrieveAssetBundleAsync(_bundle.FileName);
_steps = ESteps.CheckResult;
}
if (_steps == ESteps.CheckResult)
{
if (_bundleRequest.IsDone == false)
return;
if (_bundleRequest.Error != AssetDeliveryErrorCode.NoError)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"Failed to load delivery asset bundle file : {_bundle.BundleName} Error : {_bundleRequest.Error}";
YooLogger.Error(Error);
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
Result = new AssetBundleResult(_fileSystem, _bundle, _bundleRequest.AssetBundle, null);
}
}
}
internal override void InternalWaitForAsyncComplete()
{
if (_steps != ESteps.Done)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"{nameof(GooglePlayFileSystem)} not support sync load method !";
UnityEngine.Debug.LogError(Error);
}
}
}
#endif

View File

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