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
0
Question by LeifStro · Mar 24, 2015 at 06:34 AM · instantiatedestroyloadingdisableenable

Do empty transforms take up much CPU power?

So long story short, I'm developing a game for Mobile set in a city and there are a lot of objects being brought in and out of play as the player moves about.

I have tried numerous methods for seamlessly loading in/out objects.

First I tried instantiating and destroying objects for loading/unloading. This had noticeable spikes for even loading in something simple like a generic 3D box.

Second attempt, I put the Instantiating/Destroying calls into their own Coroutines, this made the spikes less severe, but they were still noticeable.

Thirdly, I decided to pre-instantiate all the objects I'd need and then keep all the ones not in play as deactive (SetActive(false)). It turns out that setting active to true (even done inside a coroutine) had worse performance than instantiating the objects.

So, I finally arrived at my last idea for loading. I preloaded all the needed objects, then manually went through each one's children, disabling each component that could use up CPU. Such components as scripts, renderers, colliders, audio sources, particle systems, rigidbody (set to isKinematic = true) etc were all disabled, leaving only an object with children transforms. Now I can finally enable an object (enable all its components) and the game has no spikes in performance.

However, this last solution has its own draw back. If I preload too many objects the games FPS will be significantly impacted. Event though there is nothing enabled inside the object besides its transforms.

So my question is, does having many transforms (non moving) in the scene cause a significant hit to the CPU usage? and, If so, what is the best way to do continuous loading/unloading of game objects for Mobile?

Comment
Add comment · Show 3
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 supernat · Mar 24, 2015 at 06:35 AM 0
Share

Be sure to mark your objects as static if they aren't going to be moving. I don't know for certain, but it seems that would have a large impact.

avatar image CodeMasterMike · Mar 24, 2015 at 06:40 AM 0
Share

Have you checked to make sure that, it is all the components combined, are causing the spike, or if maybe just one or two components, that are causing the spike?

$$anonymous$$aybe a component (script) makes some expensive calls in a OnEnable/Awake/Start method that causes the spike and not all the components together. Just a thought.

avatar image LeifStro · Mar 24, 2015 at 04:16 PM 0
Share

supernat: I just meant that objects out of play (set to inactive withing the game system) are not moving around or anything. They are just a transform (with possible transform children) that is sitting in an idle state. When brought into the game, these objects might be moving. Thus I cant set them as static, as that is reserved for objects that are never moved or disabled etc.

Code$$anonymous$$aster$$anonymous$$ike: I went through a series of tests, and yeah it turns out that even if every component in a prefab object (including all its children transforms) is set to disabled (enabled = false), game performance still takes a hit if there are a lot of these objects. Simply calling (SetActive = false) on the remaining transform/gameobjects within the prefab causes the performance to go back to normal. So it appears that having a bunch of empty transforms in a scene will have pretty big performance hits (im talking low 1000's of transforms on mobile though).

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Ericool · Mar 24, 2015 at 05:05 PM

put them all in a static array within a script that is init but not updated , create a method to return the ref w/ param an index . But the simpliest solution is to design your architecture first . Nothing should unused for no good reasons .

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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How To Keep GameObjects From Enabling Again? 2 Answers

Why does Unity disable the Collider when I Destroy the Rigidbody? (2D) 1 Answer

When to Destroy Multiple Items 0 Answers

[solved]how can i enable or disable a component of instantiated objects? 5 Answers

Why are my cached (in an array) gameobjects disappearing? 0 Answers


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