Version: 2023.1

AssetBundle.LoadAssetAsync

切换到手册
public AssetBundleRequest LoadAssetAsync (string name);
public AssetBundleRequest LoadAssetAsync (string name);
public AssetBundleRequest LoadAssetAsync (string name, Type type);

参数

name Name of the Asset. For the most precise matching this should be the relative path of the Asset that was built into the AssetBundle, including the file extension. The relative path and file extension are optional, and Assets can be found and loaded based on the filename alone. However this opens the potential for unexpected results if the filename is not unique within the AssetBundle. At build time it is also possible to specify a name for the Asset using AssetBundleBuild.addressableNames. In that case that specified name will be expected to load the Asset instead of the Asset path.
type The provided type will be checked against the Asset's main object, and if that is not compatible it will be matched against visible objects within the Asset. Not all nested objects are visible, for example this will not work to directly retrieve a Transform, MonoBehaviour or other Component. In cases where there are multiple matches for the name argument, the requested type can determine which Asset to load.

描述

Asynchronously loads an Asset from the bundle.

The LoadAssetAsync<T> signature is recommended, so that the requested type is explicit and no type casting is necessary.

Note: For Scenes inside AssetBundles call SceneManager.LoadSceneAsync instead of this method.

See Also: AssetBundleRequest.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961