Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity find object by name recursion

    public GameObject FindChildRecursive(GameObject parent, string childName) {
        foreach(Transform child in parent.transform) {
            if(child.name == childName) {
                return child.gameObject;
            } else {
                if(child.childCount > 0) {
                    GameObject result = FindChildRecursive(child.gameObject, childName);
                    if(result != null) return result;
                }
            }
        }
        return null;
    }
Comment

PREVIOUS NEXT
Code Example
Csharp :: get text after word C# 
Csharp :: how to create a list c# 
Csharp :: change color of object unity 
Csharp :: unity deactivate component 
Csharp :: create list in c# 
Csharp :: c# insert spaces before capital letters 
Csharp :: get file extension in c# file upload 
Csharp :: Customize yup number 
Csharp :: how to pass optional guid parameters in c# 
Csharp :: calculate how much memory an object take c# 
Csharp :: delete the particular line in files in c# 
Csharp :: vector3 unity 
Csharp :: how to flip a character in unity 2d 
Csharp :: c# get all namespaces in assembly 
Csharp :: set rotation unity 
Csharp :: .net core web app get dll name 
Csharp :: asp.net 5 iis HTTP Error 500.19 - Internal Server Error 
Csharp :: bundle.config in mvc is missing 
Csharp :: c# get custom attribute from property 
Csharp :: append multi lines to file linux 
Csharp :: the .net core sdk cannot be located 
Csharp :: convert int32 
Csharp :: how to get a length of a string in c# 
Csharp :: default parameter c# 
Csharp :: c# itext 7 PdfDocument from byte array 
Csharp :: what value of combobox index c# 
Csharp :: c# string to float 
Csharp :: linked list reverse 
Csharp :: get enum value c# 
Csharp :: ActionExecutingContext result response return 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =