You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.1 KiB

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace FX
{
// Token: 0x02000770 RID: 1904
public static class GetAllChildren
{
// Token: 0x0600306F RID: 12399 RVA: 0x00104638 File Offset: 0x00104638
public static List<GameObject> GetAll(this GameObject obj)
{
List<GameObject> result = new List<GameObject>();
GetAllChildren.GetChildren(obj, ref result);
return result;
}
// Token: 0x06003070 RID: 12400 RVA: 0x00104654 File Offset: 0x00104654
public static void GetChildren(GameObject obj, ref List<GameObject> allChildren)
{
Transform componentInChildren = obj.GetComponentInChildren<Transform>();
if (componentInChildren.childCount == 0)
{
return;
}
IEnumerator enumerator = componentInChildren.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
object obj2 = enumerator.Current;
Transform transform = (Transform)obj2;
allChildren.Add(transform.gameObject);
GetAllChildren.GetChildren(transform.gameObject, ref allChildren);
}
}
finally
{
IDisposable disposable;
if ((disposable = (enumerator as IDisposable)) != null)
{
disposable.Dispose();
}
}
}
// Token: 0x06003071 RID: 12401 RVA: 0x001046DC File Offset: 0x001046DC
public static void GetComponentsInChildren<T>(Transform trans, List<T> components) where T : class
{
for (int i = 0; i < trans.childCount; i++)
{
Transform child = trans.GetChild(i);
T component = child.GetComponent<T>();
if (component != null)
{
components.Add(component);
}
GetAllChildren.GetComponentsInChildren<T>(child, components);
}
}
// Token: 0x06003072 RID: 12402 RVA: 0x00104728 File Offset: 0x00104728
public static void MapComponentsInChildren<T>(Transform trans, Action<T> func) where T : class
{
for (int i = 0; i < trans.childCount; i++)
{
Transform child = trans.GetChild(i);
T component = child.GetComponent<T>();
if (component != null)
{
func(component);
}
GetAllChildren.MapComponentsInChildren<T>(child, func);
}
}
}
}