From 129ad4dc356976dd2e9a581f78e5485de63895ea Mon Sep 17 00:00:00 2001 From: bd_ Date: Fri, 24 Jan 2025 18:12:24 -0800 Subject: [PATCH] fix: high load caused by ObjectReferenceFixer when paths collide Closes: #1411 --- Runtime/AvatarObjectReference.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Runtime/AvatarObjectReference.cs b/Runtime/AvatarObjectReference.cs index db3c88df..e5e07196 100644 --- a/Runtime/AvatarObjectReference.cs +++ b/Runtime/AvatarObjectReference.cs @@ -141,7 +141,14 @@ namespace nadena.dev.modular_avatar.core internal bool IsConsistent(GameObject avatarRoot) { if (referencePath == AVATAR_ROOT) return targetObject == avatarRoot; - return avatarRoot.transform.Find(referencePath)?.gameObject == targetObject; + if (avatarRoot.transform.Find(referencePath)?.gameObject == targetObject) + { + return true; + } + + // If multiple objects match the same path, then we accept that the reference is consistent. + var targetObjectPath = RuntimeUtil.AvatarRootPath(targetObject); + return targetObjectPath == referencePath; } protected bool Equals(AvatarObjectReference other)