- Home /
List Bug when using debugger
So I have a list of enemies that I instantiate via a loop. This successfully spawns an enemy, but only ever one. When I make the list I get ENData (null) when I set it to the levels enemy list (taken from another script) it becomes this:
EBData Count=1
Unknown type 'System.Collections.Generic.CollectionDebuggerView'1, mscorlib.dll'
Now when it goes into the loop I can view the variables inside by hovering my mouse over them, and the enemy is spawned correctly. If I go into the script the list is being called from and check it there I receive the same error.
Alright here is some code (Sorry for the delay (9 hour shift)) This is the EnemyData Struct public struct EnemyData{ string mName; int mX; int mY;
public EnemyData(string name, int x, int y){
mName = name;
mX = x;
mY = y;
}
public string Name{
get{return mName;}
}
public int X{
get{return mX;}
}
public int Y{
get{return mY;}
}
}
And inside Level I have: (Remember Enemies here causes the error as well)
protected List<EnemyData> Enemies = new List<EnemyData>();
public List<EnemyData> GetEnemyData(){
return Enemies;
}
And then in AI$$anonymous$$anager I have:
List<EnemyData> ENData = new List<EnemyData>();
ENData = GetComponent<Level$$anonymous$$anager>().CurrentLevel.GetEnemyData();
Does that help?
I had this bug before, I fixed it by making a new class file and copy the code in, but I'd like a better fix.
O$$anonymous$$, I ran a test and got the same error in the debugger as you. Then I saw this at StackOverflow. So, this would seem to be a bug in $$anonymous$$ono, but should only affect you when using the debugger.
In my test, I added several items to the list, then printed them out in Debug.Log and they were all there. So this bug should not affect your running game.
whebert for suggesting printing Lists, this is a genuinely good tactic given the weepy state of the editor.
for 'only happens when debugging'. Bert, debugging is the most important part of writing code
Answer by Artless · Apr 12, 2015 at 05:39 PM
Look for solution: http://answers.unity3d.com/questions/560154/unable-to-populate-systemgenericcollectionslist.html#answer-945499
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
C# GameObject Lists 2 Answers
Issues outputting a list of strings 1 Answer
need help adding all gameobjects with a specific name to a list 1 Answer
how to debug in monodevelop 1 Answer