Skip to content

Commit

Permalink
fix: resolve components for mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
MSchmoecker committed Apr 23, 2024
1 parent d16425f commit 72d054a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions JotunnLib/Managers/PrefabManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,19 @@ internal static bool TryFindAssetInSelfOrChildComponents(GameObject unityObject,
return false;
}

// search for the component on the object
if (objectType.IsSubclassOf(typeof(Component)))
{
var component = unityObject.GetComponent(objectType);

if (component)
{
asset = component;
return true;
}
}

// search for the asset inside a component
foreach (var component in unityObject.GetComponents<Component>())
{
if (!(component is Transform))
Expand All @@ -640,6 +653,7 @@ internal static bool TryFindAssetInSelfOrChildComponents(GameObject unityObject,
}
}

// recursively search in children
foreach (Transform tf in unityObject.transform)
{
if (TryFindAssetInSelfOrChildComponents(tf.gameObject, objectType, out asset))
Expand Down

0 comments on commit 72d054a

Please sign in to comment.