I. Project folder structure

After creating and opening a Cocos Creator project for the first time, the developer’s project folder will contain the following structure:

Below we will describe the functionality of each folder.

1. Assets

Assets will be used to hold all the local resources, scripts and third-party library files in the game. Only contents in Assets can be displayed in Explorer. After each file in assets is imported into the project, a.meta file with the same name is generated to store the corresponding resource configuration and index information. . Meta files must be submitted to the version control system. For details, see Resource Management Notes – Meta files.

Some engineering or design raw files generated by third-party tools, such as.tps files for TexturePacker or.psd files for Photoshop, can be managed outside of assets.

2. Resource Library

Library is generated by importing assets from assets, where the structure of the file and the format of the assets are processed into the form needed for the final game release. When the Library is lost or damaged, simply delete the entire Library folder and open the project to regenerate the library.

3. Local Settings (Local)

The local folder contains the local machine configuration information of the project, including the editor panel layout, window size, location and other information. Developers don’t need to care about this.

4. Packages for extensions

The Packages folder is used to hold custom extension plug-ins for this project. To manually install extensions, you can create this folder. To uninstall an extension, delete the corresponding folder in Packages.

5. Project Settings

Settings holds project-specific Settings, such as package name, scenario, and platform selection in the Build release menu.

6. Temporary folder (Temp)

Temp is a temporary folder used to cache some temporary Cocos Creator files locally. This folder can be manually deleted after Cocos Creator is turned off, and developers do not need to care about its contents.

7.project.json

Json file and assets folder are used to verify the validity of Cocos Creator project. Only folders containing these two contents can be opened as Cocos Creator project. Developers don’t need to care about what’s in there.

8. Build goals

In using project from the main menu -> Build Publish… After a project is published using the default release path, the editor creates a build directory under the project path and holds all the build projects for the target platform.

Version control

Cocos Creator automatically generates a.gitignore file when creating a project to exclude files that should not be committed to the Git repository. If the developer is using another version control system, or needs to commit the project elsewhere, it should be noted that only assets, Packages, Settings, project.json, or any other manually added associated files need to be submitted.

2. Resource Management Notes – Meta files

Understanding how Creator generates meta files can help you and your team solve resource conflicts, file loss, component property loss, and other common problems in multi-developer development. So what does a meta file do? Let’s take a look.

1. Functions of meta files

Let’s take a look at what the meta file looks like in the scenario:

The meta file for the prefab is the same as the scene. PNG image meta file has a lot of information. In addition to the basic VER and UUID, it also records the image’s width, height, offset, nine squares and other data. With all this information, we only care about one: uUID. Uuid: Universally Unique Identifier UUID is used by Creator to manage game resources. It assigns a unique ID to each file and generates multiple sets of diagrams. You can see that in the Creator engine, a file is identified not simply by path + filename location, but by uUID referencing the file. Therefore, you can delete and move files at will in editor resource management.

2. Update timing of meta files

Meta files are generated by Creator in the following situations:

When opening the project, Creator will scan the assets directory first. If a file does not have a meta file, it will be generated.

Updating resources also causes meta files to be updated:

In Resource Manager, you can modify the name of a resource, change the directory, delete a file, or add a file. For details, see Resource Manager. You can also drag files into Explorer directly from the desktop or the operating system’s file manager. In another case, after adding, deleting, or modifying files in assets directory in the file manager of the operating system, switch to the editor interface, and you can see the refreshing process of resource manager. If a file’s meta file does not exist, both cases trigger the engine to generate the meta file.

3. Errors in meta files and solutions The following sections analyze possible errors in meta files. Uuid conflict UUID conflict is a globally unique uUID, the conflict must be caused by different files with the same UUID, once this problem occurs, Cocos Creator resource manager directory structure load incomplete. As you can see in the picture below, this situation will probably leave you in a cold sweat:

From the prompt you can see the conflicting UUID strings, then open the operating system file manager or code editor and search for this UUID:

Close the Creator editor, delete any meta files, and then open the Creator editor. This works, but references to the resource in the editor will cause the resource to be lost and need to be reedited or reconfigured. It is best to restore this meta file using a version management tool. There are two common reasons for this problem: When moving a file in the operating system’s file manager, the cut and paste operation becomes copy and paste, and the meta file is copied over. Cause two identical meta files to appear in the project at the same time. It is very, very rare to encounter a UUID generated by someone else when updating a resource from a version management tool in collaboration with multiple people that is the same as the UUID generated by a file on your computer. In general, to reduce UUID collisions, it is best to add and move files in the engine resource management tool.

Uuid change

Alternatively, if the UUID is changed and the resource corresponding to the old UUID cannot be found, the interface you edited will lose resources, images, and possibly component properties.

If you can’t find the resource corresponding to the old UUID, you can see from the console that Creator gives very detailed warning information about the scene file name, node path, component, UUID, etc. Warning information can be used to quickly locate faults. How did this happen? When someone adds a new resource to a project, they forget to switch to the editor interface to generate meta files, and at the same time commit these new files to version management (without meta files). Then, someone else updates the submitted resource and switches to the editor screen for editing, and Creator checks that the new resource doesn’t have a meta file and immediately generates it. The meta file is also generated when the first person switches to the editor, so that both computers have the same file, but the UUID in the generated meta file is different. In this case, the person who commits or updates the resource will also encounter conflict, and if the conflict is resolved by force without reason, the problem described above will occur. The following sequence diagram illustrates this faulty workflow:

Because the first student A forgot to generate the meta file and submit it, then everyone else edited the project, but everyone was born with A different UUID, so it would fall into the infinite resource error, edit things, submit update and conflict again.

To solve this problem, pay some attention to the following: queue to check whether a new file is added before committing, and if a new file is added, check whether there is a meta file, which you commit together. Anyway, when you pull a file, pay attention to whether there’s a new file, and a pair of meta files, anyway, and, if not, remind the person who submitted the file earlier to submit the meta file as well. Anyway, when you commit something, if you just buy a new meta file, you automatically create the meta file yourself, so you need to pay attention to whether you use the resource for the meta file (a file with the same name). If not, please submit the meta file from the earliest submitter. Do not submit this meta file. Note that the above points can basically prevent the meta file uUID changes caused by the project error.

** Summary: ** Meta files are an important tool for resource management in Creator, but resource errors can easily occur in collaborative development. To solve this problem, not only do we need to understand how meta files are generated and what causes conflicts, but we also need to standardize the resource submission process.