物体组件
物体组件
添加组件
GameObject.AddComponent<Rigidbody>();
查找组件
GameObject.GetComponent<SphereCollider>().radius = 1;
查找多个类型的组件
SphereCollider[] sphereColliders= GameObject.GetComponents<SphereCollider>();
删除组件
SphereCollider sphereCollider = GameObject.GetComponent<SphereCollider>(); Destroy(sphereCollider);
关闭和激活组件
GameObject.GetComponent<SphereCollider>().enabled=false; GameObject.GetComponent<SphereCollider>().enabled=true;