Skip to content

Commit

Permalink
Merge pull request #1350 from anatawa12/nre-with-partial-animation-clips
Browse files Browse the repository at this point in the history
fix: NRE if some layer is missing from VRCAvatarDescriptor
  • Loading branch information
anatawa12 authored Nov 27, 2024
2 parents 25a44c7 + ea57498 commit e725c8f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-PRERELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
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 e725c8f

Please sign in to comment.