- Home /
How can intellisense in Visual Studio know how to write the whole method declaration for for example OnTriggerEnter ?
Hello :)
When I start writing ”ontr ” intellisense autocompletes when I press tab and suddenly all of the code for OnTriggerEnter is there.
Like magic :)
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 :)
Thanks in advance
Best Regards
Answer by Eno-Khaon · Oct 04, 2021 at 09:31 PM
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.
Ok thanks :)
Will try it out tomorrow.
So if I write [autocomplete] before my method I write myself, Intellisense will then display it as a method which can be autogenerated if I start writing the name of the method in a class outside of a method? (Where I usually write new methods)
Cool :) (Sounds like there is more to it but will try it out :)
Thanks for the answer :)
Your answer
Follow this Question
Related Questions
Webplayer exception when using BufferedStream 0 Answers
Method not found: 'UnityEngine.AudioSource.PlayOneShoot'. 1 Answer
Mutator method to change multiple bool variables? 2 Answers
How to execute a function which is implemented in .NET when I have its name as a string? 1 Answer
Can't assign SetActive because it's a "method group". 0 Answers