标签:als getc tag tco void str nts real []
` public static Transform FindObj(Transform transform, Func<Transform, bool> condition, bool isGrandsonObj = false)
{
Transform[] allChilds = transform.GetComponentsInRealChildren<Transform>(isGrandsonObj);
foreach (Transform child in allChilds)
{
if (condition(child))
{
return child;
}
}
return transform;
}
public static Transform FindObj(Transform transform, string tag, bool isGrandsonObj = false)
{
return FindObj(transform, (t) => t.tag.Equals(tag), isGrandsonObj);
}`
` public static List<Transform> FindObjs(Transform transform, Func<Transform, bool> condition, bool isGrandsonObj = false)
{
Transform[] allChilds = transform.GetComponentsInRealChildren<Transform>(isGrandsonObj);
List<Transform> list = new List<Transform>();
foreach (Transform child in allChilds)
{
if (condition(child))
{
list.Add(child);
}
}
return list;
}
public static List<Transform> FindObjs(Transform transform, string tag, bool isGrandsonObj = false)
{
return FindObjs(transform, (t) => t.tag.Equals(tag), isGrandsonObj);
}`
` public static void AddActionObjects(Transform[] transform, Func<Transform, bool> condition, Action<Transform> action)
{
foreach (Transform child in transform)
{
if (condition(child))
{
action(child);
}
}
}`
` public static void AddActionObjects(Transform[] transform, Action<Transform> action)
{
AddActionObjects(transform, (t) => true, action);
}
public static void AddActionObjects(Transform transform, Func<Transform, bool> condition, Action<Transform> action, bool isGrandsonObj = false)
{
Transform[] allChilds = transform.GetComponentsInChildren<Transform>(isGrandsonObj);
AddActionObjects(allChilds, condition, action);
}
public static void AddActionObjects(Transform transform, Action<Transform> action, bool isGrandsonObj = false)
{
AddActionObjects(transform, (t) => true, action, isGrandsonObj);
}
public static void AddActionObjects(Transform transform, string tag, Action<Transform> action, bool isGrandsonObj = false)
{
AddActionObjects(transform, (t) => t.tag.Equals(tag), action, isGrandsonObj);
}
`
标签:als getc tag tco void str nts real []
原文地址:https://www.cnblogs.com/programmingAdorableNew/p/10348234.html