- Home /
Can I generate meta files by myself
We have some files stored out of Asset folder. When used, we export them to .bytes format and copy to Asset/Resources/Filebytes. So if we add a new file, we don't have its meta file generated by Unity. Can we generate this meta file manually (not by Unity) but with the same file format of Unity ? We promise to avoid generate same GUID, and are there any other risks?
Thanks a lot!
Hi I have been struggling to do this myself. My main problem with generating the meta is not the metafile itself, but that my scripts are not serialized into whereever Unity places those script assemblies.. This means I cannot compile the project without openening the Unity editor. If anyone has any idea how to solve this please let me know.
@petersvp You seem to know a lot about the meta files and how they are used in unity, do you know how unity handles metafiles, guids and assemblies for scripts in the asset folder?
Do not hijack other posts, especially if your question is not directly related to the question that was asked or if the question is very old. Both facts are true here. The question was about generating asset files (bytes extension) and not script files. Also the question is 7 years old. If you have your own question, please ask your own seperate question instead of posting an Answer to an ancient question that does not answer the question.
Answer by UNZoOM · Apr 02, 2015 at 04:17 PM
No , you cannot. Reason being , you cannot generate GUID's ( as they are Auto Generated ) based on versioning which are linked to .unity package files.
Answer by petersvp · Apr 09, 2019 at 01:18 PM
Well, basically, you can, IF and only IF you know what you are doing.
Make sure your UUID is project-wise unique. This means: you must load every single meta file in your project and build a database with used uuids (SLOW but correct!). Or you can dir-list Library/Metadata/* subfolders and use any .info file's filename as a UUID (fastest, but requires the project to be saved in unity for correct results) . This way you generate a collection of all UUIDs in your unity project.
Make sure your IDS are stable. Unity does not require proper UUIDs, any 128-bit number beside zero will succeed. This means you can use md5 hashing strategy to generate uuids. Be sure you have mechanism to avoid collisions!
In Unity, uuids are whatever makes, and breaks, references. When you assign a texture to material, you asign it by uuid. You need to have code to manage such links.
With this in mind you are, basically, safe to go. But! ALWAYS use Version Control. If you generate assets from INSIDE unity, prefer to use AssetDatabase. But in my case, and in any case where you generate assets procedurally, like in my case, I am generating materials with linked textures from outside of unity, you must generate exactly the same, expected YAML files with hex-parseable, project-unique 128-bit numbers as uuids.
Answer by lnz611 · Mar 19 at 01:39 PM
Hi, I managed to generate the metafiles manually using GUIDs that ensure there will be no collisions using a relatively simple Scala script. For assets and scenes its not as much of a problem. With scene files (not sure if you are interested in that too) it looks highly complicated but follows a nice YAML structure and is easy to do once you get it. However, with things such as C# scripts you have to be careful as they will need script assemblies. I know this post is old, but if you are still interested in this or if anyone else comes by this post looking for this feel free to contact me
Your answer
Follow this Question
Related Questions
Stop MetaData coming up in FileInfo. 1 Answer
Project automatically reimports, changing GUIDs in the meta files. 0 Answers
Is it safe to share .meta files of scripts across multiple projects? 1 Answer
Are .meta files included in an APK if they are in StreamingAssets? 0 Answers
Windows Phone 8.1 compiling problem 1 Answer