0

I have a strange problem with my Scripts in Unity/Visual studio none of the monoBehavior Methods will be shown in VS editor! i mean VS doesn't recognize them for example when i want to use "OnTriggerEnter2D" the editor doesn't recognize it. also i tried to open scripts with MonoDevelop but didn't help.

Unity version: 5.6.7f1 pro

Visual studio version: 2019 Enterprise

public class Score : MonoBehaviour {
    // Use this for initialization
    void Start() {
    }

    // Update is called once per frame
    void Update() {
        Debug.Log("Test!");
    }
    void OnTriggerEnter(){}   //  this line isn't recognized by intellisense
}
KYL3R
  • 3,877
  • 1
  • 12
  • 26
  • Possible duplicate of [Autocompletion not working in Visual studio](https://stackoverflow.com/questions/42597501/autocompletion-not-working-in-visual-studio) – derHugo Jul 17 '19 at 12:34
  • thanks for reply i tried all of possible solutions and didn't help... –  Jul 17 '19 at 13:10
  • The Unity tools for visual studio 2019 doesn't work for old unity versions for some reason. you can try find an older version of it online – SagiZiv Jul 17 '19 at 13:22
  • @SagiZiv actually i tried older unity version(2018.3.7f1) and nothing! –  Jul 17 '19 at 13:26
  • `2018.3.7` is newer than `5.6.7` though. I guess he ment you should try using VisualStudio 2017 instead. Do you have the Unity-Tools installed for VisualStudio? – derHugo Jul 17 '19 at 13:38
  • @derHugo yes unity tools installed. and you are right i didn't have this problem in VisualStudio 2017. so i need to install latest version of unity and the problem will be fixed right? –  Jul 17 '19 at 13:43
  • it should ;) be careful .. people often confuse the "latest" version with the alpha build ... don't use anything containing `a` or `b` in the Unity Version. The latest **stable** version is currently `2019.1.10` – derHugo Jul 17 '19 at 13:45
  • @derHugo thanks my friend :D –  Jul 17 '19 at 13:46

4 Answers4

0

Not sure if it's that but when you create script and rename it, if you don't change MonoBehaviour by toto it will no work. Do you have the same name between unity interface and code editor?

LexaGC
  • 110
  • 3
  • 13
  • yes i have same name in both editor. also i created an empty script and still not working. –  Jul 17 '19 at 13:08
  • For example, if you made an empty script with only Debug.log('toto') in the start method, you see it ? – LexaGC Jul 17 '19 at 13:12
  • yes i can see it. i just found out i think i have to type all of mono Methods without AutoComplete help –  Jul 17 '19 at 13:17
0

Why it must recognize if OnTriggerEnter Have Parameters .If You Question is Why Visual Studio did not recognize unity3d OnTriggerEnter because if you type

public void OnTriggerEnter(){} //This is your implementation and Unity engine will not call this 

If you want Unity OnTriggerEnter you must implement Like This

public void OnTriggerEnter(Collider col) //3D
{

}

For 2D:

 public void OnTriggerEnter2D(Collider2D col)
 {

 }
auslander
  • 470
  • 5
  • 17
0

Had a big fight with the OnTriggerEnter this evening + night :) Solved : use VS 2017 !!!

From a post Ive read it seems to be a Unity issue, haha !

explanation : (https://developercommunity.visualstudio.com/content/problem/663323/visual-studios-2019-intellisense-not-recognizing-u.html)

Dharman
  • 30,962
  • 25
  • 85
  • 135
Crispi
  • 146
  • 1
  • 4
  • 1
    Welcome to SO. It is always more helpful to add some additional information about what you are linking to in case the link goes stale. Thanks! – Gene Z. Ragan Feb 19 '20 at 22:39
0

You need to upgrade Resharper to the latest version. This solved the problem for the Visual Studio 2019 community.