1.获得默认游戏物体:
在那个物体下创建Script脚本,this. 即是该游戏物体的组件
2.获得其他游戏物体:
public GameObject gameObject;然后把游戏物体拖入。
3.在某个位置实例化游戏物体
public GameObject gameObject;
GameObject.Instantiate(gameObject, transform.position, transform.rotation);
4.获得组件:
private Rigidbody rigidbody;(声明)
rigidbody = GetComponent<Rigidbody>();
private Button button;
button = transform.Find("__").GetComponent<Button>();