From d09b52301a3f25dcc76290786b918bf31dd75ce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=86=A0=E5=B3=B0?= Date: Fri, 5 Jul 2024 20:20:38 +0800 Subject: [PATCH] update extension sample --- .../Runtime/WechatFileSystem.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Assets/YooAsset/Samples~/Extension Sample/Runtime/WechatFileSystem.cs b/Assets/YooAsset/Samples~/Extension Sample/Runtime/WechatFileSystem.cs index 7fec0af..9819578 100644 --- a/Assets/YooAsset/Samples~/Extension Sample/Runtime/WechatFileSystem.cs +++ b/Assets/YooAsset/Samples~/Extension Sample/Runtime/WechatFileSystem.cs @@ -1,4 +1,4 @@ -#if !UNITY_WECHAT_GAME +#if UNITY_WECHAT_GAME using System; using System.IO; using System.Collections.Generic; @@ -7,6 +7,19 @@ using UnityEngine.Networking; using YooAsset; using WeChatWASM; +public static class WechatFileSystemCreater +{ + public static FileSystemParameters CreateWechatFileSystemParameters(IRemoteServices remoteServices) + { + string fileSystemClass = $"{nameof(WechatFileSystem)},YooAsset.RuntimeExtension"; + var fileSystemParams = new FileSystemParameters(fileSystemClass, null); + fileSystemParams.AddParameter("REMOTE_SERVICES", remoteServices); + fileSystemParams.AddParameter("DISABLE_UNITY_WEB_CACHE", true); + fileSystemParams.AddParameter("ALLOW_CROSS_ACCESS", true); + return fileSystemParams; + } +} + /// /// 微信小游戏文件系统扩展 /// 参考:https://wechat-miniprogram.github.io/minigame-unity-webgl-transform/Design/UsingAssetBundle.html @@ -35,8 +48,8 @@ internal partial class WechatFileSystem : DefaultWebFileSystem int timeout = (int)args[3]; string mainURL = RemoteServices.GetRemoteMainURL(bundle.FileName); - string fallbackURL = RemoteServices.GetRemoteFallbackURL(bundle.FileName); - var operation = new WechatDownloadFileOperation(this, bundle, mainURL,fallbackURL, failedTryAgain, timeout); + string fallbackURL = RemoteServices.GetRemoteFallbackURL(bundle.FileName); + var operation = new WechatDownloadFileOperation(this, bundle, mainURL, fallbackURL, failedTryAgain, timeout); OperationSystem.StartOperation(PackageName, operation); return operation; }