Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
1
Question by Nercoe · Mar 11, 2013 at 11:53 AM · memorysetactivespike

gameObject.SetActive (false); stored in memory?

Hey guys, I am just curious to know whether or not my game objects are stored in memory when I use this. Probably a simple answer but it's been bugging me for a while and I believe it replaced setActiveRecursively which is what I used to use. Any help appreciated :)

When I say stored in memory, what I mean is... will it cause lag spikes if it is set to inactive (if I have a lot of models set to inactive)?

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Khada · Mar 11, 2013 at 01:03 PM

Read here for details on the changes to active states, but essentially you're correct about it replacing setActiveRecursively.

The object is not deleted and recreated, they are simply disabled. There should be no lag spikes due to the act of enabling/disabling an object unless the object itself causes such behavior.

Comment
Add comment · Show 2 · 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 Nercoe · Mar 11, 2013 at 01:33 PM 0
Share

Perfect, thanks a lot :)

avatar image Khada · Mar 11, 2013 at 02:11 PM 0
Share

You're welcome.

avatar image
3

Answer by Owen-Reynolds · Mar 11, 2013 at 03:50 PM

The standard trick (inside Unity) is to have a list of Active objects and another one of inactive objects. But then, the program only ever looks at the Active list.

So, if you have 10 actives and 10,000 inactives, sure those 10,000 take up the same memory as when they were active, but the game loop only runs 10 updates, collisions only check 10 things. The rule that GameObject.Find won't find inactive objects is because it only searches those 10 things. Overall performance is as if the inactives never existed.

They also only sort-of take up memory. The operating system and CPU put infrequently used memory in the low-speed area, or even out to disk. So inactive objects will pretty quickly get moved "out of the way." So, on a PC, you could have many more objects than will fit in memory, as long as the actives one will.

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 Nercoe · Mar 12, 2013 at 11:18 PM 0
Share

Thanks for the information, I feel I understand it fully now :)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 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

Related Questions

physics.OverlapSphere colliders 1 Answer

Wii graphic specs 1 Answer

Problems with large script 3 Answers

How do I calculate how big my struct is? 2 Answers

bug or new feature ? 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