How unity loads resources from Assetbundles

Source: Internet
Author: User
Loading and unloading objects in a resource bundle (Assetbundle)

After you use the downloaded Data Build resource bundle (Assetbundle) object, you can load the objects contained in it in three different ways:

  • Assetbundle.load uses its name identifier as the parameter-loading object. Its name is the name that appears in Project view. You can choose to pass the object type as a parameter to the load class function to ensure that a specific type of object is loaded.
  • Assetbundle.loadasync works the same way as the above load class function, but does not block the main thread after the resource is loaded. This method is useful for loading large resources, or loading multiple resources at once, to prevent applications from stopping running.
  • Assetbundle.loadall will load all objects in the resource bundle (Assetbundle). Like Assetbundle.load, objects can be selectively filtered according to their type.

To unload a resource, you need to use Assetbundle.unload. This class function contains a Boolean parameter that tells Unity whether to unload all data (including loaded resource objects) or only the compressed data in the downloaded resource bundle. If your application is using some of the objects in this resource bundle (Assetbundle) and you need to free some memory, you can pass false to unload the compressed data in memory. If you want to completely unload all objects of the resource bundle (Assetbundle), you should pass true to destroy the resources loaded from the resource bundle (Assets).

Asynchronously loading an object from a resource bundle (Assetbundles)

You can use the Assetbundle.loadasync class function to load objects asynchronously, reducing the likelihood of an application being temporarily interrupted.

How unity loads resources from Assetbundles

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.