跳到主要内容
版本:2.3.x

Class YooAssets

Assembly: YooAsset.dll
Declaration
public static class YooAssets

Properties

Initialized

是否已经初始化

Declaration
public static bool Initialized { get; }

Methods

Initialize(ILogger)

初始化资源系统

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

CreatePackage(string)

创建资源包裹

Declaration
public static ResourcePackage CreatePackage(string packageName)
Returns

YooAsset.ResourcePackage

Parameters
TypeNameDescription
System.StringpackageName包裹名称

GetPackage(string)

获取资源包裹

Declaration
public static ResourcePackage GetPackage(string packageName)
Returns

YooAsset.ResourcePackage

Parameters
TypeNameDescription
System.StringpackageName包裹名称

TryGetPackage(string)

尝试获取资源包裹

Declaration
public static ResourcePackage TryGetPackage(string packageName)
Returns

YooAsset.ResourcePackage

Parameters
TypeNameDescription
System.StringpackageName包裹名称

GetAllPackages()

获取所有资源包裹

Declaration
public static List<ResourcePackage> GetAllPackages()
Returns

System.Collections.Generic.List<YooAsset.ResourcePackage>

RemovePackage(string)

移除资源包裹

Declaration
public static bool RemovePackage(string packageName)
Returns

System.Boolean

Parameters
TypeNameDescription
System.StringpackageName包裹名称

RemovePackage(ResourcePackage)

移除资源包裹

Declaration
public static bool RemovePackage(ResourcePackage package)
Returns

System.Boolean

Parameters
TypeNameDescription
YooAsset.ResourcePackagepackage包裹实例对象

ContainsPackage(string)

检测资源包裹是否存在

Declaration
public static bool ContainsPackage(string packageName)
Returns

System.Boolean

Parameters
TypeNameDescription
System.StringpackageName包裹名称

StartOperation(GameAsyncOperation)

开启一个异步操作

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

SetDownloadSystemUnityWebRequest(UnityWebRequestDelegate)

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

Declaration
public static void SetDownloadSystemUnityWebRequest(UnityWebRequestDelegate createDelegate)
Parameters
TypeName
YooAsset.UnityWebRequestDelegatecreateDelegate

SetOperationSystemMaxTimeSlice(long)

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

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

SetDefaultPackage(ResourcePackage)

设置默认的资源包

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

IsNeedDownloadFromRemote(string)

是否需要从远端更新下载

Declaration
public static bool IsNeedDownloadFromRemote(string location)
Returns

System.Boolean

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

IsNeedDownloadFromRemote(AssetInfo)

是否需要从远端更新下载

Declaration
public static bool IsNeedDownloadFromRemote(AssetInfo assetInfo)
Returns

System.Boolean

Parameters
TypeName
YooAsset.AssetInfoassetInfo

GetAssetInfos(string)

获取资源信息列表

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

YooAsset.AssetInfo[]

Parameters
TypeNameDescription
System.Stringtag资源标签

GetAssetInfos(string[])

获取资源信息列表

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

YooAsset.AssetInfo[]

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

GetAssetInfo(string)

获取资源信息

Declaration
public static AssetInfo GetAssetInfo(string location)
Returns

YooAsset.AssetInfo

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

GetAssetInfo(string, Type)

获取资源信息

Declaration
public static AssetInfo GetAssetInfo(string location, Type type)
Returns

YooAsset.AssetInfo

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

GetAssetInfoByGUID(string)

获取资源信息

Declaration
public static AssetInfo GetAssetInfoByGUID(string assetGUID)
Returns

YooAsset.AssetInfo

Parameters
TypeNameDescription
System.StringassetGUID资源GUID

GetAssetInfoByGUID(string, Type)

获取资源信息

Declaration
public static AssetInfo GetAssetInfoByGUID(string assetGUID, Type type)
Returns

YooAsset.AssetInfo

Parameters
TypeNameDescription
System.StringassetGUID资源GUID
System.Typetype资源类型

CheckLocationValid(string)

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

Declaration
public static bool CheckLocationValid(string location)
Returns

System.Boolean

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

LoadRawFileSync(AssetInfo)

同步加载原生文件

Declaration
public static RawFileHandle LoadRawFileSync(AssetInfo assetInfo)
Returns

YooAsset.RawFileHandle

Parameters
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息

LoadRawFileSync(string)

同步加载原生文件

Declaration
public static RawFileHandle LoadRawFileSync(string location)
Returns

YooAsset.RawFileHandle

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

LoadRawFileAsync(AssetInfo, uint)

异步加载原生文件

Declaration
public static RawFileHandle LoadRawFileAsync(AssetInfo assetInfo, uint priority = 0)
Returns

YooAsset.RawFileHandle

Parameters
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息
System.UInt32priority

LoadRawFileAsync(string, uint)

异步加载原生文件

Declaration
public static RawFileHandle LoadRawFileAsync(string location, uint priority = 0)
Returns

YooAsset.RawFileHandle

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

LoadSceneSync(string, LoadSceneMode, LocalPhysicsMode)

同步加载场景

Declaration
public static SceneHandle LoadSceneSync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, LocalPhysicsMode physicsMode = LocalPhysicsMode.None)
Returns

YooAsset.SceneHandle

Parameters
TypeNameDescription
System.Stringlocation场景的定位地址
UnityEngine.SceneManagement.LoadSceneModesceneMode场景加载模式
UnityEngine.SceneManagement.LocalPhysicsModephysicsMode场景物理模式

LoadSceneSync(AssetInfo, LoadSceneMode, LocalPhysicsMode)

同步加载场景

Declaration
public static SceneHandle LoadSceneSync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, LocalPhysicsMode physicsMode = LocalPhysicsMode.None)
Returns

YooAsset.SceneHandle

Parameters
TypeNameDescription
YooAsset.AssetInfoassetInfo场景的资源信息
UnityEngine.SceneManagement.LoadSceneModesceneMode场景加载模式
UnityEngine.SceneManagement.LocalPhysicsModephysicsMode场景物理模式

LoadSceneAsync(string, LoadSceneMode, LocalPhysicsMode, bool, uint)

异步加载场景

Declaration
public static SceneHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, LocalPhysicsMode physicsMode = LocalPhysicsMode.None, bool suspendLoad = false, uint priority = 100)
Returns

YooAsset.SceneHandle

Parameters
TypeNameDescription
System.Stringlocation场景的定位地址
UnityEngine.SceneManagement.LoadSceneModesceneMode场景加载模式
UnityEngine.SceneManagement.LocalPhysicsModephysicsMode场景物理模式
System.BooleansuspendLoad场景加载到90%自动挂起
System.UInt32priority优先级

LoadSceneAsync(AssetInfo, LoadSceneMode, LocalPhysicsMode, bool, uint)

异步加载场景

Declaration
public static SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, LocalPhysicsMode physicsMode = LocalPhysicsMode.None, bool suspendLoad = false, uint priority = 100)
Returns

YooAsset.SceneHandle

Parameters
TypeNameDescription
YooAsset.AssetInfoassetInfo场景的资源信息
UnityEngine.SceneManagement.LoadSceneModesceneMode场景加载模式
UnityEngine.SceneManagement.LocalPhysicsModephysicsMode场景物理模式
System.BooleansuspendLoad场景加载到90%自动挂起
System.UInt32priority优先级

LoadAssetSync(AssetInfo)

同步加载资源对象

Declaration
public static AssetHandle LoadAssetSync(AssetInfo assetInfo)
Returns

YooAsset.AssetHandle

Parameters
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息

LoadAssetSync<TObject>(string)

同步加载资源对象

Declaration
public static AssetHandle LoadAssetSync<TObject>(string location) where TObject : Object
Returns

YooAsset.AssetHandle

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

LoadAssetSync(string, Type)

同步加载资源对象

Declaration
public static AssetHandle LoadAssetSync(string location, Type type)
Returns

YooAsset.AssetHandle

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

LoadAssetSync(string)

同步加载资源对象

Declaration
public static AssetHandle LoadAssetSync(string location)
Returns

YooAsset.AssetHandle

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

LoadAssetAsync(AssetInfo, uint)

异步加载资源对象

Declaration
public static AssetHandle LoadAssetAsync(AssetInfo assetInfo, uint priority = 0)
Returns

YooAsset.AssetHandle

Parameters
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息
System.UInt32priority

LoadAssetAsync<TObject>(string, uint)

异步加载资源对象

Declaration
public static AssetHandle LoadAssetAsync<TObject>(string location, uint priority = 0) where TObject : Object
Returns

YooAsset.AssetHandle

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

LoadAssetAsync(string, Type, uint)

异步加载资源对象

Declaration
public static AssetHandle LoadAssetAsync(string location, Type type, uint priority = 0)
Returns

YooAsset.AssetHandle

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

LoadAssetAsync(string, uint)

异步加载资源对象

Declaration
public static AssetHandle LoadAssetAsync(string location, uint priority = 0)
Returns

YooAsset.AssetHandle

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

LoadSubAssetsSync(AssetInfo)

同步加载子资源对象

Declaration
public static SubAssetsHandle LoadSubAssetsSync(AssetInfo assetInfo)
Returns

YooAsset.SubAssetsHandle

Parameters
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息

LoadSubAssetsSync<TObject>(string)

同步加载子资源对象

Declaration
public static SubAssetsHandle LoadSubAssetsSync<TObject>(string location) where TObject : Object
Returns

YooAsset.SubAssetsHandle

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

LoadSubAssetsSync(string, Type)

同步加载子资源对象

Declaration
public static SubAssetsHandle LoadSubAssetsSync(string location, Type type)
Returns

YooAsset.SubAssetsHandle

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

LoadSubAssetsSync(string)

同步加载子资源对象

Declaration
public static SubAssetsHandle LoadSubAssetsSync(string location)
Returns

YooAsset.SubAssetsHandle

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

LoadSubAssetsAsync(AssetInfo, uint)

异步加载子资源对象

Declaration
public static SubAssetsHandle LoadSubAssetsAsync(AssetInfo assetInfo, uint priority = 0)
Returns

YooAsset.SubAssetsHandle

Parameters
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息
System.UInt32priority

LoadSubAssetsAsync<TObject>(string, uint)

异步加载子资源对象

Declaration
public static SubAssetsHandle LoadSubAssetsAsync<TObject>(string location, uint priority = 0) where TObject : Object
Returns

YooAsset.SubAssetsHandle

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

LoadSubAssetsAsync(string, Type, uint)

异步加载子资源对象

Declaration
public static SubAssetsHandle LoadSubAssetsAsync(string location, Type type, uint priority = 0)
Returns

YooAsset.SubAssetsHandle

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

LoadSubAssetsAsync(string, uint)

异步加载子资源对象

Declaration
public static SubAssetsHandle LoadSubAssetsAsync(string location, uint priority = 0)
Returns

YooAsset.SubAssetsHandle

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

LoadAllAssetsSync(AssetInfo)

同步加载资源包内所有资源对象

Declaration
public static AllAssetsHandle LoadAllAssetsSync(AssetInfo assetInfo)
Returns

YooAsset.AllAssetsHandle

Parameters
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息

LoadAllAssetsSync<TObject>(string)

同步加载资源包内所有资源对象

Declaration
public static AllAssetsHandle LoadAllAssetsSync<TObject>(string location) where TObject : Object
Returns

YooAsset.AllAssetsHandle

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

LoadAllAssetsSync(string, Type)

同步加载资源包内所有资源对象

Declaration
public static AllAssetsHandle LoadAllAssetsSync(string location, Type type)
Returns

YooAsset.AllAssetsHandle

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

LoadAllAssetsSync(string)

同步加载资源包内所有资源对象

Declaration
public static AllAssetsHandle LoadAllAssetsSync(string location)
Returns

YooAsset.AllAssetsHandle

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

LoadAllAssetsAsync(AssetInfo, uint)

异步加载资源包内所有资源对象

Declaration
public static AllAssetsHandle LoadAllAssetsAsync(AssetInfo assetInfo, uint priority = 0)
Returns

YooAsset.AllAssetsHandle

Parameters
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息
System.UInt32priority

LoadAllAssetsAsync<TObject>(string, uint)

异步加载资源包内所有资源对象

Declaration
public static AllAssetsHandle LoadAllAssetsAsync<TObject>(string location, uint priority = 0) where TObject : Object
Returns

YooAsset.AllAssetsHandle

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

LoadAllAssetsAsync(string, Type, uint)

异步加载资源包内所有资源对象

Declaration
public static AllAssetsHandle LoadAllAssetsAsync(string location, Type type, uint priority = 0)
Returns

YooAsset.AllAssetsHandle

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

LoadAllAssetsAsync(string, uint)

异步加载资源包内所有资源对象

Declaration
public static AllAssetsHandle LoadAllAssetsAsync(string location, uint priority = 0)
Returns

YooAsset.AllAssetsHandle

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

CreateResourceDownloader(int, int)

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

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

YooAsset.ResourceDownloaderOperation

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

CreateResourceDownloader(string, int, int)

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

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)

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

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)

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

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)

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

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)

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

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)

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

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

YooAsset.ResourceDownloaderOperation

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

CreateResourceUnpacker(int, int)

创建内置资源解压器,用于解压当前资源版本所有的资源包文件

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

YooAsset.ResourceUnpackerOperation

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

CreateResourceUnpacker(string, int, int)

创建内置资源解压器,用于解压指定的资源标签关联的资源包文件

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)

创建内置资源解压器,用于解压指定的资源标签列表关联的资源包文件

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

YooAsset.ResourceUnpackerOperation

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

CreateResourceImporter(string[], int, int)

创建资源导入器 注意:资源文件名称必须和资源服务器部署的文件名称一致!

Declaration
public static ResourceImporterOperation CreateResourceImporter(string[] filePaths, int importerMaxNumber, int failedTryAgain)
Returns

YooAsset.ResourceImporterOperation

Parameters
TypeNameDescription
System.String[]filePaths资源路径列表
System.Int32importerMaxNumber同时导入的最大文件数
System.Int32failedTryAgain导入失败的重试次数