已修复递归寻找组件时只寻找所有第一个对象的问题

This commit is contained in:
2023-11-29 09:24:01 +08:00
parent 1fc8058640
commit 160aff025e
5 changed files with 501 additions and 5 deletions
+15 -5
View File
@@ -141,12 +141,22 @@ namespace XericLibrary.Runtime.MacroLibrary
{
int newRecursion = recursion - 1;
foreach(var item in trans.GetChildren())
//foreach(var item in trans.GetChildren())
//{
// var comp = item.GetComponent<T>();
// if(comp == null && newRecursion > 0)
// comp = item.GetComponentInRecursionChildren<T>(newRecursion);
// yield return comp;
//}
T[] comps;
foreach(var item in trans.GetChildrenRecursion(newRecursion))
{
var comp = item.GetComponent<T>();
if(comp == null && newRecursion > 0)
comp = item.GetComponentInRecursionChildren<T>(newRecursion);
yield return comp;
comps = item.GetComponents<T>();
if(comps != null
&& comps.Length > 0)
foreach (var comp in comps)
yield return comp;
}
}