I believe that the U3D Project is a little bigger. We all use unitypackage to transfer resources and share work, right?
The problem is that after the unitypackage provided by art is imported to the program, the problem of missing mono behaviour will always occur, that is, the script is lost. I don't know if you have ever encountered it. After several times, I finally got angry two days ago and wanted to completely solve the problem.
This article is some experience in solving this problem. At last, we found that, under good working standards, this problem should almost never occur. Many of our projects are historical issues, metafile should be enabled at the earliest stage of the project and managed by the SVN version.
Meta File
U3D comes with file version management, which can be selected in project setting-Editor-version control. Generally, it is managed by generating meta files.
Meta File records the content.
1. U3D current file format version number
2. Unique Identifier of each file: guid.
3. Some information related to the specific file type, such as a script file, will record additional information such as executionorder. PNG files will record information such as texture size and mipmap.
In the middle, the most important thing is the guid, which will be discussed later.
Miss mono behaviour is mainly used to process scripts, so I use the script object as an example. In fact, the skills in this article can be extended to any type of files, which is just a matter of simplicity.
Script File:. CS File
Container files:. Unity and. Prefab files
The difference is that the script file can only be mounted to the gameobject as a component object, while the gameobject will only be in the scene (. unity) and prefab (. in prefab), container files are processed in the same way. the Unity file is used as an example.
Container files and Other Related Files
2. Open the. unityfile. The tool I recommend is fairdellhexcmp.exe. You can find the referenced script components, such as "ABC. cs". We can see that the unity file is recorded.
1. pathname starting with the Assets Directory, such as "assets/artcode/ABC. cs"
2. serial format of guid
3. Library/Cache/C9/c9123456789012eec9123456789012ee
Related Files include
1. guidmapper File
2. Metadata directory
3. cache directory
4. assetdatabase3 File
The file guidmapper records the relationship between short file names and guids.
Assetdatabase3 records the correspondence between the full file path and the cache file.
Metadata, the cache records the current script file format information and content information, that is, the U3D version management core data.
When the content of the script file changes, the guid does not actually change. In addition, U3D does not actually implement Version Management Based on incremental file content changes, but overwrites it. This also explains why most of its files are binary.
Guid generation and its user
GUID is the unique identifier of a file. The associations in the container file are based on guid rather than the file name and file path. After a new file is created, U3D automatically generates a guid for it.
Assume that the script ABC. CS is created, and U3D assigns the guid c9123456789012eec9123456789012ee to it, which is recorded in the ABC. cs. Meta File.
Then we mounted the script to an object in scene and saved the scenario as SSS. Unity.
Now we can know SSS. guid, ABC. CS. the GUID is also recorded in the meta file, and the four related files at the forefront have also changed. These six changes are automatically performed by U3D when The GUID is generated.
Generation of Miss mono behaviour problems
SSS on my machine. ABC. Recorded in Unity. the GUID of CS is AAA, But if I only give you ABC. CS instead of ABC. CS. meta File, then your machine will generate a guid, which is different from mine's BBB, so the problem arises. After that, if you import the SSS. unitypackage, you will have the Miss mono behaviour problem.
This is because the guid of ABC. CS referenced by SSS. Unity on your machine is AAA, but in fact there is no file record of this GUID in related 4 files.
This problem is essentially a usage error caused by a lack of understanding of U3D version management. It is very common in the early stage of the project, and you do not know whether it is swollen, as a result, this error is spread to a considerable number of scene. This is terrible. I have to be careful to check which script is missing.
Solution
Basically, it is to keep guids consistent everywhere, which are
[Manual modification] meta file of the script
[Manual modification] references in the container File
[U3D Automatic Modification] file named after guid in Library/Cache
[U3D Automatic Modification] file named guid in Library/metadata
[U3D Automatic Modification] ing between library and guidmapper
[U3D Automatic Modification] ing between library and assetdatabase3
If AAA is in SSS. Unity and BBB is on your machine, you only need to copy the Meta File of AAA.
Complexity
(Always, but, isn't it)
In the process of solving the problem, more than one error is found,
1. GUID is inconsistent between the two machines
2. inconsistency between the guid references in the container file on the two machines
3. Inconsistent script paths
4. The script file is missing.
The above four types of errors may occur randomly. They are all caused by the nonstandard multi-person collaboration process. It is impossible to standardize the four types of errors. Will some people always make some mistakes?
Based on the above analysis, I made an automated tool for the actual situation of the project, and maintained file guid synchronization between art, planning, and programs, C # It is disgusting to write binary files. The source code of this tool is not included in the company's Intranet, but I believe that after knowing the cause of this problem, it is not far away to solve it. Come on, let's look at it.