I've recently begun working with unity C# and I've been having a lot of trouble overcoming a seemingly simple task. I am basically writing a simple script that asks a parent for a list of it's children, and then loops through the children comparing their names to a master list that I have created. I'm struggling with getting this to function and the only thing I can think to do is to give you guys some psuedo code and see if anyone can help me create a functioning script.
If simple things like loop constructs and arrays/lists are stumping you I'd suggest you invest in a C# book or find some a good online course or set of tutorials that teaches from basic command structures and primitive types though to collections. It'll save you a lot of time in the long run.
a bunch of parentheses could be removed, but for completeness i kept them all. Code (csharp): int count = 0; List<Transform> failedObj = new List<Transform>(); foreach(Transform childTransform in transform) { bool hasMatched = false; foreach(Transform obj in MasterList) { if (childTransform == obj) { hasMatch = true; break; } } if(hasMatch) { failedObj.Add(childTransform); } count++; }
I agree entirely with what you're suggesting. That is what I am doing and plan on continuing to do, however my current project is time sensitive and i'm having to work in an area I am not comfortable with yet.