mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-22 13:48:47 +00:00
fix: fix issue with GetComponentsInChildrenOnly checking wrong Transform
This commit is contained in:
parent
0b5bb074c8
commit
a8ebe9c902
@ -15,6 +15,7 @@ public static class GameObjectExtensions
|
|||||||
/// <returns>An array <typeparamref name="T" /> representing the child components.</returns>
|
/// <returns>An array <typeparamref name="T" /> representing the child components.</returns>
|
||||||
public static T[] GetComponentsInChildrenOnly<T>(this GameObject gameObject)
|
public static T[] GetComponentsInChildrenOnly<T>(this GameObject gameObject)
|
||||||
{
|
{
|
||||||
|
Transform rootTransform = gameObject.transform;
|
||||||
var components = new List<T>(gameObject.GetComponentsInChildren<T>());
|
var components = new List<T>(gameObject.GetComponentsInChildren<T>());
|
||||||
|
|
||||||
for (var index = 0; index < components.Count; index++)
|
for (var index = 0; index < components.Count; index++)
|
||||||
@ -26,7 +27,7 @@ public static class GameObjectExtensions
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (childComponent.transform.parent != gameObject.transform)
|
if (childComponent.transform == rootTransform)
|
||||||
{
|
{
|
||||||
components.RemoveAt(index);
|
components.RemoveAt(index);
|
||||||
index--;
|
index--;
|
||||||
|
Loading…
Reference in New Issue
Block a user