component.getcomponentsinchildren 获取子物体组件列表

2015-1-5 05:17| 发布者: 杨炎| 查看: 2827| 评论: 0|原作者: 蛮牛|来自: yzc88亚洲城脚本manual

摘要: component.getcomponentsinchildren 获取子物体组件列表functiongetcomponentsinchildren(t: type,includeinactive: bool = false) : componentdescription描述returns all components of type type in thegameobjec ...

component.getcomponentsinchildren 获取子物体组件列表

functiongetcomponentsinchildren(t: type,includeinactive: bool = false) : component[]

description描述

returns all components of type type in theobject" target="_blank" class="relatedlink">gameobjector any of its children.

在gameobject或任何它的子物体,返回全部type类型组件

for c# there is a generic version available.

对于c#有一个通用的版本。

only active components are returned.

仅返回激活的组件。

c#

javascript

using unityengine;

using system.collections;

public class example :monobehaviour{

publichingejoint[] hingejoints;

public void awake() {

hingejoints = getcomponentsinchildren();

foreach (hingejoint joint in hingejoints) {

joint.usespring = false;

}

}

}

// disable the spring on all hingejoints

// in this game object and all its child game objects

//在这个游戏物体和它的全部子物体的全部铰链关节上禁用弹簧

var hingejoints :hingejoint[];

hingejoints = getcomponentsinchildren (hingejoint);

for (var joint : hingejoint in hingejoints) {

joint.usespring = false;

}

相关阅读

文章点评
相关文章