Skip to main content
Version: 2.1.x

Class YooAssets

Assembly: YooAsset.dll
View Source
Declaration
public static class YooAssets

Methods

SetDefaultPackage(ResourcePackage)

设置默认的资源包

View Source
Declaration
public static void SetDefaultPackage(ResourcePackage package)
Parameters
TypeName
YooAsset.ResourcePackagepackage

IsNeedDownloadFromRemote(string)

是否需要从远端更新下载

View Source
Declaration
public static bool IsNeedDownloadFromRemote(string location)
Returns

System.Boolean

Parameters
TypeNameDescription
System.Stringlocation资源的定位地址

IsNeedDownloadFromRemote(AssetInfo)

是否需要从远端更新下载

View Source
Declaration
public static bool IsNeedDownloadFromRemote(AssetInfo assetInfo)
Returns

System.Boolean

Parameters
TypeName
YooAsset.AssetInfoassetInfo

GetAssetInfos(string)

获取资源信息列表

View Source
Declaration
public static AssetInfo[] GetAssetInfos(string tag)
Returns

YooAsset.AssetInfo[]

Parameters
TypeNameDescription
System.Stringtag资源标签

GetAssetInfos(string[])

获取资源信息列表

View Source
Declaration
public static AssetInfo[] GetAssetInfos(string[] tags)
Returns

YooAsset.AssetInfo[]

Parameters
TypeNameDescription
System.String[]tags资源标签列表

GetAssetInfo(string)

获取资源信息

View Source
Declaration
public static AssetInfo GetAssetInfo(string location)
Returns

YooAsset.AssetInfo

Parameters
TypeNameDescription
System.Stringlocation资源的定位地址

CheckLocationValid(string)

检查资源定位地址是否有效

View Source
Declaration
public static bool CheckLocationValid(string location)
Returns

System.Boolean

Parameters
TypeNameDescription
System.Stringlocation资源的定位地址

LoadRawFileSync(AssetInfo)

同步加载原生文件

View Source
Declaration
public static RawFileOperationHandle LoadRawFileSync(AssetInfo assetInfo)
Returns

YooAsset.RawFileOperationHandle

Parameters
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息

LoadRawFileSync(string)

同步加载原生文件

View Source
Declaration
public static RawFileOperationHandle LoadRawFileSync(string location)
Returns

YooAsset.RawFileOperationHandle

Parameters
TypeNameDescription
System.Stringlocation资源的定位地址

LoadRawFileAsync(AssetInfo)

异步加载原生文件

View Source
Declaration
public static RawFileOperationHandle LoadRawFileAsync(AssetInfo assetInfo)
Returns

YooAsset.RawFileOperationHandle

Parameters
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息

LoadRawFileAsync(string)

异步加载原生文件

View Source
Declaration
public static RawFileOperationHandle LoadRawFileAsync(string location)
Returns

YooAsset.RawFileOperationHandle

Parameters
TypeNameDescription
System.Stringlocation资源的定位地址

LoadSceneAsync(string, LoadSceneMode, bool, int)

异步加载场景

View Source
Declaration
public static SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
Returns

YooAsset.SceneOperationHandle

Parameters
TypeNameDescription
System.Stringlocation场景的定位地址
UnityEngine.SceneManagement.LoadSceneModesceneMode场景加载模式
System.BooleanactivateOnLoad加载完毕时是否主动激活
System.Int32priority优先级

LoadSceneAsync(AssetInfo, LoadSceneMode, bool, int)

异步加载场景

View Source
Declaration
public static SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
Returns

YooAsset.SceneOperationHandle

Parameters
TypeNameDescription
YooAsset.AssetInfoassetInfo场景的资源信息
UnityEngine.SceneManagement.LoadSceneModesceneMode场景加载模式
System.BooleanactivateOnLoad加载完毕时是否主动激活
System.Int32priority优先级

LoadAssetSync(AssetInfo)

同步加载资源对象

View Source
Declaration
public static AssetOperationHandle LoadAssetSync(AssetInfo assetInfo)
Returns

YooAsset.AssetOperationHandle

Parameters
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息

LoadAssetSync<TObject>(string)

同步加载资源对象

View Source
Declaration
public static AssetOperationHandle LoadAssetSync<TObject>(string location) where TObject : Object
Returns

YooAsset.AssetOperationHandle

Parameters
TypeNameDescription
System.Stringlocation资源的定位地址
Type Parameters
NameDescription
TObject资源类型

LoadAssetSync(string, Type)

同步加载资源对象

View Source
Declaration
public static AssetOperationHandle LoadAssetSync(string location, Type type)
Returns

YooAsset.AssetOperationHandle

Parameters
TypeNameDescription
System.Stringlocation资源的定位地址
System.Typetype资源类型

LoadAssetAsync(AssetInfo)

异步加载资源对象

View Source
Declaration
public static AssetOperationHandle LoadAssetAsync(AssetInfo assetInfo)
Returns

YooAsset.AssetOperationHandle

Parameters
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息

LoadAssetAsync<TObject>(string)

异步加载资源对象

View Source
Declaration
public static AssetOperationHandle LoadAssetAsync<TObject>(string location) where TObject : Object
Returns

YooAsset.AssetOperationHandle

Parameters
TypeNameDescription
System.Stringlocation资源的定位地址
Type Parameters
NameDescription
TObject资源类型

LoadAssetAsync(string, Type)

异步加载资源对象

View Source
Declaration
public static AssetOperationHandle LoadAssetAsync(string location, Type type)
Returns

YooAsset.AssetOperationHandle

Parameters
TypeNameDescription
System.Stringlocation资源的定位地址
System.Typetype资源类型

LoadSubAssetsSync(AssetInfo)

同步加载子资源对象

View Source
Declaration
public static SubAssetsOperationHandle LoadSubAssetsSync(AssetInfo assetInfo)
Returns

YooAsset.SubAssetsOperationHandle

Parameters
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息

LoadSubAssetsSync<TObject>(string)

同步加载子资源对象

View Source
Declaration
public static SubAssetsOperationHandle LoadSubAssetsSync<TObject>(string location) where TObject : Object
Returns

YooAsset.SubAssetsOperationHandle

Parameters
TypeNameDescription
System.Stringlocation资源的定位地址
Type Parameters
NameDescription
TObject资源类型

LoadSubAssetsSync(string, Type)

同步加载子资源对象

View Source
Declaration
public static SubAssetsOperationHandle LoadSubAssetsSync(string location, Type type)
Returns

YooAsset.SubAssetsOperationHandle

Parameters
TypeNameDescription
System.Stringlocation资源的定位地址
System.Typetype子对象类型

LoadSubAssetsAsync(AssetInfo)

异步加载子资源对象

View Source
Declaration
public static SubAssetsOperationHandle LoadSubAssetsAsync(AssetInfo assetInfo)
Returns

YooAsset.SubAssetsOperationHandle

Parameters
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息

LoadSubAssetsAsync<TObject>(string)

异步加载子资源对象

View Source
Declaration
public static SubAssetsOperationHandle LoadSubAssetsAsync<TObject>(string location) where TObject : Object
Returns

YooAsset.SubAssetsOperationHandle

Parameters
TypeNameDescription
System.Stringlocation资源的定位地址
Type Parameters
NameDescription
TObject资源类型

LoadSubAssetsAsync(string, Type)

异步加载子资源对象

View Source
Declaration
public static SubAssetsOperationHandle LoadSubAssetsAsync(string location, Type type)
Returns

YooAsset.SubAssetsOperationHandle

Parameters
TypeNameDescription
System.Stringlocation资源的定位地址
System.Typetype子对象类型

CreateResourceDownloader(int, int)

创建资源下载器,用于下载当前资源版本所有的资源包文件

View Source
Declaration
public static ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain)
Returns

YooAsset.ResourceDownloaderOperation

Parameters
TypeNameDescription
System.Int32downloadingMaxNumber同时下载的最大文件数
System.Int32failedTryAgain下载失败的重试次数

CreateResourceDownloader(string, int, int)

创建资源下载器,用于下载指定的资源标签关联的资源包文件

View Source
Declaration
public static ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain)
Returns

YooAsset.ResourceDownloaderOperation

Parameters
TypeNameDescription
System.Stringtag资源标签
System.Int32downloadingMaxNumber同时下载的最大文件数
System.Int32failedTryAgain下载失败的重试次数

CreateResourceDownloader(string[], int, int)

创建资源下载器,用于下载指定的资源标签列表关联的资源包文件

View Source
Declaration
public static ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain)
Returns

YooAsset.ResourceDownloaderOperation

Parameters
TypeNameDescription
System.String[]tags资源标签列表
System.Int32downloadingMaxNumber同时下载的最大文件数
System.Int32failedTryAgain下载失败的重试次数

CreateBundleDownloader(string, int, int)

创建资源下载器,用于下载指定的资源依赖的资源包文件

View Source
Declaration
public static ResourceDownloaderOperation CreateBundleDownloader(string location, int downloadingMaxNumber, int failedTryAgain)
Returns

YooAsset.ResourceDownloaderOperation

Parameters
TypeNameDescription
System.Stringlocation资源定位地址
System.Int32downloadingMaxNumber同时下载的最大文件数
System.Int32failedTryAgain下载失败的重试次数

CreateBundleDownloader(string[], int, int)

创建资源下载器,用于下载指定的资源列表依赖的资源包文件

View Source
Declaration
public static ResourceDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain)
Returns

YooAsset.ResourceDownloaderOperation

Parameters
TypeNameDescription
System.String[]locations资源定位地址列表
System.Int32downloadingMaxNumber同时下载的最大文件数
System.Int32failedTryAgain下载失败的重试次数

CreateBundleDownloader(AssetInfo, int, int)

创建资源下载器,用于下载指定的资源依赖的资源包文件

View Source
Declaration
public static ResourceDownloaderOperation CreateBundleDownloader(AssetInfo assetInfo, int downloadingMaxNumber, int failedTryAgain)
Returns

YooAsset.ResourceDownloaderOperation

Parameters
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息
System.Int32downloadingMaxNumber同时下载的最大文件数
System.Int32failedTryAgain下载失败的重试次数

CreateBundleDownloader(AssetInfo[], int, int)

创建资源下载器,用于下载指定的资源列表依赖的资源包文件

View Source
Declaration
public static ResourceDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain)
Returns

YooAsset.ResourceDownloaderOperation

Parameters
TypeNameDescription
YooAsset.AssetInfo[]assetInfos资源信息列表
System.Int32downloadingMaxNumber同时下载的最大文件数
System.Int32failedTryAgain下载失败的重试次数

CreateResourceUnpacker(string, int, int)

创建内置资源解压器

View Source
Declaration
public static ResourceUnpackerOperation CreateResourceUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain)
Returns

YooAsset.ResourceUnpackerOperation

Parameters
TypeNameDescription
System.Stringtag资源标签
System.Int32unpackingMaxNumber同时解压的最大文件数
System.Int32failedTryAgain解压失败的重试次数

CreateResourceUnpacker(string[], int, int)

创建内置资源解压器

View Source
Declaration
public static ResourceUnpackerOperation CreateResourceUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain)
Returns

YooAsset.ResourceUnpackerOperation

Parameters
TypeNameDescription
System.String[]tags资源标签列表
System.Int32unpackingMaxNumber同时解压的最大文件数
System.Int32failedTryAgain解压失败的重试次数

CreateResourceUnpacker(int, int)

创建内置资源解压器

View Source
Declaration
public static ResourceUnpackerOperation CreateResourceUnpacker(int unpackingMaxNumber, int failedTryAgain)
Returns

YooAsset.ResourceUnpackerOperation

Parameters
TypeNameDescription
System.Int32unpackingMaxNumber同时解压的最大文件数
System.Int32failedTryAgain解压失败的重试次数

Initialize(ILogger)

初始化资源系统

View Source
Declaration
public static void Initialize(ILogger logger = null)
Parameters
TypeNameDescription
YooAsset.ILoggerlogger自定义日志处理

Destroy()

销毁资源系统

View Source
Declaration
public static void Destroy()

CreatePackage(string)

创建资源包

View Source
Declaration
public static ResourcePackage CreatePackage(string packageName)
Returns

YooAsset.ResourcePackage

Parameters
TypeNameDescription
System.StringpackageName资源包名称

GetPackage(string)

获取资源包

View Source
Declaration
public static ResourcePackage GetPackage(string packageName)
Returns

YooAsset.ResourcePackage

Parameters
TypeNameDescription
System.StringpackageName资源包名称

TryGetPackage(string)

尝试获取资源包

View Source
Declaration
public static ResourcePackage TryGetPackage(string packageName)
Returns

YooAsset.ResourcePackage

Parameters
TypeNameDescription
System.StringpackageName资源包名称

DestroyPackage(string)

销毁资源包

View Source
Declaration
public static void DestroyPackage(string packageName)
Parameters
TypeNameDescription
System.StringpackageName资源包名称

HasPackage(string)

检测资源包是否存在

View Source
Declaration
public static bool HasPackage(string packageName)
Returns

System.Boolean

Parameters
TypeNameDescription
System.StringpackageName资源包名称

StartOperation(GameAsyncOperation)

开启一个异步操作

View Source
Declaration
public static void StartOperation(GameAsyncOperation operation)
Parameters
TypeNameDescription
YooAsset.GameAsyncOperationoperation异步操作对象

SetDownloadSystemBreakpointResumeFileSize(int)

设置下载系统参数,启用断点续传功能文件的最小字节数

View Source
Declaration
public static void SetDownloadSystemBreakpointResumeFileSize(int fileBytes)
Parameters
TypeName
System.Int32fileBytes

SetDownloadSystemClearFileResponseCode(List<long>)

设置下载系统参数,下载失败后清理文件的HTTP错误码

View Source
Declaration
public static void SetDownloadSystemClearFileResponseCode(List<long> codes)
Parameters
TypeName
System.Collections.Generic.List<System.Int64>codes

SetDownloadSystemCertificateHandler(CertificateHandler)

设置下载系统参数,自定义的证书认证实例

View Source
Declaration
public static void SetDownloadSystemCertificateHandler(CertificateHandler instance)
Parameters
TypeName
UnityEngine.Networking.CertificateHandlerinstance

SetDownloadSystemUnityWebRequest(DownloadRequestDelegate)

设置下载系统参数,自定义下载请求

View Source
Declaration
public static void SetDownloadSystemUnityWebRequest(DownloadRequestDelegate requestDelegate)
Parameters
TypeName
YooAsset.DownloadRequestDelegaterequestDelegate

SetOperationSystemMaxTimeSlice(long)

设置异步系统参数,每帧执行消耗的最大时间切片(单位:毫秒)

View Source
Declaration
public static void SetOperationSystemMaxTimeSlice(long milliseconds)
Parameters
TypeName
System.Int64milliseconds

SetCacheSystemCachedFileVerifyLevel(EVerifyLevel)

设置缓存系统参数,已经缓存文件的校验等级

View Source
Declaration
public static void SetCacheSystemCachedFileVerifyLevel(EVerifyLevel verifyLevel)
Parameters
TypeName
YooAsset.EVerifyLevelverifyLevel

GetStreamingAssetBuildinFolderName()

获取内置文件夹名称

View Source
Declaration
public static string GetStreamingAssetBuildinFolderName()
Returns

System.String

GetSandboxRoot()

获取沙盒的根路径

View Source
Declaration
public static string GetSandboxRoot()
Returns

System.String

ClearSandbox()

清空沙盒目录(需要重启APP)

View Source
Declaration
public static void ClearSandbox()