На вопрос ответили. Правильный ответ был принят от комментария agentc0re
Instantiate() and Destroy() vs setActive()
I'm making the 2d game, such as minecraft but in 2d, and i have a question about Gameobjects:
I create inventory. it's a component of GameObject of the main camera. In scene exist many GameObjects(Things) having some parameters (strength,cost, etc).
If i want to add/remove things at the inventory, what is better:
1)Destroy the thing and save parameters of this thing in cell at the inventory/ Instantiate the thing and load parameters of this thing from cell at the inventory.
2)Set to inactive the thing and save Transform of this thing in a cell at the inventory/ Set to active the thing and move this thing to the player.
3)Your variant.
Sorry for my english.
P.S. if i want to move Gameobject(Main Camera) with disabled childs(Things in the inventory) in second variant, it's expensive?
Well if you just set it to inactive, I believe the object stays in memory but just 'disappears'. if you do this for many objects you'll just fill up memory for no reason.
When you instantiate it creates a new object and then destroy will, destroy it! :D This is probably what you want to do.
Answer by Thomas-Hawk · Jan 10, 2017 at 10:51 PM
It is harder to destroy something that you instantiated than it is to set something as inactive.
I know it, but if i want to move gameobject with 500 disabled children, it will too slow, doesn't it?
Follow this Question
Related Questions
how to destroy the previously generated prefab so that we can populated with new set of prefabs ? 0 Answers
Issue with Prefab instantiate and script not working? 0 Answers
How to instantiate a game object every time when space key is pressed 2 Answers
gameObject.SetActive (false); not working 2 Answers
Canon Ball shooting with Instiate 1 Answer