Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 gnp89 · Jul 11, 2013 at 08:37 PM · meshserializationproceduralprocedural mesh

Serialize mesh in editor

I made slot machine prototype and generated the slot columns procedurally, setting parameters like the number of faces and images from my custom editor. I would like to know how to keep my gameobjects and their properties (values, components, meshes) when I press the play button. And when I stop the game, my values don't come back either. Any suggestions?

alt text

slots.png (154.1 kB)
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by DavidDebnar · Jul 11, 2013 at 08:44 PM

You have two options here:

  1. Use a plugin.

  2. Save the mesh as an asset.

Plugin!

This seems, and probably even is, the simpler of these two. I can personally recommend WhyDoIDoIts Unity Serializer. It can preserve any changes made to variables at runtime.

Asset!

To create an asset at runtime, you'd use AssetDatabase.CreateAsset. It takes 2 parameters, an Object and a String.

 function CreateAsset (mesh : Mesh, name : String) {
      AssetDatabase.CreateAsset(mesh, "Assets/Meshes/"+name);
      AssetDatabase.SaveAssets();
 }


--David--

Comment
Add comment · Show 4 · 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 gnp89 · Jul 11, 2013 at 08:53 PM 0
Share

Well maybe I can use this for a new solution, but its not exactly what I'm looking for. I want objects in my scene (which were created by scripting) persist when I press the play button. I don't want to save and load them. Is this possible?

avatar image DavidDebnar · Jul 11, 2013 at 08:59 PM 0
Share

The Unity Serializer takes care of that too.

avatar image gnp89 · Jul 11, 2013 at 09:32 PM 0
Share

Solved it using [SerializeField] in my script properties

avatar image DavidDebnar · Jul 11, 2013 at 09:46 PM 0
Share

Oh, you should've said you're using C# ;) JS does that automatically, and I'm a heavy JS so I didn't even think of that.

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

16 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 avatar image

Related Questions

Shared Meshes, do they auto-update? 0 Answers

Why does this script put Unity into a not responding state? 0 Answers

Correctly threading calculations 0 Answers

Procedual quad doesnt display texture - only single color 1 Answer

Adding extra materials to a mesh programmatically 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