From 973e7d2448f4ebccac0e0acfbbf7cfeb3a5dd9a4 Mon Sep 17 00:00:00 2001 From: bd_ Date: Sun, 3 Nov 2024 18:32:22 -0800 Subject: [PATCH] fix: suppress ObjectReferenceFixer in play mode (#1336) Not sure if this will do anything, but maybe it'll help with the perf issues people have reported? --- Editor/ObjectReferenceFixer.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Editor/ObjectReferenceFixer.cs b/Editor/ObjectReferenceFixer.cs index d87da97d..c0ddcf80 100644 --- a/Editor/ObjectReferenceFixer.cs +++ b/Editor/ObjectReferenceFixer.cs @@ -38,10 +38,23 @@ namespace nadena.dev.modular_avatar.core _context?.Invalidate?.Invoke(); } }; + EditorApplication.playModeStateChanged += state => + { + if (state == PlayModeStateChange.EnteredEditMode) + { + EditorApplication.delayCall += ProcessObjectReferences; + } + }; } private static void ProcessObjectReferences() { + if (EditorApplication.isPlayingOrWillChangePlaymode) + { + _context = null; + return; + } + _lastStage = GetCurrentContentsRootId(out var contentsRoot); AvatarObjectReference.InvalidateAll();