Packing and Subcontracting Tool Process Record

Process record:

Start packing AB

1. Collect resource paths that need to be packaged

The collection resource logic is extracted to make Mgr, and the collected resources are accessed with a dictionary, and the key value is the resource path. (Use DirectoryInfo.GetFileSystemInfos() and FileInfonfo of the IO stream to get the complete directory (this method should pay attention: if the obtained directory is "\" or "//", it should be replaced with "/")) When collecting resources, it will be based
insert image description here
on The above description configures to read the text document with the corresponding name in the Assets\Resources\Config\AbEditorConfig directory, for example

insert image description here
This configuration directory is to ignore the resource directory, and the resources under this will not be collected and packaged.

insert image description here
All other resources that resources in this directory depend on will be cached when packaged to avoid repeated packaging operations.

First collect all files in the Asset/Scenes directory, recursively traverse all subdirectories, and return a list of all resource paths that need to be packaged. Then collect Resources, and then store them together in the collection resource Mgr, and perform a screening during the storage process.

insert image description hereWhether it is a script, whether the file type is ignored, whether it is a shader, the shader file is unified with an AB name, and unified into a whole AB, which is convenient for frequent reference.

Then collect the AssetBundle that comes with Unity. After collecting these, start the merge operation. The first step is to deduplicate the AB resources set by Unity, and the second part merges all the dependent resources of AB set by Unity and the resources that the previously collected resource paths depend on. ,

insert image description here

The above is to collect all the resource paths that need to be packaged.

2. Export AB resources

insert image description here
Convert the collected resource path into AssetBundleBuild, obtain the hash value of the resource file, and pack it into the corresponding AB directory. It is divided into two directories, one directory archives the ab that needs to be compressed, and the other directory stores the ab that does not need to be compressed. The abs that need to be compressed are mainly scenes, shaders, and large-scale ab resources that are relatively common.

Then calculate the md5 of AB, and write this information into the directory index structure.

The following is the index structure of the ab resource,

Root index structure of Ab resource
{“list”:[{“path”:“assets_resources_config_platforminfo.bytes.ab”,“md5_ex”:“a09fe92520e9e4d1f607384831c13c82”,“size”:1947,“md5”:“16d668acdf6d31531f0fdcbf7538a199”,“crc”:2476629122},
{“path”:“assets_resources_config_resbin_carnivalsubtaskconfig.bytes.ab”,“md5_ex”:“6aa66d8eab7c3b74f49575e54df42f0b”,“size”:2363,“md5”:“aa8d06da54959fd6a43d23f00bc4d2c4”,“crc”:4005958029}
insert image description here

3. Export all dlls used in the project

Export the native project of the packaging platform.

insert image description here
Copy the code in the source project to the base project in the special subpackage directory.

Let’s talk about copying the DLL in the source project, and then use the tool http://stahlworks.com/dev/?tool=zipunzip to compress and encrypt it once.

4. Compress AB

Read the md5 of ab through the original index directory structure, use md5 to filter out the ab resources that do not need to be compressed, and use the 7z.exe tool to compress. After compression, the original ab name will be replaced.

5. Copy the packaged AB resources to the subcontract project directory

insert image description here

Start subcontracting

Use the form application developed by C# to select channels and subcontract operations. The tool UI form is as follows:

insert image description here
On the left is the selection channel, and on the right is the configuration.

insert image description here
First initialize the path, click Generate to start subcontracting.

The specific subcontracting process is as follows

  1. First copy the parent project to a temporary directory.
  2. Then read the channel resource configuration
  3. Copy the relevant configuration files of the channel to the temporary directory, and merge them if there are files whose file name suffix is ​​Xml in the temporary project.

insert image description hereMerge operation: recursive traversal, pass in two parent nodes, first traverse the child nodes of the source xml, and find the node with the same name from the child nodes of the target xml.
It should be noted that when searching for the same name, if the name is an intent-filter, special processing is required, and then find the attribute value of the node whose name is Action in the sub-nodes under the intent-filter and whose attribute name is "name". If the attribute value Return the same.
If the same node is not found, a new element is added in the target xml, which is equivalent to copying.
If the same node is found, compare whether the attribute is missing.insert image description here

  • Merge the configuration under Common first.
  • If the dependent channel is not empty, the dependent channel needs to be merged again.
  • Merge the selected destination funnels one more time at the end.
  1. Start to set the signature information, read out the signature path and password configured in the tool, and add it to the signingConfigs tag in the build.gradle in the temporary project.
  2. Check if AndroidSdk is configured and generate local.properties
  3. Execute the gradle clean command
  4. Execute gradle assembleRelease to start packaging.
  5. Check whether the release apk is normally displayed under the temporary project, read the package name configured in the Manifest, and rename the apk.
  6. Finally, copy the APK to the input directory.

The above is the record of all the packaging and subcontracting process, which is used for recording and review.

Guess you like

Origin blog.csdn.net/a525324105/article/details/123105730