简体   繁体   中英

Cannot use extract method function in Visual Studio Code when coding in C#

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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM