static public T FindInParents<T>(GameObject go) where T : Component
{
if (go == null) return null;
var comp = go.GetComponent<T>();
if (comp != null)
return comp;
var t = go.transform.parent;
while (t != null && comp == null)
{
comp = t.gameObject.GetComponent<T>();
t = t.parent;
}
return comp;
}
Unity中 泛型查找 父物体上所有所要查找的Component 集合
猜你喜欢
转载自blog.csdn.net/zjw1349547081/article/details/80649087
今日推荐
周排行