Visual Studio has stopped debugging my C# code, and my scripts have stopped importing to Unity

I’m using Visual Studio Code 1.90.1 with the C# and Unity extensions installed, and Unity version 2022.3.31f1.

I’m making a game that tracks the player’s score. Everything was going fine until I decided to separate the code that tracks the score and updates the gamestate in response to it from the code that causes changes to said score.

After I moved the code to a new file, both scripts stopped running in Unity, along with a third entirely unrelated script. After restarting Unity, it will no longer let me import any of the three scripts, displaying the following error message:

Can’t add script component ‘Tracker’ because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match.

It does this for all three scripts now, including the one I did not touch at all during these changes. Trying to debug the code in VS Code returns this error message:

No C# project is currently loaded. Please create a C# project in order to debug.

Again, I have to stress that two hours ago my code was running as C# code without errors, and now VS Code says it’s unrecognisable as C#. Additionally, the editor is autocompleting C# code when I type it, so VS Code is recognising the code as written, but won’t debug it or let me use it.

I am running Visual Studio on default settings, with just the following extensions:

  • .NET Install Tool
  • C#
  • C# Dev Kit
  • Unity
  • Unity Tools (disabled)

In trying to debug this myself I uninstalled and reinstalled both the C# and Unity extensions, and attempted to run their debugging tools. C#’s debugger returns the error message above; the Unity extension won’t let me select it as an option in the debugger, despite having “debugging” listed as a feature on its extension page.

I checked Unity’s package manager to see if the Visual Studio Code package had disabled somehow, and it’s enabled, updated to the latest version supported by my version of Unity, and seemingly working as intended.

I’ve also tried disabling and reenabling my extensions in VS Code. I’ve noticed that when I do this, the code is reset to the default C# colour scheme for roughly half a second, before reverting back to a neutral colour scheme. I may be reading into this too much, but this seems to imply that VS Code reads my code as C# for half a second, and then stops, every time I refresh my extensions. Also, when I refresh the C# Dev Kit specifically, I get the following message:

Detected installation of ms-dotnettools.csdevkit. Would you like to relaunch the language server for added features?

Relaunching the language server makes the code go back to C# colours. And then it stops again.

Uninstalling and reinstalling all extensions has also not helped, same with restarting VS Code. I’m at a loss for what else to try.

New contributor

Jarvis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật