Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question Main Menu script not working...

Discussion in 'Getting Started' started by notjake85, Apr 5, 2024.

  1. notjake85

    notjake85

    Joined:
    Feb 20, 2024
    Posts:
    45
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5.  
    6. public class MainMenu : MonoBehaviour
    7. {
    8.     public void PlayGame ()
    9.     {
    10.         SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
    11.     }
    12.  
    13.     public void QuitGame ()
    14.     {
    15.         Application.Quit();
    16.     }
    17. }
    Assets\Scripts\MainMenu.cs(8,17): error CS0111: Type 'MainMenu' already defines a member called 'PlayGame' with the same parameter types

    Assets\Scripts\MainMenu.cs(6,14): error CS0101: The namespace '<global namespace>' already contains a definition for 'MainMenu'
     
  2. notjake85

    notjake85

    Joined:
    Feb 20, 2024
    Posts:
    45
    I have no clue what global namespace is
     
  3. Chubzdoomer

    Chubzdoomer

    Joined:
    Sep 27, 2014
    Posts:
    136
    Sounds like you potentially have duplicate script files in your project (two MainMenu scripts/classes).