GameObject.GetComponents 获取组件列表

function GetComponents (type : Type) : Component[]

Description描述

Returns all components of Type type in the GameObject.

返回这个游戏物体上的所有类型为type的组件。

// Disable the spring on all HingeJoints 
// in this game object
// 使这个游戏物体上的所有HingeJoints上的spring不可用.

var hingeJoints : HingeJoint[];
hingeJoints = gameObject.GetComponents (HingeJoint);
for (var joint : HingeJoint in hingeJoints) {
	joint.useSpring = false;
}
最后修改:2010年12月13日 Monday 17:50

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。