Fix some issues caused by nesting AvatarDescriptors (#110)

This commit is contained in:
bd_ 2022-11-29 09:58:12 -08:00 committed by GitHub
parent 072b5c1ff1
commit 9a38bd8620
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -121,6 +121,22 @@ namespace nadena.dev.modular_avatar.core.editor
try
{
// Sometimes people like to nest one avatar in another, when transplanting clothing. To avoid issues
// with inconsistently determining the avatar root, we'll go ahead and remove the extra sub-avatars
// here.
foreach (Transform directChild in avatarGameObject.transform)
{
foreach (var component in directChild.GetComponentsInChildren<VRCAvatarDescriptor>(true))
{
Object.DestroyImmediate(component);
}
foreach (var component in directChild.GetComponentsInChildren<PipelineSaver>(true))
{
Object.DestroyImmediate(component);
}
}
new RenameParametersHook().OnPreprocessAvatar(avatarGameObject);
new MenuInstallHook().OnPreprocessAvatar(avatarGameObject);
new MergeArmatureHook().OnPreprocessAvatar(avatarGameObject);

View File

@ -271,6 +271,11 @@ namespace nadena.dev.modular_avatar.core.editor
bool zipMerge
)
{
if (src == newParent)
{
throw new Exception("[ModularAvatar] Attempted to merge an armature into itself! Aborting build...");
}
GameObject mergedSrcBone = new GameObject(src.name + "@" + GUID.Generate());
mergedSrcBone.transform.SetParent(src.transform.parent);
mergedSrcBone.transform.localPosition = src.transform.localPosition;