1using UnityEngine;
2using System.Collections;
3// This returns the GameObject named Hand in one of the Scenes.
4public class ExampleClass : MonoBehaviour
5{
6 public GameObject hand;
7
8 void Example()
9 {
10 // This returns the GameObject named Hand.
11 hand = GameObject.Find("Hand");
12
13 // This returns the GameObject named Hand.
14 // Hand must not have a parent in the Hierarchy view.
15 hand = GameObject.Find("/Hand");
16
17 // This returns the GameObject named Hand,
18 // which is a child of Arm > Monster.
19 // Monster must not have a parent in the Hierarchy view.
20 hand = GameObject.Find("/Monster/Arm/Hand");
21
22 // This returns the GameObject named Hand,
23 // which is a child of Arm > Monster.
24 hand = GameObject.Find("Monster/Arm/Hand");
25 }
26}
1using UnityEngine;
2using System.Collections;// This returns the GameObject named Hand in one of the Scenes.public class ExampleClass : MonoBehaviour
3{
4 public GameObject hand; void Example()
5 {
6 // This returns the GameObject named Hand.
7 hand = GameObject.Find("Hand"); // This returns the GameObject named Hand.
8 // Hand must not have a parent in the Hierarchy view.
9 hand = GameObject.Find("/Hand"); // This returns the GameObject named Hand,
10 // which is a child of Arm > Monster.
11 // Monster must not have a parent in the Hierarchy view.
12 hand = GameObject.Find("/Monster/Arm/Hand"); // This returns the GameObject named Hand,
13 // which is a child of Arm > Monster.
14 hand = GameObject.Find("Monster/Arm/Hand");
15 }
16}
17