Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Sometimes Unity is treating C# compile time Warnings as compile time Errors

Discussion in 'Unity 5 Pre-order Beta' started by dreasgrech, Feb 26, 2015.

  1. dreasgrech

    dreasgrech

    Joined:
    Feb 9, 2013
    Posts:
    205
    Sometimes, most of the times after switching from Visual Studio back to Unity after changing some code and pressing play, Unity treats a C# Warning like a C# error and it prevents you from compiling or running the game before that Warning has been fixed.

    It doesn't happen all the time though.

    The warning is also written in red in the Console, just like a C# error. In the same console message, all the C# warnings in my project are also written (in red).

    An example warning which Unity is sometimes treating as an error is: Assets/MyClassXYZ.cs(47,22): warning CS0168: The variable `someVariable' is declared but never used

    Unity doesn't let you run the game before you go and fix the Warning.

    Is this happening to anyone else?
     
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    I have never seen something like that.
     
  3. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    317
    This behaviour is odd. Please, next time you see this happening, send the Editor.log so I can take a look

    Adriano
     
  4. Breyer

    Breyer

    Joined:
    Nov 10, 2012
    Posts:
    412
    I had this problem antyviurs very often cause this. Disable antyvirus or reinstal unity
     
    Guhanesh likes this.
  5. Anozireth

    Anozireth

    Joined:
    Feb 7, 2013
    Posts:
    71
    Do you have an smcs.rsp or gmcs.rsp file in your Assets folder? Warning-as-error can be turned on in that file with the line:

    -warnaserror+

    We always have it turned on.
     
    Seanm07 likes this.
  6. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    I've seen this problem when the compiler couldn't create the output DLLs in the Temp/ folder because the output file was locked by some other process. This goes along the lines of what Breyer suggests. Can happen with Dropbox, too. In these cases, the full text output of the warning message when you select it in the console shows an error when you scroll further down. Not ideal that the two get mixed up and it looks as if the warning made the compile fail.