- Home /
Disable warning messages
Greetings,
Is it possible to disable the yellow exclamation point warnings in the editor console? Many of my variables are not recognized as being used, they are used btw, and my Console is filling up with a ton of these warnings. I would prefer only the serious warnings appeared.
Thanks
Be careful when you disable warnings, they are there for a reason -- better to fix the issue (even if it's $$anonymous$$or) than ignore it.
Actually, warnings are not errors for a reason too. Sometimes there's no issue to be fixed, and if you know what you're doing, it is very okay to disable the warning. I'd even argue there should be a nicer way to do it so.
Answer by Cyclops · Jul 08, 2010 at 02:16 PM
In C# you can disable them via a pragma at the top of your script file (I don't think Javascript has anything but #pragma strict). Some common ones being:
#pragma warning disable 0168 // variable declared but not used.
#pragma warning disable 0219 // variable assigned but not used.
#pragma warning disable 0414 // private field assigned but not used.
As other warnings come up you just keep adding them - I strongly suggest you take them out for the final build. :) This is just for development.
awesome, thanks cyclops. Just to clarify, you suggest deleting all of the pragmas before final build? Is this to make sure you really do not have unused variables and what not? Thanks.
@Andrew - correct. In fact, any time I am about to make a major check-in to Subversion (version control), I comment the lines out just to check for any problems.
thank you soooo much it got pretty annoying now when I'm rewriting my code
you can obviously find the code on the warning message itself. Here are a couple for obsolete code: 0618
and 0612
One thing to add - if you just want to stop the warning on one variable, you can use:
#pragma warning disable 0219
int variable = 2;
#pragma warning restore 0219
Answer by Cardinalby · Dec 03, 2015 at 08:29 AM
To ignore warnings in all files create two text files called gmcs.rsp (for editor scripts) and smcs.rsp (for game scripts) into your YOUR_PROJECT_NAME/Assets directory with contents (for example):
-nowarn:0414
0414 is warning number
This is the real & professional solution for Unity Engine. Thanks a lot!
Just for your information, if you want to reduce compile times by disabling warnings, it won't work. You have to fix the warnings, because they will still be generated, but just not shown in the log.
FYI, these files are deprecated - now you just create one file named "mcs.rsp" (see docs: https://docs.unity3d.com/$$anonymous$$anual/PlatformDependentCompilation.html)
This file is now deprecated (if targeting .NET Framework 4.x), use "csc.rsp" x)
Note that this will indeed only disable the warnings in Unity console. It's not going to do anything towards adding a element to the .csproj file generated by Unity. This means that if you build in an external editor (Visual Studio, Rider etc.) the warnings will still be there.
To add the disable to the .csproj file, you would have to postprocess the .csproj file after Unity generates it. The answer here can guide you in the correct direction if you want to do that: https://answers.unity.com/questions/54177/change-visual-studio-solution-generated-by-unity.html
Answer by callme · Nov 25, 2016 at 04:40 PM
Console > Find little yellow triangle > click.
Answer by Max_power1965 · Jul 10, 2016 at 05:56 PM
Right-click your project -> Options -> Compiler and either adjust the warning level or list the warnings you don't want to be told about in the "Ignore warnings" text box.
Answer by t36k · Aug 26, 2017 at 12:21 AM
In version 5.9.6 of MonoDevelop, you can just go to View > Message Bubbles.
There you have 3 options:
Hide Message Bubbles
Errors & Warnings
Errors Only
Your answer
Follow this Question
Related Questions
How to re-trigger all compiler warnings in the Editor?? 1 Answer
host set to C:\Program Files\Unity\Hub\Editor\2019.4.9f1\Editor\Data\Tools\RoslynScripts\..\.. 0 Answers
Should not be capturing when there is a hotcontrol 10 Answers
DebugConsole console clicking 5 Answers
How do I change the default application used to open logs from the Unity editor? (on Mac) 1 Answer