From fdc497399a5287483cf1ac5f5aeae594be38f5e9 Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Mon, 17 May 2021 18:12:48 -0400 Subject: [PATCH] fix NRE if tracked poses is null in BaseHandControllerDataProvider.cs --- .../Hands/BaseHandControllerDataProviderProfile.cs | 4 ++-- .../Controllers/Hands/BaseHandControllerDataProvider.cs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Runtime/Definitions/Controllers/Hands/BaseHandControllerDataProviderProfile.cs b/Runtime/Definitions/Controllers/Hands/BaseHandControllerDataProviderProfile.cs index e22ea9fc9..33dfd2cba 100644 --- a/Runtime/Definitions/Controllers/Hands/BaseHandControllerDataProviderProfile.cs +++ b/Runtime/Definitions/Controllers/Hands/BaseHandControllerDataProviderProfile.cs @@ -61,7 +61,7 @@ public abstract class BaseHandControllerDataProviderProfile : BaseMixedRealityCo [SerializeField] [Tooltip("Tracked hand poses for pose detection.")] - private HandControllerPoseProfile[] trackedPoses = null; + private HandControllerPoseProfile[] trackedPoses = new HandControllerPoseProfile[0]; /// /// Tracked hand poses for pose detection. @@ -77,4 +77,4 @@ public override ControllerDefinition[] GetDefaultControllerOptions() }; } } -} \ No newline at end of file +} diff --git a/Runtime/Providers/Controllers/Hands/BaseHandControllerDataProvider.cs b/Runtime/Providers/Controllers/Hands/BaseHandControllerDataProvider.cs index 4969756bb..0cda75694 100644 --- a/Runtime/Providers/Controllers/Hands/BaseHandControllerDataProvider.cs +++ b/Runtime/Providers/Controllers/Hands/BaseHandControllerDataProvider.cs @@ -41,7 +41,8 @@ protected BaseHandControllerDataProvider(string name, uint priority, BaseHandCon ? profile.BoundsMode : inputSystemProfile.BoundsMode; - if (profile.TrackedPoses.Count > 0) + if (profile.TrackedPoses != null && + profile.TrackedPoses.Count > 0) { TrackedPoses = profile.TrackedPoses.Count != inputSystemProfile.TrackedPoses.Count ? profile.TrackedPoses @@ -70,4 +71,4 @@ protected BaseHandControllerDataProvider(string name, uint priority, BaseHandCon /// protected IReadOnlyList TrackedPoses { get; } } -} \ No newline at end of file +}