Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Search each child of a GameObject searching for a string-name
- /// </summary>
- /// <param name="root">Parent gameObejct</param>
- /// <param name="aName">The name that you are looking for</param>
- /// <returns>The GameObject that you were looking for</returns>
- public static GameObject FindChild(GameObject root, string aName)
- {
- SkinnedMeshRenderer[] children = root.GetComponentsInChildren<SkinnedMeshRenderer>(true);
- for (int i = 0; i < children.Length; i++)
- {
- if (children[i].name == aName)
- return children[i].gameObject;
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement