Find() Instance Which is Child

Is there a way to get a specific object in scene… meaning I have more than 1 instance of objectX, for every objectX there is an objectY. ObjectX is a child of objectY. If objectY asks objectX = GameObject.Find(“ObjectX”); It may return the incorrect instance.

Yes, find it through its Transform and/or GameObject.

I am using this…

	for (var child : GameObject in gameObject)
	{
      if (child.name == "dbMeter")
      {
          dbMeter = child.gameObject;
          print("::::::::::child " + child);
      }
  	}

but get this error…

That’s because GameObjects don’t have children. Transforms do.

A GameObject is nothing but a collection of linked Components. Components are what provide all functionality, structure and behaviour to a GameObject. Specifically, the Transform component gives a GameObject position, rotation, scale and a relationship to other Transforms.

ah, that seems to have done it.

	for (var child : Transform in transform)
	{
      if (child.gameObject.name == "dbMeter")
      {
          dbMeter = child.gameObject;
          print("::::::::::child " + child);
      }
  	}

thanks.

just in case, are you able to answer a question on shaders?
http://forum.unity3d.com/threads/160064-Need-50-Aplha-Shader-Questions
Traffic is very slow and urgency is very high.

No need to enumerate the children. Just use Transform.Find instead.

Transform dbTran = transform.Find("dbMeter");
if (dbTran != null)
    dbMeter = dbTran.gameObject;