mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-31 10:42:53 +08:00
fix: NREs when MenuItemGUI is used outside of an avatar
This commit is contained in:
parent
a71af7ae0a
commit
0723a33017
@ -646,6 +646,13 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
var myMenuItem = serializedObject.targetObject as ModularAvatarMenuItem;
|
var myMenuItem = serializedObject.targetObject as ModularAvatarMenuItem;
|
||||||
if (myMenuItem == null) return null;
|
if (myMenuItem == null) return null;
|
||||||
|
|
||||||
|
var avatarRoot = RuntimeUtil.FindAvatarInParents(myMenuItem.gameObject.transform);
|
||||||
|
|
||||||
|
if (avatarRoot == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var myParameterName = myMenuItem.Control.parameter.name;
|
var myParameterName = myMenuItem.Control.parameter.name;
|
||||||
if (string.IsNullOrEmpty(myParameterName)) return new List<ModularAvatarMenuItem>();
|
if (string.IsNullOrEmpty(myParameterName)) return new List<ModularAvatarMenuItem>();
|
||||||
|
|
||||||
@ -653,7 +660,6 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
if (myMappings.TryGetValue((ParameterNamespace.Animator, myParameterName), out var myReplacement))
|
if (myMappings.TryGetValue((ParameterNamespace.Animator, myParameterName), out var myReplacement))
|
||||||
myParameterName = myReplacement.ParameterName;
|
myParameterName = myReplacement.ParameterName;
|
||||||
|
|
||||||
var avatarRoot = RuntimeUtil.FindAvatarInParents(myMenuItem.gameObject.transform);
|
|
||||||
var siblings = new List<ModularAvatarMenuItem>();
|
var siblings = new List<ModularAvatarMenuItem>();
|
||||||
|
|
||||||
foreach (var otherMenuItem in avatarRoot.GetComponentsInChildren<ModularAvatarMenuItem>(true))
|
foreach (var otherMenuItem in avatarRoot.GetComponentsInChildren<ModularAvatarMenuItem>(true))
|
||||||
|
Loading…
Reference in New Issue
Block a user