fix: potential null ref exceptions from scale adjuster (#767)

This commit is contained in:
bd_ 2024-03-10 19:20:34 -07:00 committed by GitHub
parent a801f0ee76
commit 3f50da35f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View File

@ -54,6 +54,12 @@ namespace nadena.dev.modular_avatar.core
internal void PreCull()
{
if (this == null)
{
EditorApplication.delayCall += () => ProxyManager.UnregisterAdjuster(this);
return;
}
if (PrefabUtility.IsPartOfPrefabAsset(this)) return;
if (scaleProxyChild == null || initialized == false)

View File

@ -102,9 +102,13 @@ namespace nadena.dev.modular_avatar.core
// Give each adjuster a chance to initialize the bone mappings first
foreach (var adj in _capturedAdjusters)
{
if (adj == null)
{
_capturedAdjusters = _adjusters = _adjusters.Remove(adj);
}
adj.PreCull();
}
foreach (var kvp in _originalToReplacementBone)
{
if (kvp.Key == null || kvp.Value == null)
@ -255,6 +259,10 @@ namespace nadena.dev.modular_avatar.core
foreach (var adj in _capturedAdjusters)
{
if (adj == null)
{
_capturedAdjusters = _capturedAdjusters.Remove(adj);
}
adj.PreCull(); // update scale
}