How can i close the namespace never used warning?

Mono Editor always remind me that “WARNING: Namespace ‘xxxx’ is never be used. (BCW0016)” message on the top of editor with yellow font. How can i close the annoying warning in Unity Script?

This question keeps going unanswered on here and the forums. From what I’ve found, there is no proper way to disable this warning. The Monobehaviour class (the default class used for all .js files) has imports predefined for UnityEngine, UnityEditor, System.Collections, and others. If your script doesn’t make any calls to these namespaces, you’ll get a warning. A possible but ugly workaround would be to use each namespace that’s giving you a warning by adding some code that does nothing but uses each namespace just to silence the warning. Add this function to each of the offending scripts at the top (after your pragmas and such).

Version for non-editor scripts:

/* Silence MonoBehaviour Warnings*/ private function SilenceWarnings() : void { var al : ArrayList; if(al == null); var ae : AccelerationEvent; if(ae == 10) SilenceWarnings(); }

Version for editor scripts:

/* Silence MonoBehaviour Warnings*/ private function SilenceWarnings() : void { var al : ArrayList; if(al == null); var ae : AccelerationEvent; if(ae == 0); var dcm : DrawCameraMode; if(dcm == 10) SilenceWarnings(); }

There’s no equvalent to C#'s #pragma warning disable #### that I can find. (Plus even if there were, there doesn’t seem to be a number code to disable this particular warning.)

It’s ugly, but that’s the only way around it that I’ve found.

In MonoDevelop, click “RUN” in the top toolbar. In the “RUN” drop-down, click on “EXCEPTIONS…”. Find “System.Collections.Generic.KeyNotFoundException” and press the Right Directional Arrow, which will put it into the “Stop in exceptions:” box. Click “OK” and you should be set. I usually want to know why a warning is happening and how to fix it, but after many hours, I have given up. If the warnings keep coming up, than the problem is elsewhere.

Add these to top of your script files.

#if UNITY_EDITOR NoWarning
	private var RemoveUnusedNameSpaceWarningsq:Queue;
	private var RemoveUnusedNameSpaceWarningsh:Help;
	private var RemoveUnusedNameSpaceWarningsg:GUI;
#endif

I found another possibility that showed promise, but I couldn’t get it to work. If you open your .unityproj files in the root of your unity project, there’s a line

<NoWarn>0169</NoWarn>

which is supposed to suppress warnings with a specific code. These are normally available in GUI by going to the compiler via the project options in C#, but on UnityScript no such option appears. They do appear in the .unityproj file however. Unfortunately, changing it to

<NoWarn>0169 0016</NoWarn>

has no effect. I tried changing it in both Debug and Release for all the unityproj files, but the warnings persisted. Perhaps someone else knows something I don’t and maybe there’s a way to get this working. Seems a whole lot better than my hack posted above if only it worked.

Try adding this unused class to the bottom of your script:

private class ShushES {var q:Queue; var h:Help; var g:GUI;}

I figured out how to hide this message! The message doesn’t do anything to your script… so there’s no point in trying to rid of it completely when it’s so difficult to remove. Simply right click on the yellow triangle with a ! in the center, and hit hide message bubble. It completely hides the error! No need for scare delving into things you don’t understand… :smiley:

PUT METHODS AS PROTECTED !