Search Unity

How can i do ? Warning message : Namespace 'System.Collections' is never used (BCW00

Discussion in 'iOS and tvOS' started by gamemiracle, Sep 5, 2011.

  1. gamemiracle

    gamemiracle

    Joined:
    Sep 5, 2011
    Posts:
    33
    i bought ios pro, when build iphone apps.

    error occur
    Warning message : Namespace 'System.Collections' is never used (BCW0016);
    Warning message : Namespace 'UnityEditor' is never used (BCW0016);


    Language : javascript


    thx for help
     
  2. ciaravoh

    ciaravoh

    Joined:
    Dec 16, 2009
    Posts:
    252
    would you please post the script ? you probably don't have any Start, Update, etc functions in your code.
     
  3. gamemiracle

    gamemiracle

    Joined:
    Sep 5, 2011
    Posts:
    33
    thx, solved it
     
  4. nummer31

    nummer31

    Joined:
    Sep 14, 2011
    Posts:
    18
    how did u solve it? I have the same problem.

    Here's my code:


    var speed = 3.0;
    var cratePrefab:Transform;

    function Update ()
    {
    if(Input.GetButtonDown("Fire"))
    {
    var crate = Instantiate(cratePrefab, transform.position, Quaternion.identity);
    crate.rigidbody.Addforce(transform.forward * 2000);
    }
     
  5. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    bump.
    :.?
     
  6. tenfour

    tenfour

    Joined:
    Jan 3, 2012
    Posts:
    7
    Same problem here. How did you solve it?

    This is appearing at the top of every js script in my project, even brand new ones that just have the empty Update function.
     
  7. Vincent_soo

    Vincent_soo

    Joined:
    May 12, 2011
    Posts:
    6
    Ya same problem here, it appear at the top of every js script in my project too
    Mind to share how you solve it?

     
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    This question keeps going unanswered. 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:
    Code (csharp):
    1. /* Silence MonoBehaviour Warnings*/ private function SilenceWarnings() : void { var al : ArrayList; if(al == null); var ae : AccelerationEvent; if(ae == 10) SilenceWarnings(); }
    Version for editor scripts:
    Code (csharp):
    1. /* 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.
     
    Last edited: Sep 24, 2012
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    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.
     
  10. xeophin

    xeophin

    Joined:
    Aug 14, 2012
    Posts:
    1
    Actually, you were on the right track, this does work. However, you need to change the syntax.

    Change it to this:

    Code (csharp):
    1. <NoWarn>0169</NoWarn>
    2. <NoWarn>0016</NoWarn>
    and it will do the trick.
     
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    This is working for you? I tried the modified syntax attempting to suppress 4 warnings. I added it to every .unityproj file in both Debug and Release sections, restarted MD, and nothing happened. Then I added it to all the .csproj files, restarted MD, and again nothing happened.

    Code (csharp):
    1. <NoWarn>0169</NoWarn>
    2. <NoWarn>0016</NoWarn>
    3. <NoWarn>0014</NoWarn>
    4. <NoWarn>0003</NoWarn>
    I got the original space separated syntax I tried from a C# project. It lets you specify ignored warnings in the MD GUI separated by spaces. The warnings are saved to the .csproj file in the same way <NoWarn>0169 ### ### ### ETC</NoWarn>.

    Also, be aware that when compiling in Unity, you don't get the 0016 warnings. You only see those when compiling directly in MonoDevelop. I guess it has those warnings suppressed internally. Can you verify yours is suppressing the 0016 warnings in MD?
     
  12. Beyond-Ken

    Beyond-Ken

    Joined:
    Dec 19, 2012
    Posts:
    7
    Try adding this unused class to the bottom of your script:

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

    MrVagoo

    Joined:
    Dec 28, 2012
    Posts:
    1
    I remove the '*' and warnings go away. Monodevelop Ver, 2.8.2
     
  14. Hardhitter77

    Hardhitter77

    Joined:
    Jul 17, 2012
    Posts:
    3
    Okay just found out how to get around this by a fluke. Didnt even really mean to do it but it works and the errors will stop coming up.

    1. Go to run

    2. Click exceptions

    3. Type in the system.collections or whatever script error is coming up

    4. Bottom right corner of the exceptions window click ok

    5. The specific error you typed in is now an exception and will not be shown again



    Worked for me hope it works for you guys.
     
  15. Sir-Gatlin

    Sir-Gatlin

    Joined:
    Jan 18, 2013
    Posts:
    28
    So, is there a reason to get rid of the warning? by just leaving them there and understand why they are happening will it cause any conflicts or problems later? I got the same warning and searched it just cause I wasn't sure if it was something i needed to worry about.
     
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,624
    It's just annoying and clutters up your warning list so it makes it harder to see the other more meaningful warnings.
     
  17. Khyrid

    Khyrid

    Joined:
    Oct 8, 2010
    Posts:
    1,790
    Go to run??? Where is run?

    ...Oh in monodevelop

    I tried it, didn't work.
     
    Last edited: Mar 24, 2013
  18. gigaloon

    gigaloon

    Joined:
    Jul 28, 2013
    Posts:
    1
    If I try using system.collections, it says I need a semicolon, despite the fact that I have one
    $Screen Shot 2013-10-06 at 6.26.21 PM.png
     
  19. tyoc213

    tyoc213

    Joined:
    Nov 14, 2011
    Posts:
    168

    Don't know.. but even using private (If I'm not wrong) and using it on multiple .js files from monodevelop, will cause a "previously defined" error.

    So I do the same, but with vars on the offending .js files



    At end of each offending .js.

    Code (csharp):
    1.  
    2. private var RemoveUnusedNameSpaceWarningsq:Queue;
    3. private var RemoveUnusedNameSpaceWarningsh:Help;
    4. private var RemoveUnusedNameSpaceWarningsg:GUI;
    5.  
    6.  
     
  20. Pawl

    Pawl

    Joined:
    Jun 23, 2013
    Posts:
    113
    Just wanted to say I'm using this solution to remove the errors and it's working fine, however I recommend wrapping the whole block in #if UNITY_EDITOR directives, otherwise Unity complains if you try to publish a web build, for example.

    Code (csharp):
    1.  
    2. #if UNITY_EDITOR
    3. private var RemoveUnusedNameSpaceWarningsq:Queue;
    4. private var RemoveUnusedNameSpaceWarningsh:Help;
    5. private var RemoveUnusedNameSpaceWarningsg:GUI;
    6. #endif
    7.