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
2
Question by ronronmx · Feb 24, 2011 at 05:09 AM · sendmessagemessage

Difference between Unity's messaging system and other custom messaging systems?

I recently started looking into using messaging systems, which are new to me, and part of my learning process to better myself at c# programing and writing better, more efficient code.

I have been reading about and using Unity's own "SendMessage" system, but I recently came across some video tutorials in which the user is using a custom messaging system like this one, and I was wondering a few things:

  1. Why is he not using Unity's built-in messaging system?
  2. What's the difference between the 2?
  3. Does Unity's messaging system have any major pros or cons?

Like I mentioned above, messaging systems are new to me, and although I understand their purpose and usage, I do not know how to tell a good one from a bad one, or whether or not Unity's built in messaging system will do everything I need it to do.

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
7
Best Answer

Answer by Jake-L · Feb 24, 2011 at 07:33 AM

The difference is in the way how messages got from the sender to the consumer/receiver. The buildin system uses reflection to call a function you provide. Reflection is somewhat slow, so if you use this extensively (every frame) this may slow down your game. Another difference (some may say drawback) is that you need to know the consumer to send him the message directly.

Other systems like that you linked rely on delegates and events (ask your favorite C# learning book or google it if you want more details). Basically this works like a mailing list subscription: an object that want to receive certain types of messages subscribes itself on a list. When the event fires, all subscribers on the list got this message. The big advantage is that you fire events no matter to whom and every object that want it will get it.

Both systems can be useful, it depends on the type of application and how you layout your code.

Hope that helps...

Jake

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 Jessy · Feb 24, 2011 at 09:19 AM 1
Share
  • for C# events. They're fast and awesome.

avatar image ronronmx · Feb 24, 2011 at 05:03 PM 0
Share

Jake L, thanks a lot for the explanation, it does help a lot. I do like the CSharp$$anonymous$$essenger messaging system better, as it seems to give the user more control, and from what I have read so far, would be a faster solution for mobile development. Thanks again for your help!

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

No one has followed this question yet.

Related Questions

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

BroadcastMessage between children? 3 Answers

iPad touch scripting... 0 Answers

Looking for some tips on performance testing 1 Answer

SendMessage , how can i send two parameter 3 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