Unable to Extract Method?

Hello!

I could use some help with a specific question. This is on the Complete C# Unity Game Developer 3D course, lecture 94. Public Methods In Unity C#. At 12:02 Rick uses the extract method function in VS Code, but when I click Ctrl + . to extract the same method, I’m getting a “no code actions available” error message.

I’ve re-installed the C# extension, closed and opened VS Code, ran as administrator, and done a fair amount of Googling but still can’t get the refactor / method extraction menu to display in VS Code.

Does anyone have any suggestions on this? Would be much appreciated!

Thanks!

Hi,

Please follow the instruction on this website and make sure all required extensions are installed: https://code.visualstudio.com/docs/other/unity

If the issue persists, please check the console of VS Code (not Unity!). If the .NET Framework 4.7.1 (Developer Pack) is mentioned there, download and install it from the official Microsoft website. Here is the link: https://dotnet.microsoft.com/download/dotnet-framework/net471

Depending on your version of Unity, it might be that you will have to install the “Visual Studio Code Editor” package in Window > Package Manager in Unity.

  1. Press Ctrl + Shift + P in VS Code.
  2. Type “OmniSharp: Select Project” and press Return.
  3. Select the solution workspace entry.

Maybe you’ll have to reboot your computer. Then launch Unity again and open one of your scripts.

Did this help?


See also:

Hi Nina,

Thank you very much! This fixed it for me. You are a wizard.

What fixed it was when I re-installed the .net framework and c# extension, restarted VScode, and unchecked the C# extension’s Omnisharp: Use Modern Net.

Now when I highlight functions and select Control + . I am seeing the extract method option, along with the other options.

Thanks again!
Alan

Fantastic! I’m glad it’s finally working. :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms