- Home /
#pragma warning disable on a global scale from within 1 script only?
I was wondering if there's a way to globally disable warning messages on all scripts, from 1 main script containing all #pragma warning disable error numbers?
I want to know this as well!!!!!!
BU$$anonymous$$P BU$$anonymous$$P BU$$anonymous$$P
There are no warnings that can never point to a possible problem, so I'd imagine that no one would bother to implement a way to hide a warning disabler where it will never be found.
Answer by Aaal · Apr 12, 2013 at 01:20 AM
Sorry, I deleted away my earlier comment. Should have commented instead of answered. But now I have found out the answer to my needs.
Ok for JS n boo users, please refer to unity manual. For c# users, create a file n name it smcs.rcp. Save this file under your assets/ folder. As for what to key in, you can either do a 'smcs -help' n find out all the options or key 'man smcs help' or something similar on the Internet. It will retrieve manual pages of smcs options. These are served as arguments to the compiler when it begins its compilation. You will ONLY notice the difference ONCE you update your scripts.
Ok, for a simple example, I need to disable warnings that imported packages always prompt. I have decided not to change their scripts as the updates will overwrite mine. Hence, create the file as I mentioned above and to disable the warnings, just key -nowarn:XXXX, where the XXXX is the number code of your warning. Voila! It works like charm.
As for c# editor's warnings or other global settings for it, create gmcs.rcp file instead.
Per @Louis's point though - you will never see those warning for your own code either right? Since 4.1 and the new ability to hide warnings in the console it would feel dangerous to me to suppress them. I guess it does make my build logs pretty large.
There are a few warnings that I disable in most of my scripts, but I still want to re-enable them when I do some debugging, and going through each script is a pain. Having a central location to enable/disable such things is definitively a plus!
Super thumbs-up for finding that. Hopefully only responsible users will take advantage of it. :D
@ronronmx: I'm just wondering what are those warnings you want to hide. Any examples? I can't think of any warning i just want to hide ins$$anonymous$$d of fixing the issue.
Answer by sewy · Feb 07, 2020 at 02:35 PM
For .NET 4.x the file is csc.rsp
and the text insede looks like -nowarn:CS0414,CS0649
https://docs.unity3d.com/Manual/PlatformDependentCompilation.html https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/nowarn-compiler-option
Your answer
Follow this Question
Related Questions
Can I get a warning if I (involuntarily) declare a new js variable in an assignment? 2 Answers
Script attached to 'Main Camera' in scene '' is missing or no valid script is attached. 0 Answers
Facebook Plugin Warnings 1 Answer
ios cant access variables in array 1 Answer
New Monobehaviour warning - instantiating unattached functions 1 Answer