Laser Defender - global namespace problem w/ music player?

I’m using Unity 2019.3.0f6 and I don’t know how to solve this problem.
After I created the player and wrote the script I’ve run into an error CS0101: The namespace ', already contains a definition for ‘Music Player’.
It’s referencing where I changed it after public class (line 5). I tried changing it to ‘MusicPLayer’ and it could play the game and the music but when it loaded to the next screen the singleton didn’t work and it restarted the song.
:frowning:

Hi Jayne,

Please watch lecture “Fixing Visual Studio Problems” (currently #4). Did this help with the classname issue?

Just went down that checklist, aside from using Unity 2018 (only because I’m using 2019 like I said before). I had updated VS before I started working and it’s version 16.5.5 too. Still no fix.

I went into the lecture changes and copy-pasted the script from there and now i’m running into 2 more errors, but these are “error CS0111- Type ‘MusicPlayer’ already defines a member called ‘Awake’ with the same parameter types” and the same for ‘SetUpSingleton’. These, in addition to the original error CS0101.

Does MonoBehaviour have the same colour as your classname? If not, there might still be a problem with Visual Studio.

  1. You could also try to click the right mouse button in the Assets folder, then on “Reimport all”.
  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. 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.
  5. Try to update VS.
  6. Try to update Unity.

Did any of these fix the issue for you?

MusicPlayer and MonoBehavior are the same color blue.
I just reimported the assets, I checked the external script editor and Unity Dev Tools is installed in VS (just triple checked). It says Unity Editor is up to date and I just updated VS last night but I tried to check again and it’s up to date. I looked in my folder and found no sln or csproj files to delete.

I attached a screen shot with my visual studio open.

Expand this:

image

Then check if there are two MovePlayer scripts in the list.

Oh that did it! Thank you for helping me figure that one out :slight_smile:

You’re welcome. :slight_smile:

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

Privacy & Terms