fix: exceptions thrown when examining a MenuItem outside of an avatar (#1030)

This commit is contained in:
bd_ 2024-08-21 20:28:52 -07:00 committed by GitHub
parent 8418f8e047
commit f44e070c46
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -123,11 +123,17 @@ namespace nadena.dev.modular_avatar.core.editor
return;
}
var parentAvatar = RuntimeUtil.FindAvatarInParents(paramRef.transform);
if (parentAvatar == null)
{
_parameterSourceNotDetermined = true;
return;
}
Dictionary<string, ProvidedParameter> rootParameters = new();
foreach (var param in ParameterInfo.ForUI.GetParametersForObject(
RuntimeUtil.FindAvatarInParents(paramRef.transform).gameObject
).Where(p => p.Namespace == ParameterNamespace.Animator)
foreach (var param in ParameterInfo.ForUI.GetParametersForObject(parentAvatar.gameObject)
.Where(p => p.Namespace == ParameterNamespace.Animator)
)
rootParameters[param.EffectiveName] = param;