Skip to content

Commit

Permalink
use TryGetComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
ousttrue committed Jul 24, 2024
1 parent 6c929f6 commit ca0e062
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Assets/UniGLTF/Editor/UniGLTF/Validation/HumanoidValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ public static IEnumerable<Validation> Validate_TPose(GameObject ExportRoot)
//
Func<HumanBodyBones, Transform> getBoneTransform = null;

if (ExportRoot.GetComponent<UniHumanoid.Humanoid>() is UniHumanoid.Humanoid humanoid)
if (ExportRoot.TryGetComponent<UniHumanoid.Humanoid>(out var humanoid))
{
getBoneTransform = humanoid.GetBoneTransform;
}
else if (ExportRoot.GetComponent<Animator>() is Animator animator && animator != null)
else if (ExportRoot.TryGetComponent<Animator>(out var animator))
{
getBoneTransform = animator.GetBoneTransform;

Expand Down

0 comments on commit ca0e062

Please sign in to comment.