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 PhilaPhan80 · Feb 11, 2013 at 07:33 PM · c#visual studioeventeventsvisualstudio

How can I make Unity's overridable events appear within the Intellisense dropdown in Visual Studio (C#)?

I'm new to Unity, but familiar with C#. When I create a new C# script that opens in Visual Studio, I get Intellisense for everything except for overridable events.

For example, while working with collision, I expect to see events like "OnCollisionEnter", "OnCollisionExit", and "OnCollisionStay" within the dropdown. However, if I type "override", the only selections I see within the dropdown are "Equals(object o)", "ToHashCode()", and "ToString()".

Also, hovering over any term shows the usual tooltips, but hovering over something like "OnCollisionEnter" shows nothing at all. It's as if the system recognizes it, but won't tell me how or why.

What am I doing wrong?

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 Bunny83 · Feb 11, 2013 at 07:42 PM

Uhm you can't because they are not overridable functions ;). Unity send messages to your scripts. Unity even optimises this message sending that messages are only send to classes which have a certain method. The MonoBehaviour base class doesn't have all those callbacks.

When working with Unity you should always have your browser open with this page ;)

Comment
Add comment · Show 3 · 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 $$anonymous$$ · Feb 11, 2013 at 08:09 PM 1
Share

Correct me if I'm wrong, but it shouldn't be message sending like in Send$$anonymous$$essage sense, rather it wires up the methods it knows on load, with reflection.. at least that's how it makes sense for me, because message sending in the Unity API sense is order of magnitudes slower than delegates. I'm curious too about how is this implemented in the background.

The way it most makes sense for me as to why it's designed this way is that big part of the API actually wraps native code, and the C++ base for the engine probably uses very different structuring in it's implementation, so it's not trivial or even impossible to make a wrapper for a class like Behaviour or $$anonymous$$onoBehaviour, simply because it doesn't exist in this logical form within the engine itself. The upside here is that the Unity API is much more than a wrapper, it exposes functionality in this very modular and straightforward way, and wires a whole bunch of stuff for free, so writing a script is like creating a $$anonymous$$i-wrapper for various functionalities of the engine core, and it seems like $$anonymous$$onoBehaviour is just a clever way for the compiler and the game coders to group functionality.

avatar image Bunny83 · Feb 11, 2013 at 08:23 PM 1
Share

Yes, of course. Unity doesn't use Send$$anonymous$$essage for the events. Unity probably uses reflection at compile time and stores some meta data in the native code part of the object. In C++ there are no different classes, there's just a $$anonymous$$onoBehaviour object which is linked to a managed code instance of one of your custom classes.

They even change what happens in native code depending on how your callback function is declared. For example OnCollisionEnter has a Collision object as parameter. However if you omit the parameter in your callback, Unity won't even calculate all the stuff in that struct / class and don't pass anything as parameter. The same thing applies to a lot other callbacks.

The easiest way to see this optimisation is when you just delete the Start and Update functions from a class, so no callback is in the class, the "enabled" checkbox in the inspector will disappear since this class doesn't receive any callbacks.

avatar image PhilaPhan80 · Feb 11, 2013 at 11:57 PM 0
Share

Ahh, good to know. I probably just haven't hit that point in the tutorials yet. Thanks!

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

10 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

Related Questions

One listener for multiple objects? 2 Answers

Unable to step. Operation is not supported 0 Answers

Impossible to use Visual Studio 2015 Debugger anymore (Unity 5.2.1f) 2 Answers

csc.exe has stopped working ,csc.exe has stoped working 0 Answers

vector 3 isnt working offset part,the vector 3 isnt working 'offset' has a problem 2 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