From 8e49df703f79433177976c95aa6d21350b07f6c9 Mon Sep 17 00:00:00 2001 From: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com> Date: Tue, 24 Sep 2024 11:14:26 +0900 Subject: [PATCH] fix: BoneProxy target couldn't be empty after assigned (#1192) --- Editor/Inspector/BoneProxyEditor.cs | 4 ++-- Runtime/ModularAvatarBoneProxy.cs | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Editor/Inspector/BoneProxyEditor.cs b/Editor/Inspector/BoneProxyEditor.cs index f9d3ec6d..22566984 100644 --- a/Editor/Inspector/BoneProxyEditor.cs +++ b/Editor/Inspector/BoneProxyEditor.cs @@ -95,7 +95,7 @@ namespace nadena.dev.modular_avatar.core.editor var t = (ModularAvatarBoneProxy) targets[i]; Undo.RecordObjects(targets, "Set targets"); var xform = ((TempObjRef) objRefs[i]).target; - if (RuntimeUtil.FindAvatarTransformInParents(xform)?.gameObject != parentAvatar) continue; + if (xform != null && RuntimeUtil.FindAvatarTransformInParents(xform)?.gameObject != parentAvatar) continue; t.target = xform; } } @@ -159,4 +159,4 @@ namespace nadena.dev.modular_avatar.core.editor } } } -} \ No newline at end of file +} diff --git a/Runtime/ModularAvatarBoneProxy.cs b/Runtime/ModularAvatarBoneProxy.cs index 35f0cd7d..38957bdc 100644 --- a/Runtime/ModularAvatarBoneProxy.cs +++ b/Runtime/ModularAvatarBoneProxy.cs @@ -205,6 +205,13 @@ namespace nadena.dev.modular_avatar.core Transform iter = newTarget; + if (newTarget == null) + { + boneReference = HumanBodyBones.LastBone; + subPath = null; + return; + } + if (newTarget == avatarTransform) { boneReference = HumanBodyBones.LastBone; @@ -230,4 +237,4 @@ namespace nadena.dev.modular_avatar.core _targetCache = newTarget; } } -} \ No newline at end of file +}