Game Development Reference
In-Depth Information
Now, let's see how to cycle through all the child objects attached to a parent. Again,
this is achieved through the Transform component, as shown in the following code
sample 3-9:
using UnityEngine;
using System.Collections;
//------------------------------------------
public class CycleChildren : MonoBehaviour
{
//------------------------------------------
// Use this for initialization
void Start ()
{
//Cycle though children of this object
for(int i=0; i<transform.childCount; i++)
{
//Print name of child to console
Debug.Log (transform.GetChild(i).name);
}
}
//------------------------------------------
}
//------------------------------------------
The world, time, and updates
A Unity scene represents a collection of finite GameObjects inside the same 3D
space and that also share the same timeframe. Every game needs to establish a
unified concept of time to achieve synchronized animation and change, because
animation means change over time. In Unity, the Time class is available for reading
and understanding time and its passing in script. Working with this class is therefore
a critical skill for the creation of predictable and consistent motion in your games.
More on this shortly.
 
Search WWH ::




Custom Search