I wanted to continue coding where I left after sleeping, but suddenly as I open my Code in Visual Studio and tried to work on my code while having using UnityEngine.UI or using UnityEngine.EventSystems standing at the top, it just says that the type or namespace "UI" or "Eventsystems" doesn't exist in the namespace "UnityEngine". And I also can't use using TMPro. I don't know if thats all I can't use.
I've now just restarted my pc, reselected Visual Studio 2022 17.2.5 in Unitys external tools and uptaded Visual Studio and it sill doesn't work.
Maybe it's important to know that restarting my Unity project isn't working.
How to fix that and how to prevent it from happening again?
CodePudding user response:
is this the case in all your scripts?
can u copy/paste the usings of your script ?
maybe try to create a new script and add the using's you cant use in the other script to check if the script file is somehow broke
is Unity correctly linked to Visual studio? you can check this when yoo look in vs into a script if there are Unity references over your classes and methods its linked
CodePudding user response:
Open Unity and go to Window > Package Manager. In the Package Manager window, select In Project from the dropdown as shown below.
In the list of packages, find Visual Studio Editor and update it to the latest version.
Close all Visual Studio windows, go to Edit > Preferences > External Tools, and regenerate project files (In your case, the External Script Editor is Visual Studio).
Reopen any script in your project and the error should disappear.