Hi all,
I’m new to unity (first post) and I apologize in advance if there is an obvious answer to this question, but I promise I’ve been looking for a solution for ages now and haven’t found one.
I have a unity project that generates gameobjects with meshes during runtime. This obviously means that my gameobjects are removed from the scene as soon as I hit stop. I want to export these gameobjects (or the whole scene including these) so I can reuse them in another unity project so that the generation process won’t be needed next time. The problem is, that I want to export all components and dependencies of the gameobjects.
What I tried:
- Save the scene via File → Save scene. Problem: as you know, you can’t save a scene whilst in play mode and all the changes made in play mode will be discarded on stop.
- Make prefabs from the generated gameobjects. Problem: the meshes aren’t being attached to the prefabs.
- Export the objects via Assets → Export Package… . Problem: this doesn’t save any of the generated gameobjects.
- Use the EditorObjExporter.cs script from http://wiki.unity3d.com/index.php?title=ObjExporter . Problem: this only exports the meshes without the other gameobject components.
- Create an editor script that saves selected gameobjects to an asset and then exports them into a package. Problem: importing the package in a new project results in gameobjects which are missing basically all the information from the original gameobjects except maybe the name.
What I think could work but haven’t tried so far, since I very much hope there is a simpler solution:
- Save the procedural gameobjects with the help of assetbundles. However, that seems overly complicated to me, since I only want a local copy of the gameobjects and don’t need any streaming functionality.
- Save the gameobjects as prefabs and separately save the meshes and somehow put both back together in the new project via scripts.
Thanks in advance for your help
You have to save the meshes as an asset - no choice over that I'm afraid. I'm pretty sure that you can fix it so the mesh is added to the prefab though. You would need to use the AssetDatabase functions to do this...
– PalermoI signed in just to upvote the question. Besides the fact that it's exactly the same thing I want to do, it's clearly written, explaining what you're doing and why, with excellent "here's what I tried/here's what happened" support. Pure Gold.
– Calisa