- Home /
Meshes as Variables...
If I assign a mesh in the editor to a public variable in script of type "Mesh", when I assign it's content to an object (...meshFilter.mesh = ...), does Unity LOAD the Mesh then, or is it already cached in memory?
I change meshes on a number of my objects over the course of the game, and I'm noticing quite a bit of slowdown, even on iPhone 3GS. This shouldn't be the case, as there are only around 20 objects, and they're all box colliders?
Anyone have any ideas?
Answer by Brian-Kehrer · Jan 26, 2010 at 05:29 AM
Why not attach all the various meshes to a parent gameObject, and simply turn on or off the ones you need or don't need?
Answer by thom · Jan 26, 2010 at 05:10 AM
Can you use prefabs? The performance will be far greater if you are using prefabs.
Prefabs have no effect on performance. They exist primarily for convenience and workflow reasons; for example a cube placed manually and a cube instantiated as a prefab are identical in the actual scene.
I was under the impression that prefabs use shared meshes and shared materials so performance would be improved. Certainly the tutorials I learned on stressed creation of prefabs for performance but thanks for the heads up--I learn something every day!
Answer by andeeee · Jan 13, 2010 at 08:47 PM
When you assign the mesh, it gets loaded into the graphics hardware. I think that is what slows things down.
Answer by S7ARBVCK · Jan 15, 2010 at 12:45 PM
Any way to get around this, then? Any way to "pre-load" meshes so I don't get the performance hit?