- Home /
adding meta data to fbx file and then reading it in unity
Is there a way to add metadata to an fbx file and then reading it in unity? I was hoping I could initialize some variables inside the actual fbx file so when it dynamically imports into the game, the game already knows what to do with it.
Answer by Paulius-Liekis · May 08, 2011 at 09:13 PM
You can import User Properties from FBX files. Use AssetPostprocessor class for reading them.
interesting, is that something ill find in the fbx exporter?
Do you know where I can find more information on this?
I did find a user defined properties dialog in 3dsmax when you right click on an object. Are you saying that anything in this dialog gets exported as part of the fbx file?
Yes. Unity imports ints, floats, strings, and Vector3, IIRC
This is great! I found the function to accomplish just this, now the documentation states that this is an Editor Class function, which im assu$$anonymous$$g means I cant do this at runtime. All objects are dynamically imported into the game using Resources.Load command. So will I still be able to use this? Or will this automatically happen when the objects are found in the folder when the Unity Editor starts up and says "Importing"?
Yes, you can't do this in runtime. The idea is that you load them using AssetPostprocessor during load time and store somewhere and then reuse stored values in runtime.
Answer by Jean-Fabre · May 08, 2011 at 08:40 PM
Hi,
For this, you are better off writing a maxscript ( or any language available in your soft), and save meta data in a seperate file. This allow to define anything and everything and in the format you like, xml, csv. The other benefit of such maxscript or custom export command is that you can preconfigure the fbx exporter, export several fbx in one go ( when you need to seperate your scene into chunks). Doing so gives you flexibility and you can modify the metadata or read the meta data with much more ease then if it was embedded in the fbx, because such metadats is likely to only answer the very specific needs of your game or framework.
Bye,
Jean
well if im going to use a separate file I could probably just use a txt format, and parse the information out of it. I guess then I would have to rename it to the same name as the fbx and look for it in my code when i dynamically import it though script? Actually an X$$anonymous$$L file would probably be easier to parse.
You would need to code the dynamic importing and the parsing ( be it using a xml lib or your own parser). So in all cases, it will be a text format and you'll need both writer and reader to be written, the writer in your preffered 3d software and the reader in Unity. You could make it binary... but I don't see the point unless you have large files or wants some obfuscation or protection
Your answer
Follow this Question
Related Questions
Working with complex FBX files 0 Answers
FBX Import model won't change transform in playmode, only in Scenepreview. Why? 1 Answer
Imported FBX from Google sketchup to unity has too many meshes, how to export/import properly? 1 Answer
Mb to fbx strange crushing issue 2 Answers
Confusion with using textures for blender fbx models 0 Answers