Quantcast
Channel: Answers by "dubbreak"
Viewing all articles
Browse latest Browse all 68

Answer by dubbreak

$
0
0
Your problem is in your first loop. Each time you loops you are reassigning pcs with the one component from that object. It should be something along the lines of: foreach(GameObject go in obj) //for every object { pcs.Add( = GetComponent<PipeConnectorScript>()); //pcs of type script } You could also do this via linq: Using System.Linq; var pcs = objs.Where(n => n.GetComponent<PipeConnectorScript>!=null).Select(n => n.GetComponent<PipeConnectorScript>!=null).ToList(); Alternatively you can do it all in one fell swoop (since it looks like this is all in one method). won = true; foreach(var obj in objs)//for each script { var pipeScript = obj.GetComponent<PipeConnectorScript> if (pipeScript !=null) { won = won && pipeScript .connected; } }

Viewing all articles
Browse latest Browse all 68

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>