VS Code will not display errors in my C# script for Unity (possible omnisharp problem)

Viewed 265
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Driver : MonoBehaviour
{
    void Start()
    {
        
    }

    void Update()
    {
        // transform.Rotate(0,0,0.1f);
        transform.Translate(0,.01f,0);

    }
}

above is my code. If I add anything incorrectly, no error appears. It appears to be a problem with omnisharp. I have tried reinstalling, fidgeting with the settings, and installing older versions of the C# extension. However, no matter what I change, errors do not appear as I code.

1 Answers

VS Code cannot automatically complete the code or check errors, and the plugin fails.

The following steps are helpful:

  1. First make sure the plugins are installed. List of plugins: Debugger for Unity. Unity Tools. Unity Colde Snippets.

  2. Make sure the development environment is complete. An incomplete development environment can also cause this problem. It is also possible that the .net version created by the project does not match the .net version of the development environment.

    Solution:

    2.1. Use a text editor to open the file with the extension csproj in the root directory of the project.

    2.2. Ctrl + F Search "TargetFrameworkVersion" keyword, you can see the information "v4.7.1". This means that your computer lacks the 4.7.1 version of .net Framework, and different computers default Versions may vary.

    2.3. Microsoft official website to download the corresponding version. It should be noted that you need to download the develop pack (development package) version, not the normal version. Otherwise useless.

    2.4. Restart vscode.

  3. VS code editor settings.

    3.1. Enter the vscode editor and press ctrl + shift + P at the same time.

    3.2. Enter in the pop-up input box: OmniSharp: select project.

    3.3. Manually select the project file.

  4. Normally, vscode cannot complete the error check because the version of omnisharp is wrong, omnishap may conflict with other versions of your vs code during the upgrade process, so you need to keep omnisharp to the latest version.

    Solution:

    4.1. Go to the console. Then click on the ouput bar and change the output type to ominisharp log. Windows version shortcut key: ctrl + shift + u.

    4.2. Search for ominisharp in the setting.json file of vs code and change its path parameter to latest.

    {
       "[csharp]": {
       "editor.defaultFormatter": "bilal-arikan.csharp-auto-formatter"
       },
       "omnisharp.path": "latest"
    }
    

    4.3. Restart vs code.

    Hope it helps you.

Related