The cause is that the Unity project is not associated with the Visual Studio you are using.
Just follow the steps below:
- Open the Unity project
- Select
Edit–>preferencesin the menu bar - On the left side of the window that pops up, find and select
External Tools - In the right-hand pane, find
External Scripts Editorand change it in the dropdown, selecting the Visual Studio version you use - Close the settings window
From then on, whether you open the project from Unity or right-click the Unity project in File Explorer and open it with Visual Studio, script methods will navigate normally.