Can I Safely Use VSCode and VS 2022?

Is there a way to use both vscode and and vs 2022 together with unity safely?

While I was going through a tutorial file I decided to try using both, but I found it ended up causing problems like unity wasn’t recognizing cameras, and the debugger would step into internal unity package .cs files. I confirmed something was broken, when I found complete files from the tutorial, made a new project, and then replaced the scripts with my own, and everything seemed to work as expected.

I like using vscode when I write because with my setup I can write faster with fewer keypresses, but I find visual studio is far superior when it comes to working with the debugger, and going through scripts, and looking for methods.

Can anyone speak to this?

Thanks.

yes - if you really want… although why

Like i said in my post, I’m more comfortable working with vscode. There are some really useful qol extensions I use, that do things I can’t within the VS2022 environment.

I like the “predict what I’m trying to do” inside the full app, sometimes it writes the code itself. Can it does that inside VSCode? I’ve tried once but it appears to be mostly a better text editor.

Intellisense is available pretty much everywhere. Google for how to enable it with your editor, obviously the C# version of it.

Further and better AI-based help (such as Copilot) is changing so rapidly that by the time I finish typing this sentence, there’s probably a new plugin you can tinker with. It’s spreading like wildfire at this point.

Intellisense is in vscode, but there are also extensions with various snippets, multi-carat plugins. There are some AI plugins as well that help when writing C#, but they aren’t always correct. Unless I’m wrong, those extensions aren’t available for VS2022.

One thing I can do in VSCode that I can’t in VS is hit F2 to rename a variable and have it change at every instance in the script. I have to multi carat select, then rename. I know it doesn’t sound like a big deal but for me it is.

Visual Studio has IntelliCode and GitHub Copilot. Many extensions are also available on the Visual Studio Marketplace.

Visual Studio has the same functionality. The default binding is Ctrl+R,Ctrl+R. Keyboard shortcuts can be customized, this binding being Refactor.Rename.

1 Like

Well technically you dont need VS studio at all, I dont have it installed. if you like code, use code.

man i tried googling it, and the related posts I found told me it wasn’t possible. Good to know.

There is my issue though. I have to learn the commands and workflows before I can use it efficiently.

Regardless, as it stands working with both shouldn’t be an issue? It doesn’t break the scene, or mess up the files?

I’m not aware of features that modify scene/asset data. The editors just work off of .csproj files (generated by the Visual Studio editor package in Unity) that have no bearing on how the project actually works. The developer experience might have problems - I’m not sure how well the Unity editor would deal with repeatedly switching between two editors, and from my recollection there are different preferred C# project formats between the two editors (classic csproj vs SDK-style csproj) meaning the C# project files would be generated differently for each editor, but the Unity project itself should be fine.

This is why I’m asking. When i started in vs 2022, then opened the files in vscode later, I got lots of assembly messages/warnings. One of them said something like “using UnityEngine doesn’t exist and should be removed”, the warnings didn’t make sense, and things became really buggy.

I was hoping someone would have first hand experience using both within the same project

Did you make sure to set the external code editor and regenerate project files between changing editors? (A scripting API exists for this that could make this driven by a custom shortcut)

1 Like

I have moved on from that project, but I did regenerate the files when I noticed things weren’t behaving normally. From what I can remember I don’t think it fixed anything.

I don’t want to risk breaking this project now, so I’m sticking to VS 2022 for now. Maybe someone else can confirm or deny if it’s an issue.

Seeing as your errors seem to be related to the generated C# projects, I’m not clear on whether you specifically set the code editor each time in Preferences. This should be a required step (along with using Assets > Open C# Project) instead of only opening the project folder from VSC. Following this pattern in a moderate size project (100 assemblies) seems to work correctly on my end, with Unity 6000.0.19f1 and VS editor package 2.0.22.

You can use version control and ensure your project has history that you can go back to if anything breaks. That will also allow you to see if there are any unexpected asset/scene changes going on when you fiddle with using different code editors.

There can occasionally be issues in the data Unity stores in Library, and in such cases, it’s safe to delete the folder while the Unity editor is closed, and it will regenerate files as necessary the next time it’s opened.

Yeah I wasn’t setting it every time. that would be impractical. The way I was working I had both open simultaneously, and I would lose track of which one I opened first, and how I had it set.

I’ll just use 1 for now