Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by Integer Games · Jan 16, 2016 at 04:25 PM · meshsavetutorial

Save mesh generated in game to editor.

I followed this tutorial: https://unity3d.com/learn/tutorials/projects/procedural-cave-generation-tutorial

Every thing worked fine but I want to save the generated cave to the editor.

The finished project is here: https://github.com/SebLague/Procedural-Cave-Generation

I tried pressing play then coping and pasting the cave from play to the editor but the mesh unsets :(

Comment
Add comment · Show 1
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 Cherno · Jan 16, 2016 at 06:13 PM 1
Share

You could try to use EditorUtility.SetDirty, if that doesn't work then you'd have to write and read the data to and from a file, for example with Serialization and a BinaryFormatter. Edit: You can also use Editor Extensions to generate your mesh while in Editor mode; The generated mesh will stay then.

2 Replies

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

Answer by alishka · Jan 16, 2016 at 07:24 PM

I don't know how exactly do you want to "save it to editor", because for reading/displaying raster mesh data, the model has to be saved in a specific format which the engine understands (FBX, OBJ, etc.)

So, say you have generated your cave, I'm assuming you're keeping your mesh data somewhere (I'll read the code on github later). With that mesh data, you can use ExportOBJ, that will let you save your procedurally generated cave (GameObject) into a .OBJ file that will be saved to your project directory for later use. No need to build an exporter from scratch as @Cherno suggested.

Nice work on the cave generator!

Cheers!

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 Integer Games · Jan 17, 2016 at 10:13 AM 0
Share

Thanks, I ended up changing the script to run in the editor.

avatar image
3

Answer by lassade · Jan 17, 2016 at 05:43 AM

If you just want to use it inside the editor you can place ExecuteInEditMode attribute in your cave generator script. You can change the hideflagd of your mesh as well ( if you dont want to keep it, since you always will generate a new one ! ).

Inside the editor as well using an editor script you can simple save the mesh by calling http://docs.unity3d.com/ScriptReference/AssetDatabase.CreateAsset.html, the mesh saved will have a .asset extension and you only can use it inside unity.

Correct if i'm wrong but you want to save the mesh because you cant see it while in editor mode and then you cant create your level from that. If is the case give a look in the how to build editor scripts this way you will be able to create a cave and build a level from that really easy. This is just suggestion you dont really need to.

Comment
Add comment · Show 2 · 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 Integer Games · Jan 17, 2016 at 10:13 AM 0
Share

Thank you.

avatar image alishka · Jan 17, 2016 at 11:38 AM 0
Share

Nice idea! +1

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

6 People are following this question.

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

Related Questions

How do I properly save a procedurally created mesh? 1 Answer

Setting a mesh's triangles and vertices from file causes distortion. 2 Answers

Detecting Mesh and Saving it 1 Answer

How do I create a mesh collider? 2 Answers

Best way to save procedural world/mesh? 0 Answers


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