diff --git a/X10D.Unity/src/GameObjectExtensions.cs b/X10D.Unity/src/GameObjectExtensions.cs
index 97d03d3..23d7f3c 100644
--- a/X10D.Unity/src/GameObjectExtensions.cs
+++ b/X10D.Unity/src/GameObjectExtensions.cs
@@ -15,6 +15,7 @@ public static class GameObjectExtensions
/// An array representing the child components.
public static T[] GetComponentsInChildrenOnly(this GameObject gameObject)
{
+ Transform rootTransform = gameObject.transform;
var components = new List(gameObject.GetComponentsInChildren());
for (var index = 0; index < components.Count; index++)
@@ -26,7 +27,7 @@ public static class GameObjectExtensions
continue;
}
- if (childComponent.transform.parent != gameObject.transform)
+ if (childComponent.transform == rootTransform)
{
components.RemoveAt(index);
index--;