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?

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–