Skip to content

Commit

Permalink
fix: NRE if some layer is missing from VRCAvatarDescriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 committed Nov 27, 2024
1 parent 25a44c7 commit a995077
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Editor/AnimatorParserV2/AnimatorParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,27 @@ private void CollectAvatarDescriptorModifications(RootPropModNodeContainer modif

// load controllers
var controllers = new AnimatorLayerMap<RuntimeAnimatorController>();

// 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)!;

Expand Down

0 comments on commit a995077

Please sign in to comment.