Search Unity

Error CS0106

Discussion in 'Scripting' started by omueller5, Jan 11, 2020.

  1. omueller5

    omueller5

    Joined:
    Jan 7, 2020
    Posts:
    2
    I am trying to make a pause menu but I have gotten an error saying that the modifier 'public' is not valid for the item; "Assets\Scripts\PauseMenu.cs(26,9): error CS0106: The modifier 'public' is not valid for this item". I can't finish the pause menu without having public in my code.
     

    Attached Files:

    • MVS.PNG
      MVS.PNG
      File size:
      24.2 KB
      Views:
      402
  2. WarmedxMints

    WarmedxMints

    Joined:
    Feb 6, 2017
    Posts:
    1,035
    Your issue is likely before that. It looks like you are trying to declare public methods within another method.
     
    Bunny83 likes this.
  3. omueller5

    omueller5

    Joined:
    Jan 7, 2020
    Posts:
    2
    my issue was I was trying to declare 4 public void methods in a void method, thanks for the help
     
    Kurt-Dekker likes this.
  4. gamenentertainment

    gamenentertainment

    Joined:
    Jan 12, 2021
    Posts:
    1
    I also have the same error..
     
  5. mopthrow

    mopthrow

    Joined:
    May 8, 2020
    Posts:
    348
    Make your own thread and post the entire code and the error messages :). We can't tell what's wrong without seeing your code.

    Please use the forum code tags when posting your code. It makes it easier to read.
     
    Bunny83 and Kurt-Dekker like this.
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,749
    Bunny83 and mopthrow like this.
  7. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    4,011
    Exactly!

    Well, if it's the same issue, the solution would be the same as well. If what WarmedxMints and omueller5 posted does not solve your issue, you don't have the same issue. This error can occur from all sorts of mistakes. For example in interface declarations you can't use the public modifer either. In any way, create your own thread..
     
    mopthrow likes this.