1

For two days now, I've been having a rather strange problem.

Class ehader, showing non recognized MonoBehaviour class

The MonoBehaviour class isn't recognized by VS Code, with the following error:

Error while loading [...]: Exception thrown: System.TimeoutException: The operation has timed out.

I've already tried executing Edit > Preference > RegenerateProjectFiles, but to no avail.
I also deleted the "Library" folder as suggested by some users, with disastrous results, as it completely broke the game (the problem was solved by reinserting the old "Library" folder).
The only thing I haven't tried is increasing the "TimeOut" setting, which many have recommended, but I'm not sure how to do it and I'm afraid of damaging VSCode.
The only issue I'd like to point out are that the version of Unity on this PC is old (2023, I believe). However, I don't think that's the problem, since everything was working fine until the other day, and before this happened, the PC shut down on its own (with Unity open) due to some Windows updates.

But there's another problem.
Some people who deleted the "Library" folder and complained that their game was "broken" have been told that there might be something wrong with the project itself, because the folder only contains temporary, standard information that's generated each time the project is launched, so it shouldn't affect the game files.
I wanted to know if anyone could shed some light on this, and since I'm here, I wanted to ask if, when I update Unity, I should install one version at a time, or go straight to the latest versions. Maybe this is a silly question, but I'm terrified I might lose my game by updating to a version that's too recent.

10
  • deleting library really should have little effect. After all, thats why we exclude it from source control. it may mean when you load the project its target has changed (eg it may default back to windows if webgl etc) and it may even open a blank scene, but no, it shouldnt break your project. So, the question arguably is then, what broke? that probably needs fixing. 2023 got to 2023.2 and then moved to be 6000.0 :D Commented Nov 21 at 10:56
  • "and it may even open a blank scene," By "broken," I mean this. It opened a blank scene. Commented Nov 21 at 14:40
  • 1
    but thats not broken.. thats lack of understanding.. all your scenes were still there Commented Nov 22 at 12:12
  • Library folder is meant to be fully regenerated when deleted. Any breaking is not intended (either your project or the Unity version has a problem). It generally contains cached precomputed/compiled stuff, be it shaders, assemblies (e.g. Assembly-CSharp.dll) and so on. I'm assuming you have the VSCode package installed since it only bugged out two days ago. Any chance VSCode is the issue? Have you checked for any conflicting packages? Also what is it trying to load when it errors out and who is showing the error (Unity or Code)? Commented Nov 24 at 21:20
  • Also any chance your project is located in a partition that's not C? Because recently Unity was giving me grief when trying to load a project in a spare partition and I noticed Steam was too(same partition has steam library) and it happened due to permissions, which has never happened before on a simple new partition made in Windows. Given MS has been screwing up a lot lately on updates... Commented Nov 24 at 21:23

1 Answer 1

1

Various suggestions and solutions from users/programmers all point to a likely folder corruption due to the sudden PC reboot. However, I've never been entirely convinced by two things:

1: Because the classes weren't recognized when building a project in another directory.

2: because of the following error:

Error while loading [...]: Exception thrown: System.TimeoutException: The operation has timed out.

And it was precisely this last error that prompted me to investigate further within VS Code. In fact, the compiler was trying to establish a connection with the "LSP" (I assume the acronym for Language Service Protocol), but was unsuccessful.

Searching for "Omnisharp" in the VS Code settings search engine, I came across the following option:

Settings>Extensions>C#>OmniSharp>Dotnet>Server: Use Omnisharp

Omnisharp setting

Which was disabled (perhaps because of the sudden PC reboot?). By enabling it, VS Code finally recognized the Unity classes.

VS Code now recognizes classes

I hope this helps other users, please make changes with caution!

Sign up to request clarification or add additional context in comments.

1 Comment

Please add setting name as text also.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.