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 kromenak · Mar 15, 2011 at 12:46 AM · androidiphoneperformanceevent

Performance of C# Events on iPhone/Android

I'm interested in possibly using the C# event system in a game project for iphone/android, but I'm curious about the performance costs/benefits associated with using this over an event system on the wiki.

First off, are C# events supported in Unity? Second, are they a good solution to event-based programming in Unity? Third, do they scale well as more events/listeners are added to the scene? My main concern here is the performance ramifications on framerate.

Thanks!

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

1 Reply

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

Answer by Mike 3 · Mar 15, 2011 at 12:54 AM

There's no issue using c# events on iOS or Android - there should be a fairly linear performance hit from adding more listeners, which you'd expect.

If anything, you could potentially increase framerate if you register for an Update event, and propagate that event from one source, for example, instead of relying on unity's Update function

I won't comment on the quality of the event managers on the wiki, as I haven't used them, but any abstraction over a pure event will incur at least some cost, so look into them thoroughly

Comment
Add comment · Show 4 · 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 kromenak · Mar 15, 2011 at 04:53 PM 0
Share

Great, thanks for the info! The reason I was unsure about using C# events was because all the forum posts I could find point to people using wiki event handlers...I guess thaty might have been before Unity supported .NET 2.0.

avatar image Mike 3 · Mar 15, 2011 at 07:54 PM 0
Share

Nah, they worked fine in .NET 2.0 as well. $$anonymous$$y bet is that is that they're generally talking about events as a more abstract design, as opposed to the language feature, where you generally register for named events.

avatar image numberkruncher · Feb 20, 2012 at 02:57 AM 0
Share

@kromenak Are you suggesting that it would be more efficient to expose a static update C# event Entity.OnUpdate which is invoked by a single controller script and then for each script that requires a per-frame update void Start() { Entity.OnUpdate += ... }? Are there any disadvantages to this? Cheers

avatar image kromenak · Feb 27, 2012 at 06:50 PM 1
Share

@kruncher I don't think there would necessarily be a disadvantage to that approach; basically what you seem to be doing is getting the Update behavior of a $$anonymous$$onoBehavior without the class necessarily being a $$anonymous$$onoBehavior. If you are going to make it a $$anonymous$$onoBehavior anyway, I'd probably just use the Update function and be done with it.

Something we've discussed for our next project is potentially just having a main scene $$anonymous$$onoBehavior that manually calls an Update function on classes - hopefully will cut down on overhead and make it easier to follow stack traces.

We've also been using C# events pretty frequently. They seem to work fine for us, so no complaints there!

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

2 People are following this question.

avatar image avatar image

Related Questions

Eventhandlers & performance on mobile 0 Answers

Best way to create/design modular Player 2 Answers

Halo effect perfomance on mobile devices 1 Answer

iPhone 4 game lags 2 Answers

Slow Startup on iOS and Android 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