"Komatsu teaches you to develop" "Unity system Module Development" Unity Assetbundle Pack Notes

Source: Internet
Author: User

* Recent Project updated Unity5.5.2, and by the way updated the Project UI packaging, also update the notes here

First, the package is divided into two parts, part is packaged into a assetbundle package, part of the package from the Assetbundle to become available resources.

First, the first part is packaged.

All resources can be packaged, not even resources (some data) can also be packaged as long as you need.

Packaged things can be used directly, a font, a texture, a prefab, a scene, are a dozen out into the Assetbundle package can be used directly, but why do we still have to develop their own packaging process it?

The most important reason is that if you package everything directly, such as you are developing two UI interfaces, these two UI interfaces use the same texture, the same font, and you each pack two prefab, This texture and this font will be included in the two bundle bundles, which means that it duplicates the memory that it occupies.

So in order to solve this problem, basically each project will be in the packaging of the same resources used to texture,atlas,font the same resource stripping, recording, and then packaging, wait for the time to load back.

This is the main development work for each project's own packaging process.

Now the Unity version (our project is unity5.3.5f) provides a stripping method, and the previous unity version needs to be stripped. I'll talk about it in the next two. (Although you only need one, in order to tell the details of both)

Next, we'll talk about the packaging process for our project.

First of all, packaging general Texture,atlas are relatively simple, there are two more special needs to develop independently of the situation

1. Packaging Panel (UI interface)

2. Pack scene (game scene)

First of all, packing panel.

You will use a lot of pictures in a UI interface, many fonts, whether it's atlas or texture you need to peel them off.

Packing panel We use our own stripping method.

Suppose there is now a battleui.prefab

Here is the packing step.

1. Clean up the data and create a folder (for different types of files, such as texture, Atlas)

2.prefabutils.instantiate instantiate this prefab.

3. Get all the dynamic components under this instantiated prefab (see different items)

4. Get all the Ngui scripts that are hanging on this gameobject. (If there are dynamic components, each dynamic component will also traverse all Ngui scripts)

5. Copy the Ngui script and use a class to store and mount the Gameobject, such as:

Public Class PRefabHierarchyInfo:MonoBehavior  {   public Transform[] transforms;   public UILabel[] uilabels;   public UIPanel[] uipanels;   public UISprite[] uisprites;  }  

6. Record the referenced texture, Atlas, Font, Panel (interface)
7. Empty the Texture.atlas that the original Ngui script woman quoted

* The purpose of step 3-7 is to use this interface or multiple interfaces to the Texutre, Atlas information to come out, unified processing, or direct packaging will be a resource exists multiple

8. Package all the resources found in step 6 buildpipeline.build (if Atlas is not creategameobject, use Prefabutility.createprefab () (You can also set the Atlas properties for different platforms depending on the requirements)
9. Packing panel

* Originally wanted to write here, found something too much another article to record

* Below is a link to update the new packaged UI method

http://blog.csdn.net/chrisfxs/article/details/60136875

Next comes the packaging scene

The purpose of the packaging scenario is to extract all the dynamic components in the scene and separate and package all the material and shader

And the way we packaged the scene chose now Unity's auto-stripping method (the Assetbundle name will be packaged individually (automatically separated) (with Assetimporter class, change assetimporter.assetbundlename))

Here are the packing steps:

1. Clear All Assetbundlename

2. Find all the scenes in the project that need to be packaged

3. Find everything in each scene that needs to be packaged and packaged separately (e.g. material, Shader)

4. Get the resource address of all the objects that need to be packaged, a scene to write a config file and put it inside

5. Change the assetbundlename of each scene

6. Assetbundlename (e.g. shader, Texture, Material, gameobject (dynamic components)) for each object that needs to be individually packaged (stripped)

7.buildpipeline.buildassetbundle ()

The packaging system will peel off the assetbundlename and pack it all alone, leaving the remaining unity into a scene package

This basically completes the packing work.

Next comes the unpacking.

Load panel

1. Load Assetbundle (Assetbundle.loadfromfileasync (path))

2. Put in memory

3. When you open the interface, instantiate the interface class and restore the data. For example, CDialog is the interface class, cpanel the data class for this interface, and re-assigns the data such as Atlas and font that were previously packaged in process 6-7 records back

Loading scene scenes

1. Load Config

2. Load scene to Memory

3. Walkthrough Scene

4. Load Shader,texture

5. Load Material

*4.5 These two order cannot, because before packing has the dependency, loads the material to load the shader first, Texture

6. Load dynamic components (rearrange objects and other information based on previous config)

...

"Komatsu teaches you to develop" "Unity system Module Development" Unity Assetbundle Pack Notes

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.