Unity script .meta files

First of, a little announcement – not only is this my first post on Ninjacrab but it is also my first ever blog post. Cue fanfare and digital equivalent of confetti (twitter posts?). Will try to keep posting here as we progress on the project, mostly for the externalization of memory as my internal memory has been proven time and time again by various parties (well mostly just one person) to be unreliable. Oh and also hopefully the tips/tricks/gotchas we post here pop up on someone’s Google/Bing search sometime and save them some time and stress.

Anyway, we learned something new about the .meta files that Unity automatically generates for .cs scripts. Thus far these have been merrily version controlled along with the rest of unity/code files. Min recently wanted to see if we can do without versioning these to clean things the repo up a bit, and just allow Unity to auto generate them on each individual developer’s box. Seemed like an OK idea – until we ran into an issue. The script’s .meta files contain a Unity-assigned script GUID, that is then referenced in the Unity objects when assigned –

Example:
ExampleScript.cs
ExampleScript.cs.meta
guid: c4dd34a10729e324592f904cfe9a64da

ExampleScene.unity
m_Script: {fileID: 11500000, guid: c4dd34a10729e324592f904cfe9a64da, type: 3}

So when I grabbed latest, Unity did not see a .meta file for the script so it presumably generated its own (desired), but then the newly generated GUID didn’t match up with what was assigned in the .unity file. Makes sense in hindsight.

K, time to do some coding.

Leave a Reply