unity 脚本中如何获得另外物体的数据
1、打开unity3d选择菜单中的“GameObject”--“3D Object”。

3、接着我们创建两个脚本,一个Cube_data、一个Sphere_data。


6、在Cube_data脚本的start中通过GameObject.Find获得并输出烂瘀佐栾这个sphere_aa变量的数值(同样方式我们也可以获得其它组件属性)。void Start () { int aa =GameObject.Find("Sphere").GetComponent<Sphere_data>().sphere_aa; print(""+aa); }
