- Home /
Problem is not reproducible or outdated
If child.name == String problem
Hi to all! I have a very simple problem which is driving me crazy:
for (var child :Transform in transform)
{
print(child.name);
if(child.name=="ChildX")
{
print("I would love to see this message in the console");
break;
}
}
Now, the first print is working fine. ChildX is in there. The second print, no.The child.name condition is never satisfied... It must be dead simple, what am I doing wrong? Many thanks for your help,
Gregzo
Answer by Statement · Dec 07, 2011 at 01:13 PM
Maybe you have a space or something in the name of ChildX? How about case sensitivity?
Try this:
print("[" + child.name + "] " + child.name.Length + " characters long");
to see if there are any whitespace in the name. The length should be 6 for your string.
I've tried it already, no spaces. I've tried rena$$anonymous$$g as well...
Silly me, the child's name was long and there was a typo. Thanks for helping, voted your answer up.
Gregzo
Follow this Question
Related Questions
Show variable name from a class as String 2 Answers
How do I retrieve Mecanim State Name? 2 Answers
Get Parent name of child 1 Answer
String to Var 1 Answer
How to call a child by tag or name 1 Answer