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 Hamesh81 · Oct 11, 2013 at 09:24 AM · performanceoptimizationtimerinvoketimers

Are there any performance differences between a timer and using Invoke?

Quite straight forward; I often find it easier to use Invoke whenever I need something to happen based on a specific delay. I find this easier then setting up a traditional timer using floats, bools and Time.time.

Is there any performance differences between the two approaches? I haven't found any slow down from using Invoke but I would appreciate some more knowledgeable advice about these two approaches, so I don't have to rewrite my code later down the track.

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 DannyB · Oct 11, 2013 at 10:31 AM 0
Share

I believe invoke is slower, but in any case, for delaying execution, have you considered using coroutines and yield return new WaitForSeconds? - in my games I have many things that require delayed execution, and never used invoke or cumbersome timer logic.

avatar image Hamesh81 · Oct 11, 2013 at 10:58 AM 0
Share

By "slower" is it significant, because I use Invoke quite often in my scripts so should I be concerned for optimization reasons?

In Js WaitForSeconds is definitely straight forward to set up, but in C# (which is what I use predo$$anonymous$$antly) it takes a few extra lines of code, I think about as many as setting up a manual timer which is why I just use Invoke because it's just one line.

avatar image DannyB · Oct 11, 2013 at 11:44 AM 0
Share

Well, if you are using it a lot, then yes, it may be significant. Whether it is significant enough to justify a change will depend on your specific uses and frequency of execution.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by DarkPixel · Oct 11, 2013 at 12:24 PM

The best thing to do is to benchmark it.

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

17 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

Related Questions

How Can I Reduce Build Time for Script-Heavy Projects? 2 Answers

Should i bake the skinned mesh? 1 Answer

Why did my render time increase after lowering the vertex count? 2 Answers

Whats an efficient method for drawing hundreds of Health Bars etc. over units for an RTS? 2 Answers

Performance of game depends on computer's power option? 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