From f92d10cf506c0e806dda3514bb24aa2cf6738b8a Mon Sep 17 00:00:00 2001 From: bd_ Date: Sat, 16 Mar 2024 20:50:41 +0900 Subject: [PATCH] fix: NullRefExceptions from inspectors (#789) * fix: NullReferenceError while deleting a GameObject with parameter usage UI open * fix: NullRefException from editor when moving a Menu Installer outside of an avatar --- Editor/Inspector/Menu/MenuInstallerEditor.cs | 2 +- Editor/ParamsUsage/ParamsUsageEditor.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Editor/Inspector/Menu/MenuInstallerEditor.cs b/Editor/Inspector/Menu/MenuInstallerEditor.cs index 4fabf8d9..5110aa36 100644 --- a/Editor/Inspector/Menu/MenuInstallerEditor.cs +++ b/Editor/Inspector/Menu/MenuInstallerEditor.cs @@ -178,7 +178,7 @@ namespace nadena.dev.modular_avatar.core.editor } } - if (InstallTargets.Count == 1 && (InstallTargets[0] is VRCExpressionsMenu || InstallTargets[0] == null)) + if (commonAvatar != null && InstallTargets.Count == 1 && (InstallTargets[0] is VRCExpressionsMenu || InstallTargets[0] == null)) { var displayValue = installTo.objectReferenceValue; if (displayValue == null) displayValue = commonAvatar.expressionsMenu; diff --git a/Editor/ParamsUsage/ParamsUsageEditor.cs b/Editor/ParamsUsage/ParamsUsageEditor.cs index 35ff3966..7f1649be 100644 --- a/Editor/ParamsUsage/ParamsUsageEditor.cs +++ b/Editor/ParamsUsage/ParamsUsageEditor.cs @@ -104,8 +104,10 @@ namespace nadena.dev.modular_avatar.core.editor var ctx = serializedObject.context as GameObject; + if (ctx == null) return; + var avatarRoot = RuntimeUtil.FindAvatarTransformInParents(ctx.transform)?.gameObject; - if (ctx == null || avatarRoot == null) return; + if (avatarRoot == null) return; var orderedPlugins = ParameterInfo.ForUI.GetParametersForObject(ctx) .GroupBy(p => p.Plugin)