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
This commit is contained in:
parent
2ea9fb50b6
commit
44bfec958c
@ -61,18 +61,19 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ctx.GetAvatarRoot(root?.transform?.parent?.gameObject) != null)
|
||||||
|
{
|
||||||
|
continue; // nested avatar descriptor
|
||||||
|
}
|
||||||
|
|
||||||
|
var renderers = new HashSet<Renderer>(new ObjectIdentityComparer<Renderer>());
|
||||||
avatarToRenderer.Add(root, renderers);
|
avatarToRenderer.Add(root, renderers);
|
||||||
|
|
||||||
foreach (var renderer in root.GetComponentsInChildren<Renderer>())
|
foreach (var renderer in root.GetComponentsInChildren<Renderer>())
|
||||||
@ -83,7 +84,6 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
renderers.Add(renderer);
|
renderers.Add(renderer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return avatarToRenderer.Select(kvp => RenderGroup.For(kvp.Value).WithData(kvp.Key)).ToImmutableList();
|
return avatarToRenderer.Select(kvp => RenderGroup.For(kvp.Value).WithData(kvp.Key)).ToImmutableList();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user