0
Fixed

SceneMouseNavigation.LateUpdate uses FindObjectsByType<TMP_InputField> every frame → catastrophic global scan on large scenes

Ramon Janousch vor 1 vor einem Tag in realvirtual.io Starter and Professional aktualisiert von Support vor 1 vor einem Tag 2

LateUpdate in SceneMouseNavigation calls CheckForFocusedFields which uses FindObjectsByType.

On large scenes, this per-frame global lookup produces unacceptable frame times.

FindObjectsByType should not be called every frame.

This is the profiler result with 4000 active and 400.000 inactive objects in the scene:

Image 1416


Same scene with an early return in CheckForFocusedFields.

Image 1417

Image 1418

Environment:

  • Unity 6000.2.10f1
  • realvirtual-Professional-6.2.1
  • Windows 10 x64
  • RAM 32 GB
  • CPU Intel Xeon W-11955M @2.6 GHz (8 Cores)
GUT, ICH BIN ZUFRIEDEN.

Thanks for the blazingly fast support. Well done :)

Zufriedenheit von Ramon Janousch gestern um 09:13
+1
Wird überprüft

Thanks for reporting - we are checking for a solution - maybe caching it and will let you know.

Fixed

Hi, thanks for reporting and finding the issue.  


Please relace the method by this:  


//! Check if any UI input field has focus - uses EventSystem for O(1) performance
private bool CheckForFocusedFields()
{
// Check if currently selected GameObject is a TMP_InputField (O(1) performance)
var selectedObject = EventSystem.current?.currentSelectedGameObject;
if (selectedObject != null)
{
var inputField = selectedObject.GetComponent();
if (inputField != null && inputField.isFocused)
return true;
}

// Check UI Toolkit focus controller
if (focusController != null && focusController.focusedElement is TextField)
return true;

return false;
}


We will inlclude this in the next update.