0
votes

When i try to use OnCollisionEnter2D, is like this function don't exists in MonoBehaviour, i try to digit On + CRTL+ SPACEBAR and the only things that appears is CommonOnScreenControl,ReadOnlyCollectionBase,RuntimeInitializeOnLoadMethodAttribute.

My objects have a box collider 2d and a Rigid body (with body type Dynamic and discrete continuous collision detect)

2
What is your Unity version? What IDE are you using? Mono or VS?Programmer
Code hinting has never worked for me for those special MonoBehaviour-specific methods. Just refer to the documentation for the method signature until you've used it enough to know it by heart. =PSerlite
it will not be autocompleted by intellisense. Just type it, but check if you did it correctly in unity docsŁukasz Motyczka

2 Answers

2
votes

Can you show your script so we can see exactly what you wrote?

It's hard to understand your exact problem, but the function "public void OnCollisionEnter2D()" will not automatically finish with intellisense for you if that's what you mean, but it still exists and can be used.

2
votes

Unity callback functions should work even though intellisense is not showing it.

C# IntelliSense for Unity messages and C# code coloration for Unity messages were added to Visual Studio in version 2.8 (3.0 Preview).

The autocomplete feature should work for the OnCollisionEnter2D function.

I was not able to get this working until I updated it to 2.8.2 (3.0 Preview 3) directly from the Visual Studio IDE.

From Visual Studio, click on the circled icon below after installing Unity, Visual Studio and Microsoft Visual Studio Tools for Unity.

enter image description here

It will give you option to update Visual Studio and other plugins. Update Microsoft Visual Studio Tools for Unity and other items listed there.

If you don't see options to update plugins,update it directly from here. The IntelliSense should work after this.