The funny part is that same script worked for 5 mins
I start to beleive that i made something wrong with the buttons “On CLick()”
EDIT:
this is the Errors :
Assets\Script\PauseMenu.cs(5,14): error CS0101: The namespace ‘’ already contains a definition for ‘PauseMenu’
Assets\Script\PauseMenu.cs(11,17): error CS0111: Type ‘PauseMenu’ already defines a member called ‘PauseButton’ with the same parameter types
Assets\Script\PauseMenu.cs(24,16): error CS0111: Type ‘PauseMenu’ already defines a member called ‘Resume’ with the same parameter types
Assets\Script\PauseMenu.cs(30,16): error CS0111: Type ‘PauseMenu’ already defines a member called ‘Pause’ with the same parameter types
Assets\Script\PauseMenu.cs(36,17): error CS0111: Type ‘PauseMenu’ already defines a member called ‘LoadMenu’ with the same parameter types
Assets\Script\PauseMenu.cs(40,17): error CS0111: Type ‘PauseMenu’ already defines a member called ‘QuitGame’ with the same parameter types
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class PauseMenu : MonoBehaviour
{
public static bool GameIsPaused = false;
public GameObject pauseMenuUI;
{
public void PauseButton()
{
if (GameIsPaused)
{
Resume();
}
else
{
Pause();
}
}
public void Resume()
{
pauseMenuUI.SetActive(false);
Time.timeScale = 1f;
GameIsPaused = false;
}
public void Pause()
{
pauseMenuUI.SetActive(true);
Time.timeScale = 0f;
GameIsPaused = true;
}
public void LoadMenu()
{
Time.timeScale = 1f ;
SceneManager.LoadScene("//main menu");
}
public void QuitGame()
{
Application.Quit();
}
}
This error means that you’ve written a class with a certain name, but there is already a class with that name in your project. You can’t have two classes with the same name unless they are in different name spaces.
Some possible causes of this error are:
C#, Unity, or an asset that you installed already had a class named PauseMenu
You wrote a script named PauseMenu and accidentally made a copy of it.
You updated an installed asset with scripts and for some accidental reason, it created a duplicate of the script instead updating the existing script.
I was able to fix it the cause of the error it was numer 2 somehow i copied my script i have no clue how that happen but thanks god i was able to find and delete the other one anyway thank you for taking the time to answer have a great day sir !
I am having the same issue but none of the 3 suggestions apply. It seems like after reopening my project, the errors just appeared and all my scripts are now broken. What can I do?
This bug has happened occasionally - try quitting Unity, deleting your project folder’s Library folder, and reopening Unity. This should cause Unity to reimport everything, and if cause by a bug, should fix it.
Figured out how I duplicated my scripts creating this issue. I had unity and MVS open. When I got an error I figured I could delete the space I made in the name of the script. HOWEVER this meant it created a new script when I saved the script I had open in MVS with the space still in it. The solution was to close out of Unity and MVS, rename the files in the folder (including the meta) and reopen.