找回密碼
 注冊帳號

掃一掃,訪問微社區

component.getcomponentsinchildren 獲取子物體組件列表

2015-1-5 05:17| 發布者: 楊炎| 查看: 2988| 評論: 0|原作者: 蠻牛|來自: unity3d腳本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;

}

相關閱讀

文章點評
相關文章
女校游泳队彩金