• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by W01Fi3 · Apr 19, 2016 at 05:02 AM · other

Unity 5: BCE0021: Namespace 'System.Collections' not found, maybe you forgot to add an assembly reference?

I've been looking around for a long time trying to find a solution but I only found things that linked to unity 3 which don't even have answers.

I am using some JavaScript and some C# on Unity 5.3.4

Edit: Only JavaScripts are affected.

I don't know why this is happening, and I'm not sure why this is happening. This all happened when I deleted one of my assets and it's script.

Here's one of my scripts with the error, but I don't see what's wrong. Assets/Generator and control point assets/Generator.js(1,1): BCE0021: Namespace 'System.Collections' not found, maybe you forgot to add an assembly reference?

 #pragma strict
 
 var Health : float = 20;
 var MaxHealth : int = 90;
 var Speed : float = 1;
 var HealthFloat : float = 1;
 
 var ControlPointUI : UI.Text;
 var ControlPointBackround : UI.Image;
 var ControlPointUISlider : RectTransform;
 var ControlPointUIGameObject : GameObject;
 
 var UnderAttack : boolean = false;
 var TextEnabled : boolean = false;
 var Friendly : boolean;
 var Reclaiming : boolean;
 var CanHack : boolean = true;
 var CanReclaim : boolean = true;
 var PlayerInside : boolean;
 
 var BaseName : String;
 var TeamControlled : String;
 var NBPlayerStatus : String;
 
 var LightsToDisable : Behaviour[];
 
 var PeopleInRange : int;
 var RubyInRange : int;
 var SapphireInRange : int;
 
 function Start()
 {
     Health = MaxHealth;
     TextEnabled = false;
     PlayerInside = false;
 }
 function Update()
 {
     AssignUI();
     UpdateText();
 
     HealthFloat = Health/MaxHealth;
 
     //if(TextEnabled == true)
     //{
     //    ControlPointUIGameObject.SetActive(true);
     //}
     //else
     //{
     //    ControlPointUIGameObject.SetActive(false);
     //}
 
     if(RubyInRange == SapphireInRange && RubyInRange > 0 && SapphireInRange > 0)
     {
         NBPlayerStatus = "Contested";
         Reclaiming = false;
         UnderAttack = false;
     }
     else if(RubyInRange > SapphireInRange && TeamControlled == "Ruby" && Health < MaxHealth || RubyInRange < SapphireInRange && TeamControlled == "Sapphire" && Health < MaxHealth)
     {
         NBPlayerStatus = "Reclaiming";
         if(Reclaiming == false)
         {
             GeneratorRecapture();
         }
     }
     else if(RubyInRange == 0 && SapphireInRange == 0 && Health == MaxHealth || RubyInRange > SapphireInRange && TeamControlled == "Ruby" || RubyInRange < SapphireInRange && TeamControlled == "Sapphire")
     {
         NBPlayerStatus = "Secure";
         Reclaiming = false;
         UnderAttack = false;
     }
     else if(RubyInRange < SapphireInRange && TeamControlled == "Ruby" || RubyInRange > SapphireInRange && TeamControlled == "Sapphire" && Health > 0)
     {
         NBPlayerStatus = "Capturing";
         if(UnderAttack == false)
         {
             GeneratorCapture();
         }
     }
 }
 function AssignUI()
 {
     if(ControlPointBackround == null)
     {
         ControlPointBackround = gameObject.Find("CPointUI").GetComponent("Image");
     }
     if(ControlPointUI == null)
     {
         ControlPointUI = gameObject.Find("CPointUIText").GetComponent("UnityEngine.UI.Text");
     }
     if(ControlPointUIGameObject == null)
     {
         ControlPointUIGameObject = gameObject.Find("CPointUI");
     }
     if(ControlPointUISlider == null)
     {
         ControlPointUISlider = gameObject.Find("CPointUISlider").GetComponent("RectTransform");
     }
 }
 function OnTriggerEnter(collider : Collider)
 {
     PlayerInside = true;
     if(collider.tag == "Ruby")
     {
         RubyInRange += 1;
     }
     else if(collider.tag == "Sapphire")
     {
         SapphireInRange += 1;
     }
     TextEnabled = true;
 }
 function OnTriggerStay()
 {}
 function OnTriggerExit(collider : Collider)
 {
     if(collider.tag == "Ruby")
     {
         RubyInRange -= 1;
     }
     else if(collider.tag == "Sapphire")
     {
         SapphireInRange -= 1;
     }
     PlayerInside = false;
     CanHack = true;
     CanReclaim = true;
     TextEnabled = false;
 }
 function UpdateText()
 {
     if(PlayerInside == true)
     {
         ControlPointUISlider.transform.localScale = new Vector3(HealthFloat, 1f, 1f);
         if(UnderAttack == false && Reclaiming == false && Health == MaxHealth)
         {
             ControlPointUI.text = (BaseName + " - " + " Generator Stable - " + NBPlayerStatus);
             //ControlPointUI.GetComponent.<Renderer>().material.color = Color.green;
         }
         else if(UnderAttack == true && Reclaiming == false && Health > 0)
         {
             ControlPointUI.text = (BaseName + " - " + " Generator Critical! " + Health + " - " + NBPlayerStatus);
             //ControlPointUI.GetComponent.<Renderer>().material.color = Color.yellow;
         }
         else if(UnderAttack == false && Reclaiming == false && Health == 0)
         {
             ControlPointUI.text = (BaseName + " - " + " Generator Destroyed! - " + NBPlayerStatus);
             //ControlPointUI.GetComponent.<Renderer>().material.color = Color.red;
         }
         else if(UnderAttack == false && Reclaiming == true)
         {
             ControlPointUI.text = (BaseName + " - " + " Repairing Generator " + Health + " - " + NBPlayerStatus);
             //ControlPointUI.GetComponent.<Renderer>().material.color = Color.green;
         }
     }
 }
 function GeneratorCapture()
 {
     gameObject.Find(BaseName + " ControlPannel").SendMessage("GeneratorSystem", true);
     gameObject.Find(BaseName + " ControlPannel").SendMessage("GeneratorStatus", "Contested");
     UnderAttack = true;
     Reclaiming = false;
     do
     {
     if(Health == 0)
     {
         gameObject.Find(BaseName + " ControlPannel").SendMessage("GeneratorStatus", "Destroyed");
         UnderAttack = false;
     }
     if(Health == MaxHealth/2.5)
     {
         gameObject.Find(BaseName + " ControlPannel").SendMessage("GeneratorStatus", "Critical");
     }
     if(Health > 0)
     {
         yield WaitForSeconds(1/Speed);
         Health -= 1;
     }
 
     }while(UnderAttack == true && Reclaiming == false);
 }
 function GeneratorRecapture()
 {
     UnderAttack = false;
     Reclaiming = true;
     do
     {    
     yield WaitForSeconds(0.5/Speed);
     Health += 1;
     gameObject.Find(BaseName + " ControlPannel").SendMessage("GeneratorStatus", "Contested");
     if(Health == MaxHealth)
         {
             Reclaiming = false;
             gameObject.Find(BaseName + " ControlPannel").SendMessage("GeneratorStatus", "Online");
         }
     }while(Reclaiming == true && UnderAttack == false);
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by W01Fi3 · Apr 23, 2016 at 08:10 PM

Alright I fixed it. After searching through google, I found this person who said that they named a script "System". I did the same thing. The fix is to not name a script "System"

Yay, I can now do stuff

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Zoogyburger · Apr 19, 2016 at 04:29 PM

Try adding a

 import System.Collections.Generic;

under

  #pragma strict


Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image W01Fi3 · Apr 19, 2016 at 06:55 PM 0
Share

No, it just added another error on JS. BCE0021: Namespace 'System.Collections.Generic' not found, maybe you forgot to add an assembly reference?

And I just realized this glitch only occurs on JavaScripts. $$anonymous$$y C# Scripts are fine.

avatar image Zoogyburger · Apr 19, 2016 at 07:05 PM 0
Share

What did you delete? The program probably can't find the script it needs.

avatar image W01Fi3 · Apr 20, 2016 at 05:13 PM 0
Share

I deleted what I planned to be a place to get new weapons but I deleted it cause i was going to remake it at a later day. I deleted the prefab and it's script and now it's freaking out about what ever is going on.

avatar image landon912 W01Fi3 · Apr 20, 2016 at 05:14 PM 0
Share

$$anonymous$$oved to comment.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Read string from other script (C#) 1 Answer

Access variable from script on other gameobject. 1 Answer

Create blips relative to the players position on a minimap. 1 Answer

Access guiText from other object. 3 Answers

Why i can not access these variables? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges