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 Ren · Mar 25, 2011 at 02:06 AM · gameobjectoptimizationupdateefficiency

Efficiency of Game Loops

What is the difference between letting the objects run their own update functions during run time, versus, using a Game Manager to call their "update" functions during run time? Is there any efficiency cost of using a GameManager Class to run the game rather than just using the default component based system that Unity provides?

==========================================================================

Example of Component Based:

Script1:

function Update() { // Run Object 1's Update stuff; }

Script2:

function Update() { // Run Object 2's Update stuff; }

And so on...

==========================================================================

Example of Using a Game Manager:

public class GameManager : MonoBehaviour {

// Update Function for the Game Manager Class

void Update() { // Check for Input and Assign values to Player

 // Update Player

 // Update Environment

 // Update so on...

}

}

===========================================================================

Feedback would be greatly appreciated... Thank you (:

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 Eric5h5 · Mar 25, 2011 at 02:28 AM

If you mean looping through all objects in a single Update function as opposed to having each object use its own Update function, then yes, there is overhead involved in an Update call that you can eliminate by consolidating them.

However, it's questionable whether you would call this "improved efficiency". It's likely your code will become more complicated, for one, which means more chance for bugs. It's possible you're not CPU-limited in the first place, or that the Update calls are contributing a small enough amount that "fixing" this won't actually improve the framerate at all. Also, it's possible that you're better off not using Update in the first place anyway, and would find coroutines or other methods like InvokeRepeating more effective.

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 Ren · Mar 25, 2011 at 02:54 AM 0
Share

Hey Thanks Eric,

I was just wondering whether consolidation of the objects in a single update function would cause a drop in efficiency, since Unity was built to be component based.

I don't have much CPU power to play around with since it's the iPhone.

Well for me i prefer having objects in my control and choosing which to update each frame, so i think i would prefer having an array of objects and have them have a scheduled update given by the Game$$anonymous$$anager.

Anyway, thanks a lot for the answer :D

Cheers,

Renqi

avatar image
0

Answer by meat5000 · Aug 10, 2013 at 12:11 PM

A central game manager, in my opinion should only be used in specific circumstances.

Imagine a variable 'x' from a script 'Script'. If x is used in an update of Script :

Use -> x;

If you use a central manager to do this :

Retrieve x from 'Script'; Use -> x;

Which is essentially 'twice' the operation. If you do this for a large amount of stuff you would impact performance.

Use GetComponent over gameObject.find but minimise usage of both, and if possible restrict it to use in the start() functions.

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

1 Person is following this question.

avatar image

Related Questions

Performance when having Update functions in many gameObjects ? 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Number of scripts per Object. Optimization question. 1 Answer

a ton of sprites vs sprite-tiling on one object 0 Answers

Efficient mesh vertex count changes? 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