How can intellisense in Visual Studio know how to write the whole method declaration for for example OnTriggerEnter ?

Hello :slight_smile:

When I start writing ”ontr ” intellisense autocompletes when I press tab and suddenly all of the code for OnTriggerEnter is there.

Like magic :slight_smile:

I want to know how intellisense does this.

How do intellisense know there is a method named OnTriggerEnter that I might or might not want in my class?

Is the method inherited from MonoBehavior somehow?

Is it an interface? (But then the method must be implemented in my class right? In this case I can choose to not implement it if I want to)

Is it a snippet intellisense can see?

Also if i implemented the code for OnTriggerEvent and then try to write ”ontr” again intellisense does not show OnTriggerEvent in the list of available methods to implement.

How can intellisense know that I have already implemented this code?

I understand how intellisense can see that there is a field in a class and autocomplete if I start typing the fields name.

Also the same if I have declared a method in a class and start typing the methods name in another method or in the constructor.

But here I don’t understand.

Intellisense does not know of the method and knows how to write the whole code for writing that method?

I am sure there is a simple explanation that I did not think of but I have googled this for some time and can not get the answer myself.

Greatful for any replies :slight_smile:

Thanks in advance

Best Regards

Unless I’m misunderstanding something, it looks to me like Unity’s implementation of various preset functions (to be utilized/overridden, as it were) probably make use of AutoCompleteAttributes (or similar-enough) to allow them to be constructed as completely and automatically as possible.