Code not showing up when opening Visual Studio from Unity - unity3d

I am a newcomer when it comes to Unity. I was following along with this online course. At one point, I had to write a C# script. So, I created one and doubled clicked it to edit it with Visual Studio. However when Visual Studio opened, all I could see was a essentially a blank screen. I couldn't see any code. Does anyone know the fix?
Thank you

Did you create it inside like this ... In Unity>ProjectWindow>AssetsFolder>RightClick>Create>C#Script.Then double click to open it.It will open up a script containing Start() and Update() method.If you could not find this.Restart and try.This is to test and try script for Unity scripting.

So this is way too late for the original post but maybe someone else will find this useful. So you did everything you were supposed to and even see the automated code with everything it should have in the inspector, but when you go and run the code whether clicking the actual script in the asset>scripts or clicking the open button in the inspector the same problem persists... blank uneditable screen.
I think you may just need to run updates on Visual Studio and/or if on a Mac maybe you need to log back into Microsoft. To do this just click the Visual Studio tab and click check for updates. Usually, you will also see an update suggestion in the top center of the screen. Run the updates and let it restart visual studio. Once you reopen visual studio at this time if you are on a Mac it should ask you to log into Microsoft. Your code might show up now.

Related

Visual Studio Code Destroyed all my files

I have been using visual studio code for about a year now. Recently I went to save one of my files and visual studio code gave me the error message this file conflict with a previous version. I clicked on the error and it presented me with a screen show the differences. I turned out I had added a line at the top importing defining a new constant. When I clicked override visual studio code presented me with a blank file. I went to look at my files and found that every file I have every worked on in the program has been changed to a blank file. Now whenever I try to save a file nothing happens, and I can't close tabs. I use a macbook if that helps in any way. Does anyone know how I could retrieve my files and how to prevent this prom happening again.
Edit: this applies to all my files not just ones associated with this project.

Visual Studio Code Save All button issue

Visual Studio Code Save All button is always enabled even without any file changes. How can we solve this issue? Ideally it should be grayed Out if no file changes are there in the workspace.
It's an intentional feature, just in case someone is not sure if they saved their files, VS Code will always show it to prevent closing without saving (besides the exit prompt).
Now, if for some reason they decided to change this, it would we worse, as people are used to the always blue button.

Attach debug to process Unity doesn't work

I created new 3d unity project, then in asserts I created c# script if I click on it twice Visual Studio 2017 is opened. Then I would like to make a debug, so I set debug point and click in Unity on play button and nothing happes.
There is no attach button or something like this.
What am I doing wrong?
This happens randomly to me as well. The way I fix it it to go Unity->Edit Menu->Preferences->External Tools, and set the External Script Editor to something else, and then revert it back to Visual Studio.
If that fails, just underneath that dropdown there is a button Regenerate Project Files, which helps when your VS project files get messed up.
Also, upgrading to the latest version of Visual Studio and Unity Tools for VS could help.
My bad if I misunderstood this question, but all you have to do for unity to update your scripts for your game is ctrl + s, this will let unity know you made changes to the script and it will apply those changes.

How to hide/unhide comments with Microsoft VSCode?

I have a code with many comments, how can I hide these ones, but no delete, I need them after.
I need to hide all the comments in one click, not a simple collapse one
Can't find such feature as well.
Read this issue from GitHub - https://github.com/Microsoft/vscode/issues/46505
Seems like that VSCode can't do it (from the box) and all people waiting for that feature.
I was looking for a way to do that too as I put way too many comments making it hard to debug... and I came across this https://marketplace.visualstudio.com/items?itemName=eliostruyf.vscode-hide-comments it makes all the comments invisible, but it leaves special characters in place. There are also commands to toggle show/hide.
Hide Comments - Visual Studio Marketplace
We now have an extension for that. On the editor title, a toggle action is available to show/hide the comments quickly.
You can download from inside Visual Studio 2022 called unobtrusive code and it will hide all comments and put "+" symbols on the collapsed line to the left of your code that you can open or close them with. It works great.
*** TO GET THE EXTENSION: ***
I went to the Extensions menu at the top of VS 2022 and chose manage extensions.
Then in the manage extensions window that opens up, choose online then Visual Studio Marketplace. In the search at the top right of the manage extensions window type in unobtrusive code. download it and then exit Visual Studio. You should see a window pop up to install it.
When you start VS 2022 again and open a C# script, it should have all the comments minimized to the "plus symbols" to the left of the code!
Hope it works for anyone wanting to hide their comments.

Middle click in Visual Studio Code for scrolling?

I'm checking out this Visual Studio Code but when you middle-click for scrolling as you would everywhere else it selects code instead of scrolling. Not exactly like a left click but still, annoying for me. Is there a way to solve this issue?
No, unfortunately not (yet). But you can contribute here on github to make it happen.
Since the issue has been reported but not fixed for 5 years, you should upvote that issue, and then use the autohotkey workaround:
https://github.com/qooqu/vs-code-mbutton-scroll-ahk
(You have to hold the middle-button down in vscode and drag the mouse up or down to autoscroll, and it scrolls one line at a time instead of smoothly, but it's much better than nothing.)
(To use: Install AutoHotkey, then you can download and run the linked .ahk file)
There's an extension that allows this kind of behaviour in Visual Studio.
Visual Studio Marketplace Link