mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
25 lines
559 B
C#
25 lines
559 B
C#
|
using UnityEngine;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
public static class TransformExtensions
|
|||
|
{
|
|||
|
public static Transform FindDeepChild(this Transform parent, string childName)
|
|||
|
{
|
|||
|
Queue<Transform> queue = new Queue<Transform>();
|
|||
|
queue.Enqueue(parent);
|
|||
|
|
|||
|
while (queue.Count > 0)
|
|||
|
{
|
|||
|
var c = queue.Dequeue();
|
|||
|
if (c.name == childName)
|
|||
|
return c;
|
|||
|
foreach (Transform t in c)
|
|||
|
queue.Enqueue(t);
|
|||
|
}
|
|||
|
|
|||
|
return null;
|
|||
|
}
|
|||
|
}
|
|||
|
|