- Home /
How to efficiently copy a mesh modified during runtime?
Here's a simple icosphere, representing Mars.
At program startup, in an attempt to simulate height, I loop through the vertices and modify them slightly. This gives the planet a sort of bumpy feel.
I now wish to reuse this exact same bumpy mesh. For instance, I want ten other bumpy copies of Mars floating right next to the original bumpy Mars. But I don't want Unity to copy the mesh, since it's quite large. Rather, I want each copy of Mars to reference the one single mesh in memory.
What's the best way to do this? Or am I asking the wrong questions? I'm new at this.
Thanks!
Answer by One Ring · Mar 12, 2015 at 05:13 PM
If you use the same method to make the sphere bumpy then you could just repeat the process, if theres any randomness you could set a seed at the start to make sure it will match.
Won't this result in double the memory usage? I'll have two exactly identical meshes loaded into memory at the same time, whereas I'd like just the one to be reused. Imagine I wanted to copy $$anonymous$$ars a hundred times.
You can probably just get a reference to the mesh and then put that into the mesh filter on the other mars object.
http://docs.unity3d.com/ScriptReference/$$anonymous$$eshFilter.html
Your answer
Follow this Question
Related Questions
Which is more efficient? 1 Answer
How efficient are Mesh Colliders? 2 Answers
Procedural quad, problem with texture 1 Answer
Accessing mesh vertices is extremely inefficient; any workarounds? 0 Answers