Slow EventRefDrawer inspector performance

We’re on FMOD 2.02.19 and our game has almost 6000 events. EventReferenceDrawers in the inspector are sluggish even when there’s only 5-10 of them, and the editor turns into a slideshow when there’s 15+.

After profiling I found EventReferenceDrawer.GetEditorEventRef() calls EventManager.EventFromString() which takes a very long time to do string comparisons, about 250k of them when EventReferenceDrawer.OnGUI() is called 50 times a frame.

I sorted EditorEvents and used List.BinarySearch() which immediately fixed editor performance. Please add a fix similar to this that doesn’t use linear search, thank you!

        private static EditorEventRef s_TempEditorEventRef = null;
        private static IComparer<EditorEventRef> s_EditorEventsComparer = Comparer<EditorEventRef>.Create((a, b) => string.Compare(a.Path, b.Path, StringComparison.CurrentCultureIgnoreCase));
        public static EditorEventRef EventFromString(string path)
        {
            AffirmEventCache();
            
            if (s_TempEditorEventRef == null)
            {
                s_TempEditorEventRef = ScriptableObject.CreateInstance<EditorEventRef>();
                eventCache.EditorEvents.Sort((a, b) => string.Compare(a.Path, b.Path, StringComparison.CurrentCultureIgnoreCase));
            }

            s_TempEditorEventRef.Path = path;
            int index = eventCache.EditorEvents.BinarySearch(s_TempEditorEventRef, s_EditorEventsComparer);
            if (index < 0)
            {
                return null;
            }

            return eventCache.EditorEvents[index];
        }

Thanks for your feedback!

I have added a task to our tracker to investigate the best way to implement your suggestion.