fix: previewing Object Toggle targets Renderers other than MeshRender… (#1112)

* fix: NullReferenceException when previewing Object Toggle with renderers other than MeshRenderer and SkinnedMeshRenderer

* fix: NullReferenceException when previewing Scale Adjuster with renderers other than MeshRenderer and SkinnedMeshRenderer
This commit is contained in:
nekobako 2024-09-14 09:52:45 +09:00 committed by GitHub
parent 2735adf55c
commit 106ba8c5ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -42,6 +42,9 @@ namespace nadena.dev.modular_avatar.core.editor
foreach (var renderer in renderers)
{
// For now, the preview system only supports MeshRenderer and SkinnedMeshRenderer
if (renderer is not MeshRenderer and not SkinnedMeshRenderer) continue;
bool currentlyEnabled = context.ActiveInHierarchy(renderer.gameObject);
bool overrideEnabled = true;

View File

@ -75,7 +75,13 @@ namespace nadena.dev.modular_avatar.core.editor
renderers = new HashSet<Renderer>(new ObjectIdentityComparer<Renderer>());
avatarToRenderer.Add(root, renderers);
foreach (var renderer in root.GetComponentsInChildren<Renderer>()) 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);
}
}
}