I’m creating a sphere model (including generating vertices etc) via a script.
It takes a long time, since i use a lot of vertices.
Q: Can I do it once, and take the “generated” sphere into the editor as a prefab ? this way i can “spawn” the prefab on the game in zero time, instead of waiting for the sphere generation ?
I tried using PrefabUtility.CreatePrefab , but the created prefab does not seem to contain the vertices i created in run time.
Any ideas ?
If you want to save it in your unity project as a file that’s a little complicated and likely involves more than a few editor classes. It might be easier to create an OBJ file and then import it.
If however you just need to clone it at runtime. Your process creates a mesh, so as long as you hold onto that memory reference you can refer to it as many times as you need. If you just want to clone the whole object, use Object.Instantiate().
Clones the object original and returns the clone.
This function makes a copy of an object in a similar way to the Duplicate command in the editor. If you are cloning a GameObject then you can also optionally specify its position and rotation (these will default to Vector3.zero and Quaternion.identity respectively). If you are cloning a Component then the GameObject is is attached to will also be cloned, again with an optional position and rotation.