- Home /
Is it better to destroy and instantiate or turn off mesh renderer?
My game objects are nothing more than planes. They don't have colliders enabled (Sub question, should I get rid off the colliders on them then?) and are only visual. They also need to go away, so would it be better for me to be deleting them and recreating them when I need them back, or just I just disable and enable their mesh renderer?
It's a game inspired by Evil Genius, which was inspired by Dungeon Keeper. The game objects are 4 directional walls for each tile that only exist when they are the border between a room and empty space.
As a general rule… Creating/destroying objects keeps your object hierarchy clean. This may make it easier to understand what's going on if the number of planes is going to vary a lot.
Enabling/disabling objects generates less overhead and so typically will be more performant. However, if the number of planes is going to vary a lot then there's a bit more complexity to manage.
Overall, unless you've got performance problems on a fundamental working game, then just do whatever's easiest to understand and debug.
Answer by DaveA · Jan 27, 2014 at 10:05 PM
It is much more efficient to just turn the renderer on/off. In fact, there are 'pool managers' which can handle a lot of things like that, just google for them. Pretty easy to code but then, why reinvent the wheel.
Your answer
Follow this Question
Related Questions
What's the best way to make a long scrolling list of items? 0 Answers
Optimize huge number of Destroy() calls (cannot use object pooling) 3 Answers
Changing two different objects renderer colour 1 Answer
How do you disable your own Collider? Bugfix 1 Answer
Replace GameObject vs. replacing mesh and material? 2 Answers