Skip to content

Commit

Permalink
fix(PlayerObject): ensure player object check includes inactive objects
Browse files Browse the repository at this point in the history
The `IsPlayerObject` method now also checks inactive game objects when
seeing if any of the ancestors are a player object.
  • Loading branch information
thestonefox committed Dec 16, 2016
1 parent f1b864f commit 452c037
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Assets/VRTK/Scripts/Internal/VRTK_PlayerObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ public static void SetPlayerObject(GameObject obj, ObjectTypes objType)
/// <returns>Returns true if the object is a player object with the optional given type.</returns>
public static bool IsPlayerObject(GameObject obj, ObjectTypes ofType = ObjectTypes.Null)
{
var playerObject = obj.GetComponentInParent<VRTK_PlayerObject>();
return (playerObject && (ofType == ObjectTypes.Null || (ofType == playerObject.objectType)));
foreach (var playerObject in obj.GetComponentsInParent<VRTK_PlayerObject>(true))
{
if (ofType == ObjectTypes.Null || ofType == playerObject.objectType)
{
return true;
}
}
return false;
}
}
}

0 comments on commit 452c037

Please sign in to comment.