No MonoBehavior Scripts in file

In Section 1 part 6 [Introducing Visual Studio] I have run into an error which I cannot circumvent. I have read through similar errors and none of the suggestions or workarounds fix my issue. Any assistance in this matter would be greatly appreciated.

Hi Narosis,

What error did you get? I cannot see any problem in your screenshot.

My best guess is the filename doesnā€™t match the class name.

No MonoBehavior Scripts in the file or their names do not match the file name is one error & the second error is Canā€™t add script component ā€˜Introducerā€™ because the script class cannot be found. Make sure there are no compile errors and that the file name and class name match.

From the errors Iā€™m getting you may be correct, but where is the disconnect happeningā€¦ why are the filename and class name not matching?

also: on line 10 there is is screwdriver and when I click on it a arrow down menu appears with the ā€œoptionā€ [for lack of a better term] use expression body for methods

I think maybe just delete that script and create a new one since youā€™re not too far into it, make sure you delete the file and create the new one within Unity paying special attention to the naming so that Unity can get all the meta data sorted out properly.

Before you delete anything, click the right mouse button in your Assets folder in Unity and click on ā€œReimport allā€. If that did not help, try the following:

  1. Restart Unity and VS.
  2. Is Visual Studio selected as your External Script Editor in Unity (Edit > Preferences > External Tools)?
  3. Are the Unity development tools installed in VS (Tools > Extensions and Updates)? If they are not installed, go to Tools > Get Tools and Features.
  4. Please check if your scripts are included in the project in Visual Studio. Open the Solution Explorer with Ctrl + Alt + L. A dotted icon indicates that the object is not included. If thatā€™s the case, do the following:

  1. Reboot your PC.
  2. Close both Unity and VS. Go to your project folder and delete all sln and csproj files. Then start Unity again, double click on the script file inside your Assets folder in Unity.
  3. Try to update VS.
  4. Try to update Unity.

Did any of these suggestions fix the issue for you?

Iā€™ve deleted and recreated the file in question MULTIPLE times to no avail so I remain at an impasse.

!. & 5. Done repeatedly.
2. Visual studio IS selected as my External Script Editor.
3. The option to install Unity Development tools NOT available in Visual Studio for Mac.
4. Ctrl + Alt + L does NOTHING in Visual Studio for Mac.
6. Done, same results
7. & 8. Both are the latest versions

NONE of the suggestions worked for me.

Since I mentioned the Solution Explorer, have you already looked for answers on the internet?

That could be the problem. Have you already looked for the option on the internet?

That could also be the problem. For some people Visual Studio 2019 does not work well with Unity. If thatā€™s also the case here, test VS 2017.

Iā€™ve been scouring the internet for solutions since yesterday [starting around 14:00 eastern standard time]

I will ā€˜downgradeā€™ to VS 2017 [IF I can find it] after finally locating the download and installing Visual Studio for Mac Community 2017, I am presented with errors [see Image] VSfMC2017

Not only am I confronted with the aforementioned errors, VS 2017 constantly wants to upgrade to VS 2019ā€¦ thanks for all your help but I need a break the frustration this is creating is killing my desire to learn.

Ugh! I recently had that bug with my project tooā€¦

  1. Try uh copying all the important stuff in your game in the files folder
  2. Delete Project
  3. Make a new one and paste the files to replace all the ones in the new game
  4. See if it worked because I think it worked for me
  5. Good Luck and sorry if it doesnā€™t work but a Good project refresh may work

Tip: Try using VS Code because itā€™s awesome and it works for me

ULTIMATE TIP: DONā€™T GIVE UP!! KEEP ON LEARNING!!! :grinning:

I totally get how you feel, happens to all of us but @ErenYeager is right, donā€™t give up, youā€™ll find the solution soon!

Less frustrated and back at the ā€œgrindā€ā€¦ Following your suggestion I installed VS Code and because of that I direct this query to you,please take note of the attached imageā€¦ What do the three (3) ā€œ0 referencesā€ lines mean? VS Code

After installing the latest Unity Editor [2019.3.6f1] and executing ā€œReimport allā€, I am happy to report I am able to move forward. Thank [ALL OF] you for your assistance with this matter!!!

1 Like

Right on! I could be wrong but Iā€™m pretty sure those ā€œ0 referencesā€ just mean nothing is calling those methods, but visual studio doesnā€™t know that Unity calls Start and Update.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms