Notifications
Article
Unity Tips: .meta Files
Published 6 months ago
84
0
Have you ever heard in your developments the word .meta? If you have done it, do you really know what it is about? If you have never heard it or if you do not know what it really means then this post will help you!
The .meta file is the identification of a specific file when it’s imported inside Assets folder. The .meta file is the identity.
Then the .meta are like the soul of our files that recite within a project of Unity, These appear as invisible in our explorer or finder and are generated by Unity when we import or create an asset (ex: a script, a material, a 3d model, etc).
Let’s see a little more in detail what happens when we create/import a file into Unity.

Creating an Asset

I’ve created a folder inside my empty project and you can see in Finder that there is no .meta but if we press “cmd +shift + .” we will see the hidden files and .meta is now visible.
Tip: to reveal hidden files:
Mac: “cmd +shift + .”
Windows: go to the View toolbar and check Hidden Items

If we import a file from outside of our project into the editor, for example an image, Unity will create a .meta file too! Let’s see!

IMPORTANT!

When you are manipulating assets, just like I did with the image, use the Unity Editor, because if you just copy and paste the image in your Explorer or Finder the .meta file will not be created and possible errors can happen.
So be sure, if you are an artist, game designer, animator, developer or integrator ALWAYS USE THE UNITY EDITOR TO MANIPULATE ASSETS. :)

The .meta file
Let’s see how it looks.
This is the .meta from the folder I’ve created. Metas will vary depending the file that are representing, but every each of them has the most important value that it’s the GUID.
GUID (or UUID) is an acronym for ‘Globally Unique Identifier’ (or ‘Universally Unique Identifier’).
That is the id Unity will use to create references and dependencies between files. Have you ever wonder how a prefab maintains the reference of a scripts or to another GameObject? Well this is the magic!

Connecting files

Let’s see how Unity connect files between them.
First let’s create a Cube in the Scene and make it a prefab.
Now create a script.
And now let’s connect our script with our prefab (Do not forget to Apply changes on the prefab)
Finally we can go to our .prefab file and check if the connection really exists. How? First go to your script .meta file and copy the GUID value and after that open the .prefab file with a Text Editor (Visual Code, Notepad, etc)
There you can find the connection! Search the script GUID in the .prefab.
Now that you know what a .meta file is, what is it role inside Unity, you will understand better the famous Missing (Mono Script). This is because our GameObject or Prefab has a reference to a GUID that does not exists in the project. This happen a lot if teams are not careful and do not commit them in their repositories like Github, Gitlab, Bitbucket, etc.
Missing (Mono Script) example

Summary

Meta files are essential and they have an important role inside Unity development. Be sure to commit them to your repositories, talk to no technical people about this so you can avoid future headaches and now you know something more about Unity!
If you want to see a tool that uses meta files to check references and dependencies between objects you can find it here: Reference Explorer
Martin Gonzalez
Software Engineer at Etermax - Programmer
4
Comments