Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
This question was closed Jan 13, 2017 at 02:48 PM by ya_sayanb for the following reason:

На вопрос ответили. Правильный ответ был принят от комментария agentc0re

avatar image
0
Question by ya_sayanb · Jan 09, 2017 at 04:06 PM · scripting problemgameobjectinstantiatedestroysetactive

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?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image agentc0re · Jan 09, 2017 at 07:20 PM 1
Share

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.

1 Reply

  • Sort: 
avatar image
0

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ya_sayanb · Jan 13, 2017 at 02:30 PM 0
Share

I know it, but if i want to move gameobject with 500 disabled children, it will too slow, doesn't it?

Follow this Question

Answers Answers and Comments

120 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges