Vscode: What would make VSCode the definitive editor for Unity projects?

Created on 5 Feb 2018  路  15Comments  路  Source: microsoft/vscode

I know this is a broad topic, but I want to suggest the discussion about it.

As large amount of people, I love to make video games and Unity is providing one of the best experiences I had so far. I really love VSCode and the fact that it's solid, fast and still under development with the help of the community. It is one of the most pleasent coding experiences that I ever had.

The last editor I used was Visual Studio with ReSharper, a nice, very strong and fully-featured experience. Both tools are great, but they have _too_ much to offer. It's by far more than ever needed to create simple games, which make the coding kinda "laggy". "I'm programming games, thus my tools should run at 4K@60fps!" hahaha. That's why I changed to VSCode: to have a smoothier coding experience.

Although VSCode is going well in the smoothness department, there is some rough edges to be polished (that's part of the beauty).

So, my questions are:

  • What would make it the definitive editor for Unity projects?
  • What features are missing?

My intention here is to suggest some features to VSCode team and the related extensions makers, create pull requests to improve them and create more extensions if necessary.

*out-of-scope

Most helpful comment

For me, these are the things I remember now:

  • Camel humps: the hability to navigate though CamelCasedNames. There is an extension: Camel Case Navigation, but it lacks some features, like ctrl+backpspace to delete a hump or the hability to use the navigation inside the rename panel, for example (I'm planning to make a PR there adding those features)
  • Renaming integration with Unity: Oh, the renaming... Every time I have to rename a MonoBehaviour the references are lost inside Unity and I have to make them again. I don't know if there is an extension for that or some workaround.
  • Namespaces: Usually I use namespaces in my projects due to... what they are for. Turns out that every time I create a class I have to put it by hand (almost, the auto-completion handles some of the work). I tried another good extension: C# Extensions but I couldn't make it work another way except using the entire folder structure as the namespace. It would be better if it guessed the namespace by the namespace of files inside the folder (like ReSharp does).
  • Remove unused usings command: A shortcut to remove the unused usings would be nice. For the current file and for the project/selected folder. To make it work today, I have to open the project on Visual Studio and make it there. The guys from C# for VSCode don't seem to have the intention to do the feature.
  • Namespace suggestions: When writing the name of a class, for example, Code could suggest some namespaces that contains the same class name but are not yet added to the file and are in the dependencies of the project. Today you have to write the complete name of the class to do so (which is nice, except when you don't quite remember the entire name of the thing).

All 15 comments

For me, these are the things I remember now:

  • Camel humps: the hability to navigate though CamelCasedNames. There is an extension: Camel Case Navigation, but it lacks some features, like ctrl+backpspace to delete a hump or the hability to use the navigation inside the rename panel, for example (I'm planning to make a PR there adding those features)
  • Renaming integration with Unity: Oh, the renaming... Every time I have to rename a MonoBehaviour the references are lost inside Unity and I have to make them again. I don't know if there is an extension for that or some workaround.
  • Namespaces: Usually I use namespaces in my projects due to... what they are for. Turns out that every time I create a class I have to put it by hand (almost, the auto-completion handles some of the work). I tried another good extension: C# Extensions but I couldn't make it work another way except using the entire folder structure as the namespace. It would be better if it guessed the namespace by the namespace of files inside the folder (like ReSharp does).
  • Remove unused usings command: A shortcut to remove the unused usings would be nice. For the current file and for the project/selected folder. To make it work today, I have to open the project on Visual Studio and make it there. The guys from C# for VSCode don't seem to have the intention to do the feature.
  • Namespace suggestions: When writing the name of a class, for example, Code could suggest some namespaces that contains the same class name but are not yet added to the file and are in the dependencies of the project. Today you have to write the complete name of the class to do so (which is nice, except when you don't quite remember the entire name of the thing).

Debug attaching is hit and miss.
Sometimes code changes are not 'seen' by Unity. ( Reload Window seems to help )

Yes, you are right. Sometimes, VSCode just have some weird errors in code like "this class is defined elsewhere" but it's not! And they go away only when you restart VSCode. Usually this happens when I rename a class and its file.

About the debug. I almost gave up on it 馃槖 . Sometimes (specially when the project is opened for days) I try to debug and it doesn't step to the next line. And it freezes Unity. Until you restart both. Most of my debug are made by Debug.Log like in ye olde times.

News!

Camel humps are now part of the Visual Studio Code: https://code.visualstudio.com/updates/v1_25#_subword-support but it's not working like expected yet: https://github.com/Microsoft/vscode/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+subword.

@kleber-swf Regarding the "this class is defined elsewhere": This seems to be OmniSharp keeping old code around in memory. Use the command "Restart OmniSharp" from the Ctrl+Shift+P Menu as an alternative to restarting/reloading.

Side note: this regularly happens to me when switching branches in git...

Thanks @founderio. I agree. It's some cache stuff since I usually execute the command "Reload Window" and the errors disappear. Although it's still annoying 馃槃

It's just me or now every time we create a new class we have to restart VSCode to make the new class see the others?

I have the same issue it is very annoying. @kleber-swf

For the renaming issue, I'm thinking of creating an extension that when you rename a MonoBehaviour, it automatically renames the file and the .meta file to the new name. What do you guys think? Or, is there an extension that do that?

@kleber-swf That sounds nice. Additionally, if you rename or move things (folders, etc) in vs Code's file explorer, it auto renames/moves the .meta file.

So, I'm researching and studying about making VSCode extensions in my spare time to create one to address the renaming issue. Well for now it seems a bunch of stuff to study ahahah!

I'm still not sure about how to proceed, so if you guys have any experience to share it will be very appreciated. As soon as I figure out what will be the base code I'll create the repository where everyone can contribute.

The features (at least at the beginning) would be:

  1. when a class is renamed, its file should be renamed accordingly
  2. when a file which contains a class with the same name is renamed, the containing class should be renamed as well
  3. when, in any occasion, a file is renamed, its corresponding .meta file is renamed accordingly
  4. when a file is moved, its corresponding .meta is also moved
  5. when a file is deleted, its corresponding .meta file is also deleted

For the first feature, I'm using this approach: Rename Symbols. It works, but only when Omnisharp isn't active. So I'm thinking that for this type of extension we will need to create a language server, which is waaaaaay more difficult. If that's the case, I'm thinking of create a branch from Omnisharp itself and tweak it were we need (I'm making some experiments with this approach right now).

What you guys think? Any of you have experience with language servers?

I would suggest to start with moving files/folders in vscode first, it's very annoying to find out the reference links are all dead just because I forget to move the .meta with the .cs

The rename part could come later.

Hello @kleber-swf! Do you have any news about renaming/moving unity3d files?

@imurashka I found this extension in the market: https://marketplace.visualstudio.com/items?itemName=PTD.vscode-unitymeta
Sounds like it is what you're looking for. I haven't tried it yet though and hope you'll try it and leave here your feedback. I'm using Rider for a while and just checking if VSCode is already good enough to give it a try. So looking forward to your reply 馃槈

housekeeping ... this issue looks more like an issue for the C# extension or one of the many Unity extensions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stoffeastrom picture stoffeastrom  路  380Comments

Brakkar picture Brakkar  路  364Comments

ozsay picture ozsay  路  247Comments

misolori picture misolori  路  282Comments

Perkovec picture Perkovec  路  191Comments