mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2024-12-29 18:55:06 +08:00
fix: ScaleAdjusterPreview breaks when avatar descriptors are nested (#1154)
This commit is contained in:
parent
9073ff8c2d
commit
3648348184
@ -61,27 +61,27 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
var avatarToRenderer =
|
var avatarToRenderer =
|
||||||
new Dictionary<GameObject, HashSet<Renderer>>(new ObjectIdentityComparer<GameObject>());
|
new Dictionary<GameObject, HashSet<Renderer>>(new ObjectIdentityComparer<GameObject>());
|
||||||
|
|
||||||
foreach (var adjuster in scaleAdjusters)
|
foreach (var root in ctx.GetAvatarRoots())
|
||||||
{
|
{
|
||||||
if (adjuster == null) continue;
|
if (ctx.GetComponentsInChildren<ModularAvatarScaleAdjuster>(root, true).Length == 0)
|
||||||
|
|
||||||
// Find parent object
|
|
||||||
// TODO: Reactive helper
|
|
||||||
var root = FindAvatarRootObserving(ctx, adjuster.gameObject);
|
|
||||||
if (root == null) continue;
|
|
||||||
|
|
||||||
if (!avatarToRenderer.TryGetValue(root, out var renderers))
|
|
||||||
{
|
{
|
||||||
renderers = new HashSet<Renderer>(new ObjectIdentityComparer<Renderer>());
|
continue;
|
||||||
avatarToRenderer.Add(root, renderers);
|
}
|
||||||
|
|
||||||
foreach (var renderer in root.GetComponentsInChildren<Renderer>())
|
if (ctx.GetAvatarRoot(root?.transform?.parent?.gameObject) != null)
|
||||||
{
|
{
|
||||||
// For now, the preview system only supports MeshRenderer and SkinnedMeshRenderer
|
continue; // nested avatar descriptor
|
||||||
if (renderer is not MeshRenderer and not SkinnedMeshRenderer) continue;
|
}
|
||||||
|
|
||||||
|
var renderers = new HashSet<Renderer>(new ObjectIdentityComparer<Renderer>());
|
||||||
|
avatarToRenderer.Add(root, renderers);
|
||||||
|
|
||||||
renderers.Add(renderer);
|
foreach (var renderer in root.GetComponentsInChildren<Renderer>())
|
||||||
}
|
{
|
||||||
|
// For now, the preview system only supports MeshRenderer and SkinnedMeshRenderer
|
||||||
|
if (renderer is not MeshRenderer and not SkinnedMeshRenderer) continue;
|
||||||
|
|
||||||
|
renderers.Add(renderer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user