Skip to content

Commit 01878e7

Browse files
sohailshafiiWkfacebook-github-bot
authored andcommitted
fix(Runtime): Address edge case where GetNumberOfTransformsRetargeted is called too early
Summary: If `GetNumberOfTransformsRetargeted` is called too early, then `TargetSkeletonData` might be `null` or `TargetSkeletonData.BodyToBoneData` might be `null`. An example edge case would be: 1. Application starts up while scripts are initializing. 2. A permissions check appears. The application pauses and `AnimationRigSetup` calls `DisableRigAndUpdateState` via `OnApplicationFocus` when `hasFocus` is false. 3. `DisableRigAndUpdateState` calls `_retargetingLayer.GetNumberOfTransformsRetargeted()`, and `_retargetingLayer` metadata might not be ready at that point. Reviewed By: andkim-meta Differential Revision: D46335611 fbshipit-source-id: 6f60a3bb9134a227cddcfe99730abedf9aa3b307
1 parent 85827ba commit 01878e7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Runtime/Scripts/AnimationRigging/RetargetingLayer.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ public bool EnableTrackingByProxy
175175
public int GetNumberOfTransformsRetargeted()
176176
{
177177
int numTransforms = 0;
178+
// return default case if this is called before initialization.
179+
if (TargetSkeletonData == null || TargetSkeletonData.BodyToBoneData == null)
180+
{
181+
return numTransforms;
182+
}
178183
foreach (var boneData in TargetSkeletonData.BodyToBoneData.Values)
179184
{
180185
if (boneData.CorrectionQuaternion != null)

0 commit comments

Comments
 (0)