Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
6
Question by Schnodahipfe · Apr 11, 2013 at 03:58 PM · mesheditor-scriptingassetexport

Export/Save procedural GameObjects with meshes

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 :)

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image whydoidoit · Apr 11, 2013 at 03:59 PM 0
Share

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...

avatar image MrBorogove · Nov 16, 2015 at 12:23 AM 0
Share

I 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.

3 Replies

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by Schnodahipfe · Apr 15, 2013 at 12:20 PM

I finally found this great plugin, which can save the gameobjects with all its components: http://whydoidoit.com/unityserializer/

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fattie · Apr 15, 2013 at 12:20 PM 0
Share

sorry that nobody told you this more quickly - it's like the single most famous plugin for Unity - everyone uses it

avatar image Schnodahipfe · Apr 15, 2013 at 12:29 PM 0
Share

no worries, it was my lack of expertise that prevented me from finding it because I didn't consider using "serialization" as a search phrase ins$$anonymous$$d of "save" and "export"

avatar image Schnodahipfe · Apr 15, 2013 at 12:32 PM 0
Share

at whydoidoit: I just realized that it was you who commented on my post ;) - great tool!

avatar image whydoidoit · Apr 15, 2013 at 07:43 PM 0
Share

Thanks! Yeah I obviously missed that you want this at runtime :) $$anonymous$$y comment was about creating a mesh inside a prefab (probably because I was doing that just recently).

avatar image Fawar · Jan 30, 2015 at 06:39 PM 0
Share

Does it allows you to save individual prefabs? I want to generate "levelsections" save those individually as prefab and load these prefabs to make copies while the game is really running and not the editor?

avatar image
0

Answer by yusufsermet · Feb 01, 2017 at 09:07 AM

Hi All,

Thanks @Schnodahipfe for the great description of the problem. After 4 years of the original question, I am facing with the same problem. I tried the updated version of the Unity Serializer (link here), however it does not save the scene in an independent file.

What I want to do is to generate a scene (3d maps) in a Unity project, then, I want to load the generated scene from another Unity Project. Is this possible? Any help and leads are extremely appreciated. I have been working on this for quite some time.

Note: Using the updated version of the Unity Serializer, I was able to save and load the scene in the same Unity Project, however, I couldn't make it work in a different project.

Thank you.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DreamWalker_1989 · Feb 23, 2017 at 08:55 AM 0
Share

@yusufsermet Hi, I have the same problem. Do you find someway to solve this issue? save Gameobject in the runtime not editor. If you had solved this issue ,please tell me . Thank you

avatar image
0

Answer by RyanShackelford · Apr 25, 2018 at 11:36 PM

You can save generated meshes as .asset and .prefab files using AssetDatabase and PrefabUtility.

For Assets: https://docs.unity3d.com/ScriptReference/AssetDatabase.CreateAsset.html AssetDatabase.CreateAsset(mesh,"Assets/" + "assetName.asset"); AssetDatabase.SaveAssets();

For Prefabs: https://docs.unity3d.com/ScriptReference/PrefabUtility.html PrefabUtility.CreatePrefab("Assets/Prefabs/saveMeshAsPrefab.prefab", meshGameObject);

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Programmatically Exporting an Asset Package 4 Answers

How to save changes of fbx subassets ? 0 Answers

How to export objects that are part of a single imported FBX file 1 Answer

Maya LT - Export group as single FBX 0 Answers

Unable to save the mesh when RecalculateNormals() is applied to the mesh in the editor script 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges