diff --git a/CHANGELOG-PRERELEASE.md b/CHANGELOG-PRERELEASE.md index 404452fa..b8aa25af 100644 --- a/CHANGELOG-PRERELEASE.md +++ b/CHANGELOG-PRERELEASE.md @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog]. ### Removed ### Fixed +- NRE if some playabke layer is missing from AvatarDesciptor `#1350` ### Security diff --git a/CHANGELOG.md b/CHANGELOG.md index f459d7fe..926b0064 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -135,6 +135,7 @@ The format is based on [Keep a Changelog]. - Error if all components are on inactive GameObject `#1318` - Animation bindings for BoxCollider generated by VRCStation will be removed `#1331` - This might break the GogoLoco or other flying avatar that supports Quest / Android. +- NRE if some playabke layer is missing from AvatarDesciptor `#1350` ### Security diff --git a/Editor/AnimatorParserV2/AnimatorParser.cs b/Editor/AnimatorParserV2/AnimatorParser.cs index e816020b..3aa841b6 100644 --- a/Editor/AnimatorParserV2/AnimatorParser.cs +++ b/Editor/AnimatorParserV2/AnimatorParser.cs @@ -216,6 +216,27 @@ private void CollectAvatarDescriptorModifications(RootPropModNodeContainer modif // load controllers var controllers = new AnimatorLayerMap(); + + // load default layers to not cause error + foreach (var layer in stackalloc[] + { + VRCAvatarDescriptor.AnimLayerType.Base, + VRCAvatarDescriptor.AnimLayerType.Additive, + VRCAvatarDescriptor.AnimLayerType.Gesture, + VRCAvatarDescriptor.AnimLayerType.Action, + VRCAvatarDescriptor.AnimLayerType.FX, + VRCAvatarDescriptor.AnimLayerType.Sitting, + VRCAvatarDescriptor.AnimLayerType.TPose, + VRCAvatarDescriptor.AnimLayerType.IKPose, + }) + { + ref var loader = ref DefaultLayers[layer]; + var controller = loader.Value; + if (controller == null) + throw new InvalidOperationException($"default controller for {layer} not found"); + controllers[layer] = controller; + } + foreach (var layer in descriptor.specialAnimationLayers.Concat(descriptor.baseAnimationLayers)) controllers[layer.type] = GetPlayableLayerController(layer, useDefaultLayers)!;