Horje
unity create a child object Code Example
how to reference a child object unity
    private void Start()
    {
        parentObject = GameObject.Find("Parent");// The name of the parent object
        childObject = parentObject.transform.GetChild(0).gameObject; // the parent index (starting from 0)
    }
unity create a child object
		// spawns object
        objToSpawn = new GameObject("Start");

        // add Components
        objToSpawn.AddComponent<Rigidbody>();
        objToSpawn.AddComponent<MeshFilter>();
        objToSpawn.AddComponent<BoxCollider>();
        objToSpawn.AddComponent<MeshRenderer>();

        // sets the obj's parent to the obj that the script is applied to
        objToSpawn.transform.SetParent(this.transform);
how to reference a child gameobject unity
Transform[] transforms = this.GetComponentsInChildren<Transform>();
 
 foreach(Transform t in transforms)
 {
     if (t.gameObject.name == "Child")
     {
         Debug.Log ("Found " + t);
     }
 }




Csharp

Related
how to clone somthing unity Code Example how to clone somthing unity Code Example
c# check if string is only letters and numbers Code Example c# check if string is only letters and numbers Code Example
how to convert nullable datetime datarow to datetime in c# Code Example how to convert nullable datetime datarow to datetime in c# Code Example
how to get object to spawn in a curcle Code Example how to get object to spawn in a curcle Code Example
bit in sql server c# Code Example bit in sql server c# Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9