Reputation: 2369
When I build/enter play mode in the Unity IDE, many warnings clutter the console window that have been generated by script compilation of 3rd-party assets. How can I disable or hide the console warnings from specific assets without making changes to those assets?
I anticipate people righteously howling about how I need to fix the warnings instead of sweeping them under the rug. But to those folks, please consider...
The code is in 3rd-party assets--not mine. Typically, no upgrade on the asset is available that would fix the messages, and I've reviewed the messages and judged them to be benign. I realize the value of warnings, but I don't want to dig into 3rd-party code to fix the warnings. I'm also reluctant to change the code in these assets because it essentially gives me a local fork. And then future updates on the asset from the 3rd-party will need to be hand-merged against my local updates. That's time-consuming and introduces risk.
Upvotes: 5
Views: 1462
Reputation: 8622
Thank you to both Erik Hermansen and Adam B for providing solutions.
I went with Erik Hermansen's solution, but modified it slighty, sort of the other way around :) :
Note that you probably have to add some references to each assembly:
MyAssembly.asmdef:
ThirdParty.asmdef:
(maybe some others, depending on your own project)
Upvotes: 2
Reputation: 3861
Put the plugin into its own folder and make an assembly definition if there isn't one already.
Then you need to create a csc.rsp
text file alongside the assembly definition
Edit this csc.rsp
and add this line
-warn:0
This will set the warning level to 0 (no warnings) for that assembly only.
see https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/errors-warnings
Upvotes: 1
Reputation: 2369
Two years later, I can answer my own question. :)
Create .asmdef
files such that third party assets are in one manifest, and all project code is in a separate .asmdef
. So in my project, I keep the 3rd-party assets just under Assets
with project
one level down.
Assets
(folder)
thirdPartyAssets.asmdef
Project
(folder)
project.asmdef
This basically "disables" warnings from 3rd-party assets by simply not building them. You will still see 3rd-party build warnings if those assets change or a clean build is made.
The original question was how to disable for specific assets, so I'll note that it's possible to arrange the .asmdefs
to include/exclude assets in different groups. And simply putting an .asmdef
into the folder of one asset that warning-spams, will cause that single asset's warnings not to be shown except for the cases I described in the previous paragraph.
Upvotes: 4