Skip to content

Instantly share code, notes, and snippets.

@is8r
Last active August 29, 2015 14:27
Show Gist options
  • Save is8r/97ad1aa63ad0a3e644e0 to your computer and use it in GitHub Desktop.
Save is8r/97ad1aa63ad0a3e644e0 to your computer and use it in GitHub Desktop.
GameObject obj = GameObject.Find("Environments") as GameObject;
GameObject obj = GameObject.Find("Environments/Directional Light") as GameObject;
GameObject[] objs = GameObject.FindGameObjectsWithTag("Actor");
foreach(GameObject obj in objs)
{
print ("FindGameObjectsWithTag: " + obj);
}
Dammy dammy = FindObjectOfType(typeof(Dammy)) as Dammy;
Dammy[] dammys = FindObjectsOfType(typeof(Dammy)) as Dammy[];
foreach(Dammy dammy in dammys)
{
print ("dammy: " + dammy);
}
GameObject obj = GameObject.FindWithTag("Actor") as GameObject;
for(int i = 0; i < transform.childCount; i++){
GameObject obj = transform.GetChild (i).gameObject;
}
foreach(Transform t in transform){
GameObject obj = t.gameObject;
}
Dammy dammy = gameObject.GetComponent<Dammy> () as Dammy;
Dammy dammy = gameObject.GetComponentInChildren<Dammy> () as Dammy;
GameObject obj = transform.parent.gameObject;
GameObject obj = this.gameObject;
GameObject obj = transform.gameObject;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment