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

Class ResourcePackage

Assembly: YooAsset.dll​
View Source​
Declaration
public class ResourcePackage

Properties​

PackageName​

包裹名

View Source​
Declaration
public string PackageName { get; }

InitializeStatus​

初始化状态

View Source​
Declaration
public EOperationStatus InitializeStatus { get; }

Methods​

InitializeAsync(InitializeParameters)​

异步初始化

View Source​
Declaration
public InitializationOperation InitializeAsync(InitializeParameters parameters)
Returns​

YooAsset.InitializationOperation

Parameters​
TypeName
YooAsset.InitializeParametersparameters

UpdatePackageVersionAsync(bool, int)​

向网络端请求最新的资源版本

View Source​
Declaration
public UpdatePackageVersionOperation UpdatePackageVersionAsync(bool appendTimeTicks = true, int timeout = 60)
Returns​

YooAsset.UpdatePackageVersionOperation

Parameters​
TypeNameDescription
System.BooleanappendTimeTicks在URL末尾添加时间戳
System.Int32timeout超时时间(默认值:60秒)

UpdatePackageManifestAsync(string, bool, int)​

向网络端请求并更新清单

View Source​
Declaration
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion = true, int timeout = 60)
Returns​

YooAsset.UpdatePackageManifestOperation

Parameters​
TypeNameDescription
System.StringpackageVersion更新的包裹版本
System.BooleanautoSaveVersion更新成功后自动保存版本号,作为下次初始化的版本。
System.Int32timeout超时时间(默认值:60秒)

PreDownloadContentAsync(string, int)​

预下载指定版本的包裹资源

View Source​
Declaration
public PreDownloadContentOperation PreDownloadContentAsync(string packageVersion, int timeout = 60)
Returns​

YooAsset.PreDownloadContentOperation

Parameters​
TypeNameDescription
System.StringpackageVersion下载的包裹版本
System.Int32timeout超时时间(默认值:60秒)

ClearUnusedCacheFilesAsync()​

清理包裹未使用的缓存文件

View Source​
Declaration
public ClearUnusedCacheFilesOperation ClearUnusedCacheFilesAsync()
Returns​

YooAsset.ClearUnusedCacheFilesOperation

GetPackageVersion()​

获取本地包裹的版本信息

View Source​
Declaration
public string GetPackageVersion()
Returns​

System.String

UnloadUnusedAssets()​

资源回收(卸载引用计数为零的资源)

View Source​
Declaration
public void UnloadUnusedAssets()

ForceUnloadAllAssets()​

强制回收所有资源

View Source​
Declaration
public void ForceUnloadAllAssets()

IsNeedDownloadFromRemote(string)​

是否需要从远端更新下载

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

System.Boolean

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

IsNeedDownloadFromRemote(AssetInfo)​

是否需要从远端更新下载

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

System.Boolean

Parameters​
TypeName
YooAsset.AssetInfoassetInfo

GetAssetInfos(string)​

获取资源信息列表

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

YooAsset.AssetInfo[]

Parameters​
TypeNameDescription
System.Stringtag资源标签

GetAssetInfos(string[])​

获取资源信息列表

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

YooAsset.AssetInfo[]

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

GetAssetInfo(string)​

获取资源信息

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

YooAsset.AssetInfo

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

CheckLocationValid(string)​

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

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

System.Boolean

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

LoadRawFileSync(AssetInfo)​

同步加载原生文件

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

YooAsset.RawFileOperationHandle

Parameters​
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息

LoadRawFileSync(string)​

同步加载原生文件

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

YooAsset.RawFileOperationHandle

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

LoadRawFileAsync(AssetInfo)​

异步加载原生文件

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

YooAsset.RawFileOperationHandle

Parameters​
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息

LoadRawFileAsync(string)​

异步加载原生文件

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

YooAsset.RawFileOperationHandle

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

LoadSceneAsync(string, LoadSceneMode, bool, int)​

异步加载场景

View Source​
Declaration
public 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 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 AssetOperationHandle LoadAssetSync(AssetInfo assetInfo)
Returns​

YooAsset.AssetOperationHandle

Parameters​
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息

LoadAssetSync<TObject>(string)​

同步加载资源对象

View Source​
Declaration
public 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 AssetOperationHandle LoadAssetSync(string location, Type type)
Returns​

YooAsset.AssetOperationHandle

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

LoadAssetAsync(AssetInfo)​

异步加载资源对象

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

YooAsset.AssetOperationHandle

Parameters​
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息

LoadAssetAsync<TObject>(string)​

异步加载资源对象

View Source​
Declaration
public 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 AssetOperationHandle LoadAssetAsync(string location, Type type)
Returns​

YooAsset.AssetOperationHandle

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

LoadSubAssetsSync(AssetInfo)​

同步加载子资源对象

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

YooAsset.SubAssetsOperationHandle

Parameters​
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息

LoadSubAssetsSync<TObject>(string)​

同步加载子资源对象

View Source​
Declaration
public 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 SubAssetsOperationHandle LoadSubAssetsSync(string location, Type type)
Returns​

YooAsset.SubAssetsOperationHandle

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

LoadSubAssetsAsync(AssetInfo)​

异步加载子资源对象

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

YooAsset.SubAssetsOperationHandle

Parameters​
TypeNameDescription
YooAsset.AssetInfoassetInfo资源信息

LoadSubAssetsAsync<TObject>(string)​

异步加载子资源对象

View Source​
Declaration
public 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 SubAssetsOperationHandle LoadSubAssetsAsync(string location, Type type)
Returns​

YooAsset.SubAssetsOperationHandle

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

CreateResourceDownloader(int, int, int)​

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

View Source​
Declaration
public ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
Returns​

YooAsset.ResourceDownloaderOperation

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

CreateResourceDownloader(string, int, int, int)​

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

View Source​
Declaration
public ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
Returns​

YooAsset.ResourceDownloaderOperation

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

CreateResourceDownloader(string[], int, int, int)​

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

View Source​
Declaration
public ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
Returns​

YooAsset.ResourceDownloaderOperation

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

CreateBundleDownloader(string, int, int, int)​

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

View Source​
Declaration
public ResourceDownloaderOperation CreateBundleDownloader(string location, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
Returns​

YooAsset.ResourceDownloaderOperation

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

CreateBundleDownloader(string[], int, int, int)​

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

View Source​
Declaration
public ResourceDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
Returns​

YooAsset.ResourceDownloaderOperation

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

CreateBundleDownloader(AssetInfo, int, int, int)​

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

View Source​
Declaration
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo assetInfo, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
Returns​

YooAsset.ResourceDownloaderOperation

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

CreateBundleDownloader(AssetInfo[], int, int, int)​

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

View Source​
Declaration
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
Returns​

YooAsset.ResourceDownloaderOperation

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

CreateResourceUnpacker(string, int, int)​

创建内置资源解压器

View Source​
Declaration
public 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 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 ResourceUnpackerOperation CreateResourceUnpacker(int unpackingMaxNumber, int failedTryAgain)
Returns​

YooAsset.ResourceUnpackerOperation

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