Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

error CS0201

Discussion in 'Getting Started' started by rrobuxian, Jun 24, 2020.

  1. rrobuxian

    rrobuxian

    Joined:
    Jun 24, 2020
    Posts:
    2
    Hello!
    Im making a 3d puzzle game, and the following code is typed correctly, but it gives a error.

    public void QuitGame ()
    {
    Application.Quit
    }


    Im using Unity 2017.4.40f1 Personal 64 bit
    Also, every time i want to use the debug log this happens:
    Error CS0104: ‘Debug’ is a ambiguous reference between ‘System.Diagnostics.Debug’ and ‘UnityEngine.Debug’

    can someone please help me?
     
  2. DaDonik

    DaDonik

    Joined:
    Jun 17, 2013
    Posts:
    258
    If your code throws errors that do not even let it compile, it is 100% not 'typed correctly'.
    This is something to remember when you get the next few thousands of errors of the same
    kind. It's always you who has done something wrong, no matter how strongly you believe you
    have done it correct. Computers don't make errors until the hardware fails.
    Don't take that the wrong way, it happens to all of us. You just have to be aware that it's your fault :D

    See this for your answer on what went wrong.


    You don't need System.Diagnostics.Debug. Remove it from the top of your file.
    Alternatively you can tell the compiler which one you want, by being more specific.
    Write
    Code (CSharp):
    1. UnityEngine.Debug.Log("LoggyLog");
    instead of
    Code (CSharp):
    1. Debug.Log("LoggyLog");
    so the compiler knows which one you mean.
     
  3. rrobuxian

    rrobuxian

    Joined:
    Jun 24, 2020
    Posts:
    2
    That helped a lot! Now i can finally use Debug.Log now!
    I forgot to place () after Application.Quit . I don't know how i forgot that, but i just did! Thanks alot for your help!
     
    DaDonik likes this.