diff --git a/CHANGELOG-PRERELEASE.md b/CHANGELOG-PRERELEASE.md index 11466de6..f25e8c8d 100644 --- a/CHANGELOG-PRERELEASE.md +++ b/CHANGELOG-PRERELEASE.md @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog]. ### Fixed - Errors with models with UV at very edge `#1363` +- Errors if exactly same AnimatorController is specified for multiple playable layers `#1366` ### Security diff --git a/CHANGELOG.md b/CHANGELOG.md index 722090f0..5e4f947f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog]. ### Fixed - Errors with models with UV at very edge `#1363` +- Errors if exactly same AnimatorController is specified for multiple playable layers `#1366` ### Security diff --git a/Editor/Processors/InitializeAnimatorOptimizer.cs b/Editor/Processors/InitializeAnimatorOptimizer.cs index 08aa0b05..3f4ffc55 100644 --- a/Editor/Processors/InitializeAnimatorOptimizer.cs +++ b/Editor/Processors/InitializeAnimatorOptimizer.cs @@ -46,14 +46,14 @@ protected override void Execute(BuildContext context, TraceAndOptimizeState stat switch (component) { case Animator animator: - animator.runtimeAnimatorController = ProcessController(animator.runtimeAnimatorController, component.gameObject); + ProcessController(animator.runtimeAnimatorController, component.gameObject); break; #if AAO_VRCSDK3_AVATARS case VRCAvatarDescriptor avatarDescriptor: foreach (ref var layer in avatarDescriptor.baseAnimationLayers.AsSpan()) - layer.animatorController = ProcessController(layer.animatorController, component.gameObject); + ProcessController(layer.animatorController, component.gameObject); foreach (ref var layer in avatarDescriptor.specialAnimationLayers.AsSpan()) - layer.animatorController = ProcessController(layer.animatorController, component.gameObject); + ProcessController(layer.animatorController, component.gameObject); #endif break; // do not run animator optimizer with unknown components @@ -62,14 +62,14 @@ protected override void Execute(BuildContext context, TraceAndOptimizeState stat } } - AnimatorController? ProcessController(RuntimeAnimatorController? runtimeController, + void ProcessController(RuntimeAnimatorController? runtimeController, GameObject rootGameObject) { - if (runtimeController == null) return null; + if (runtimeController == null) return; var cloned = (AnimatorController)runtimeController; var wrapper = new AOAnimatorController(cloned, rootGameObject); animatorState.Add(wrapper); - clonedToController.Add(cloned, wrapper); + if (!clonedToController.TryAdd(cloned, wrapper)) return; #if AAO_VRCSDK3_AVATARS foreach (var behaviour in ACUtils.StateMachineBehaviours(cloned)) @@ -83,7 +83,6 @@ protected override void Execute(BuildContext context, TraceAndOptimizeState stat } } #endif - return cloned; } #if AAO_VRCSDK3_AVATARS