diff --git a/Assets/_ModularAvatar/EditModeTests/BoneProxyTest.cs b/Assets/_ModularAvatar/EditModeTests/BoneProxyTest.cs index 725dfe1a..02c31814 100644 --- a/Assets/_ModularAvatar/EditModeTests/BoneProxyTest.cs +++ b/Assets/_ModularAvatar/EditModeTests/BoneProxyTest.cs @@ -98,13 +98,16 @@ namespace modular_avatar_tests var boneProxy = proxy.AddComponent(); boneProxy.target = bone.transform; boneProxy.attachmentMode = attachmentMode; + // Prevent the bone from being optimized away + var proxyTransform = boneProxy.transform; + proxyTransform.gameObject.AddComponent(); bone.transform.localPosition = Vector3.one; bone.transform.localRotation = Quaternion.Euler(123, 45, 6); AvatarProcessor.ProcessAvatar(root); - Assert.AreEqual(proxy.transform.parent, bone.transform); + Assert.AreEqual(proxyTransform.parent, bone.transform); if (expectSnapPos) { diff --git a/Packages/nadena.dev.modular-avatar/Editor/BuildContext.cs b/Packages/nadena.dev.modular-avatar/Editor/BuildContext.cs index 19bd479c..ad3ff21e 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/BuildContext.cs +++ b/Packages/nadena.dev.modular-avatar/Editor/BuildContext.cs @@ -56,6 +56,8 @@ namespace nadena.dev.modular_avatar.core.editor public AnimatorController DeepCloneAnimator(RuntimeAnimatorController controller) { + if (controller == null) return null; + var merger = new AnimatorCombiner(this); switch (controller) { diff --git a/Packages/nadena.dev.modular-avatar/Editor/Menu/ActionProcessing/ActionGenerator.cs b/Packages/nadena.dev.modular-avatar/Editor/Menu/ActionProcessing/ActionGenerator.cs index 88b9d88d..94147a01 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/Menu/ActionProcessing/ActionGenerator.cs +++ b/Packages/nadena.dev.modular-avatar/Editor/Menu/ActionProcessing/ActionGenerator.cs @@ -31,6 +31,8 @@ namespace nadena.dev.modular_avatar.core.editor .Where(item => item != null) .ToImmutableHashSet(); + if (actionMenus.IsEmpty) return; + // Generate the root blendtree and animation; insert into the FX layer var animLayers = avatar.baseAnimationLayers; int fxLayerIndex = -1; @@ -89,7 +91,11 @@ namespace nadena.dev.modular_avatar.core.editor layerList.Insert(0, GenerateBlendshapeBaseLayer(avatar)); rootBlendTree.defaultWeight = 1; layerList.Insert(0, rootBlendTree); - layerList[1].defaultWeight = 1; + if (layerList.Count > 1) + { + layerList[1].defaultWeight = 1; + } + controller.layers = layerList.ToArray(); foreach (var action in avatar.GetComponentsInChildren(true)) @@ -211,7 +217,8 @@ namespace nadena.dev.modular_avatar.core.editor descriptor.expressionParameters = expParams; } - List expParameters = expParams.parameters.ToList(); + List expParameters = + expParams.parameters?.ToList() ?? new List(); List blendTrees = new List(); Dictionary> groupedItems =