The role of the .meta file is simply to build
a "bridge" between
Unity and resources.
When referencing a game resource in the game, Unity
does not directly follow the path or name of the file, but uses a unique GUID
to point to the resource file in the project.
This GUID
is stored in the
meta file generated by
the Unity
project for each resource and file
. In addition to the GUID , the meta file also stores information about resource imports. For example, texture assets can be imported as standard textures, normal maps, GUI textures, cookies , or lightmaps. These import settings will be stored in the meta file.
GUID Advantages: Move, rename or modify the content of a resource, and the resource can still be referenced by GUID (as long as the
GUID
remains unchanged, the resource can be referenced.
GUID Disadvantages: You must clearly realize that Meta files are associated with specific resources. If you delete a meta file,
Unity
will think that the original resource file has been deleted, and then
generate a new one for this "
new
" resource file.
GUID
.
_
This is the most common cause of broken resource references in game scenes.
When importing new assets into Unity , Unity will automatically do the following :
1.
Assign a unique
ID
2.
Create a
.meta
file
3.
Processing resources
1.
Assign a unique
ID
:
Unity will maintain a list of its own resources. When importing resources into
Unity ,
Unity will first detect this resource list, and then assign a unique ID to the imported resources . This ID will be used to refer to resources in Unity .
2.
Create a
.meta
file
Unity
added the .meta file after version
4.2
, if you can't see the .meta file in the version after 4.2 , you can set the following settings :
Set the Visible meta Files option in the Edit->Project Settings->Editor / VersionControl option
After the above actions, open the project directory (
in
the Project
panel, right-click to select
the Show in Explorer option
),
and you can see the files with
the .meta
suffix. You can see
that Unity has created a
.meta file
for each file and folder in the Assets file
.
3.
Processing resources
Unity will convert the data you import into the project into data that
Unity
can recognize when the editor is running, and these data will be stored in the project's Library
file.
The content in the
Library file is automatically generated by
Unity , so we don't need to
modify the Library file. When performing version control on Unity projects, there is no need to
To add
the Library
file to it.
The role of the meta file
1. It is a file used to assist in the management of
Unity
resource files.
Unity
distinguishes different resources in the project
according to
the GUID recorded in
the meta ;
2. meta also records some very important information of corresponding resources, such as:
information of each resource Inspector, etc.
The meta
file generally contains the following content
guid: We said above that Unity will assign a unique
ID
, which is stored here
MonoImporter: According to different file types, its data is different ImprotSetting data, such as Mode Improter
, Audio Improter, etc., and
you can understand each row of data by referring to the
Inspector panel