Home > Software engineering >  Cannot use extract method function in Visual Studio Code when coding in C#
Cannot use extract method function in Visual Studio Code when coding in C#

Time:03-24

I want to use the extract method function on this line of code in Visual Studio Code:

GetComponent<NavMeshAgent>().destination = hit.point;

This is the whole function:

    private void MoveToCursor()
    {
       Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
       RaycastHit hit;
       bool hasHit = Physics.Raycast(ray, out hit);
       if (hasHit)
       {
           GetComponent<NavMeshAgent>().destination = hit.point;
       }
    }

I've tried using Ctrl ., Ctrl Shift R, with no success. There is also no lightbulb coming up, and the setting is on. The extensions I have installed are the official C# extension, and Unity Code Snippets. Help is much appreciated and I'd be happy to provide more information if it's necessary(but I think there is enough).

CodePudding user response:

I solved the error by going into unity and changing the code editor. This was done by selecting the preferences menu, then selecting external tools or searching it, and changing the external script editor to Visual Studio Code.

  • Related