In the editor in the Project > Assets > My Scripts > Ladder > mouse right click Create > C# Script give it the name Raise then double click but i can’t use it since the MonoBehaviour is not active not in light blue.
Other scripts have it fine.
Not sure what is wrong. I tried to give it other names like RaiseLadder or Raise Ladder but each time i create the script it’s not working.
Its a bug with VS and Unity. Sometimes the VS intellisense just breaks. Usually deleting the Library and the .csproj/.sln files fixes the issue. These folders get recreated by Unity upon reopening the project.
Sometimes the .cs file will be opened as a single file that has not been registered properly in the project file yet, hence your assembly references and other source files are not accessible from the newly created script.
I can only speak about personal experience, but for me, this mostly (or even exclusively) happens when I use ‘Enter’ on a newly created script. Double click does usually work like a charm and triggers a solution-reload dialog as soon as VS gets focused again.
Once you run into this problem, it is usually enough to close VS and re-open with Unity. If that doesn’t fix it right away, you still got the option that @TaleOf4Gamers_1 has mentioned.
It caused by Renaming Project Folder after project creation.
Simple Solution: Rename your project file to original.
Boring Solution: After you create your script, go to VS and find your newly created script in the solution explorer panel. Right click and choose “Exclude from Project”. Then right click your Assets folder on solution explorer, select Add context, and then select “Existing Item” option. Then choose and add your newly created script file from this window. That fixes the problem. But still you have to do that for every single script.
Hello. I think this post is relatively old. Please excuse me for my english. I seem to have found the solution to this problem.
Right click Assembly-CSharp in the solution explorer and click unload the project. Then redo the same manipulation but this time to reload the project. Alleluia it works again
I’m afraid this is not the reason; I just created a script and opened it about 30 seconds after creating it and the problem is there. It doesn’t take that long to Unity to compile a new empty script.
I think generally VS with Unity has bad synchronization.
I didn’t hit issue as yours. But VS desyncing is not something uncommon for me.
So there may be something else going on.
Try in Unity Ctrl+R tor refresh, after script is created.
Or create script from VS. And copy, or type MonoBehaviour manually.
They ve fixed it, download latest Tools for Unity and Visual Studio 2017, there is a post in VS forums stating so. Anyway for me it does not happen anymore.
Problem:
Visual Studio 2017’s intellisense doesn’t recognize new MonoBehaviour scripts in generated from Unity.
Workaround:
Right-click the project in VS and unload the project (shortcut-L), right-click again and load it (shortcut-L again).
All MonoBehaviour scripts created hereafter no longer require the workaround. Visual Studio magically recognizes newly created scripts! I don’t understand why, but it works.
If I recall correctly, this was happening with Visual Studio already. The problem seems to have been fixed with the most recent versions of Unity; I haven’t seen it happening in 2018 or 2019 yet.
If you don’t have Visual Studio 2017 as an option, go to Start (Win10), type Visual Studio, right click on your preferred version (2017), select ‘open file location’, right click on the ‘Visual Studio 2017’ shortcut and select properties. Copy the full Target path without double quotes. Close out of these windows and get back into Unity.
then paste your full path in without quotes and hit Open. You should now see the friendly name for “Visual Studio 2017”. Close out of Preferences and double click your script file. Should open as expected now.