GetComponentsInChildren Not Work In OnDisable[Unity]

Just use GetComponentsInChildren<Type>(true).

Because the default found set not include the inactive components,and when OnDisable function called,all of the children are inactive.


link:Doc:http://docs.unity3d.com/ScriptReference/Component.GetComponentsInChildren.html

Component.GetComponentsInChildren


Component[] GetComponentsInChildren(Type t, bool includeInactive = false);


Parameters

t

The type of Component to retrieve.

includeInactive

Should inactive Components be included in the found set?



已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页