mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2024-12-29 02:35:06 +08:00
fix: Scale Adjusters outside an avatar throw exceptions (#822)
* fix: Scale Adjusters outside an avatar throw exceptions * fix: improve scale adjuster performance
This commit is contained in:
parent
8d64c63f49
commit
b25359a14a
@ -112,13 +112,15 @@ namespace nadena.dev.modular_avatar.core
|
||||
trueParent = trueParent.parent;
|
||||
}
|
||||
|
||||
// Clean up any additional parentage we might not want
|
||||
if (proxyChild.parent != null)
|
||||
{
|
||||
Transform parent = proxyChild.parent;
|
||||
|
||||
// Reparent to root
|
||||
proxyChild.SetParent(null, false);
|
||||
|
||||
// Destroy old hierarchy
|
||||
Transform parent = proxyChild.parent;
|
||||
while (parent.parent != null) parent = parent.parent;
|
||||
DestroyImmediate(parent.gameObject);
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ namespace nadena.dev.modular_avatar.core
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_adjusters.Contains(adjuster)) return;
|
||||
_adjusters = _adjusters.Add(adjuster);
|
||||
_dirty = true;
|
||||
}
|
||||
@ -121,7 +122,17 @@ namespace nadena.dev.modular_avatar.core
|
||||
_dirty = false;
|
||||
}
|
||||
|
||||
var avatarRoots = _capturedBones.Keys.Select(RuntimeUtil.FindAvatarTransformInParents).ToImmutableHashSet();
|
||||
var avatarRoots = _capturedBones.Keys.Select(bone =>
|
||||
{
|
||||
var root = RuntimeUtil.FindAvatarTransformInParents(bone);
|
||||
if (root == null)
|
||||
{
|
||||
root = bone;
|
||||
while (root.parent != null) root = root.parent;
|
||||
}
|
||||
|
||||
return root;
|
||||
}).ToImmutableHashSet();
|
||||
var potentialRenderers = avatarRoots.SelectMany(r => r.GetComponentsInChildren<SkinnedMeshRenderer>(true))
|
||||
.ToList();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user