Skip to content

Instantly share code, notes, and snippets.

@arun02139
Created June 11, 2015 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arun02139/30df7a9eb2ad0c96ec38 to your computer and use it in GitHub Desktop.
Save arun02139/30df7a9eb2ad0c96ec38 to your computer and use it in GitHub Desktop.
public static GameObject FindRecursive(this GameObject o, string target_name)
{
if(o.name == target_name)
return o;
int numChildren = o.transform.childCount;
for (int i = 0; i < numChildren; ++i)
{
GameObject tRet = o.transform.GetChild(i).gameObject.FindRecursive(target_name);
if(tRet != null)
return tRet;
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment