This question was 
             closed Mar 18, 2016 at 04:57 AM by 
             lennotoecom for the following reason: 
             
 
            wrong neighbors List creation, fail at the OnTriggerEnter2D function
 
               Question by 
               lennotoecom · Mar 18, 2016 at 12:44 PM · 
                c#listgameobjectsforeach  
              
 
              c# foreach does not work
Hello,
please help me, I'm desperate and cannot find the solution.
 
 Below is the code that does not work:
 List<sq> aList = new List<sq> ();
 compileList(sqA, ref aList);
 
 public void compileList(sq e, ref List<sq> iList){
     foreach(sq s in e.neighbors){
         compileList(s, ref iList);
     }
 }
sq class contains
 public class sq : MonoBehaviour {
     public List<sq> neighbors = new List<sq> ();
     ...
 }
but the foreach loop is not even called to every recursive neighbor : (
 Neighbors are constructed like this:
 sqA - sqB - sqC - sqD - sqE
 where, for example sqB has neighbors sqA and sqC,
 and sqA has a single neighbor sqB.
 Any help much appreciated.
               Comment
              
 
               
               koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                