Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity find gameobject by name

GameObject enemy = GameObject.Find("enemy");
Comment

c# unity get name of object

public GameObject obj;

void Start()
{
	string objName = obj.name;
  	Debug.Log(objName);
}
Comment

unity find object by name

    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 :: c# get all inherited classes of a class 
Csharp :: pause audio unity 
Csharp :: enum loop 
Csharp :: regex for email c# 
Csharp :: unity check if key pressed 
Csharp :: c# executable directory 
Csharp :: writeline c# 
Csharp :: unity log 
Csharp :: c# copy to clipboard 
Csharp :: c# random boolean 
Csharp :: open website c# 
Csharp :: creatw list of int in C# 
Csharp :: unity get current scene 
Csharp :: write to file c# 
Csharp :: unity spawn object at position 
Csharp :: c# tostring mmm dd yyyy 
Csharp :: c# get wifi ip address 
Csharp :: how to populate listbox using list<t c# 
Csharp :: unity object follow mouse 
Csharp :: unity time.deltatime timescale 0 
Csharp :: pass parameter to thread c# 
Csharp :: on collision 2d unity 
Csharp :: unity list of gameobjects 
Csharp :: minheap c# 
Csharp :: remove end character of string c# 
Csharp :: bower azure repository tag 
Csharp :: unity input.getkeyup not working 
Csharp :: double tryparse dot comma 
Csharp :: unity 3d sound 
Csharp :: unity animator current state name 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =