fix: Replace Object dropping children (bdunderscore#547) (#575)

This commit is contained in:
konsti219 2023-12-25 06:53:39 -05:00 committed by GitHub
parent aa698565ab
commit e6ffd04110
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,8 +83,13 @@ namespace nadena.dev.modular_avatar.core.editor
replacement.transform.SetParent(original.transform.parent, true);
var siblingIndex = original.transform.GetSiblingIndex();
// Move children of original parent
// Move children of original parent (the List needs to be cloned first because it is being modified)
List<Transform> children = new List<Transform>();
foreach (Transform child in original.transform)
{
children.Add(child);
}
foreach (Transform child in children)
{
child.SetParent(replacement.transform, true);
}