参考链接:
https://docs.unrealengine.com/latest/INT/Programming/Assets/AsyncLoading/index.html //官方文档
https://wiki.unrealengine.com/TAssetPtr_and_Asynchronous_Asset_Loading //官方维基百科,非常详细
https://forums.unrealengine.com/community/community-content-tools-and-tutorials/4924-tutorial-c-runtime-async-load-modular-character-intermediate //社区
https://forums.unrealengine.com/unreal-engine/feedback-for-epic/documentation-feedback/45301-asynchronous-loading-assets-documentation-erroneous-line //社区
StepOne:建立自己的GameInstance单例,在其中存储一个 FStreamableManager 管理器,这个东西用来管理各项资源
StepTwo:找到要加载的资源
其中知识点:
TAssetPtr<AMyItem> MyItem; //指向尚未加载的资源
可以从TAssetPtr对象中获取FStringAssetReference,
方式:
// the .h
TAssetPtr<ABaseItem> MyItem;
// the .cpp
FStringAssetReference AssetToLoad
AssetToLoad = MyItem.ToStringReference();
AssetLoader.SimpleAsyncLoad(AssetToLoad);
StepThree:开始加载,有两种加载方式
SimpleAsyncLoad //使用这种方式加载将不会进入被垃圾回收,除非手动Unload,只能单个加载
RequestAsyncLoad //加载一个对象数组,并在加载完成时触发委托,当委托被触发时,对象数组中的所有对象会被Unload
https://docs.unrealengine.com/latest/INT/Programming/Assets/AsyncLoading/index.html //官方文档
https://wiki.unrealengine.com/TAssetPtr_and_Asynchronous_Asset_Loading //官方维基百科,非常详细
https://forums.unrealengine.com/community/community-content-tools-and-tutorials/4924-tutorial-c-runtime-async-load-modular-character-intermediate //社区
https://forums.unrealengine.com/unreal-engine/feedback-for-epic/documentation-feedback/45301-asynchronous-loading-assets-documentation-erroneous-line //社区
StepOne:建立自己的GameInstance单例,在其中存储一个 FStreamableManager 管理器,这个东西用来管理各项资源
StepTwo:找到要加载的资源
其中知识点:
TAssetPtr<AMyItem> MyItem; //指向尚未加载的资源
TAssetSubclassOf<T> //没太弄明白
Variable | Description |
TAssetSubclassOf<T> | Points to a subclass of the defined baseclass that hasn't been loaded yet, but can be by request. |
TAssetPtr<T> | Points to asset that hasn't been loaded yet, but can be by request Used to point to Blueprints instead of basic components. |
可以从TAssetPtr对象中获取FStringAssetReference,
方式:
// the .h
TAssetPtr<ABaseItem> MyItem;
// the .cpp
FStringAssetReference AssetToLoad
AssetToLoad = MyItem.ToStringReference();
AssetLoader.SimpleAsyncLoad(AssetToLoad);
StepThree:开始加载,有两种加载方式
SimpleAsyncLoad //使用这种方式加载将不会进入被垃圾回收,除非手动Unload,只能单个加载
RequestAsyncLoad //加载一个对象数组,并在加载完成时触发委托,当委托被触发时,对象数组中的所有对象会被Unload