Skip to content

Commit 96560de

Browse files
authored
Improved scene debugger search to reduce lag spike and improve performance in general (#1095)
1 parent d645176 commit 96560de

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

NitroxClient/Debuggers/SceneDebugger.cs

+6-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class SceneDebugger : BaseDebugger
2828
private bool sendToServer;
2929
private bool showUnityMethods;
3030
private bool showSystemMethods;
31-
private bool hitMode = false;
31+
private bool hitMode;
3232
private Vector2 gameObjectScrollPos;
3333

3434
/// <summary>
@@ -395,7 +395,7 @@ private void RenderTabHierarchy()
395395
else
396396
{
397397
// Searching. Return all gameobjects with matching type name.
398-
if (gameObjectSearch != gameObjectSearchCache)
398+
if (gameObjectSearch != gameObjectSearchCache && gameObjectSearch.Length > 2)
399399
{
400400
try
401401
{
@@ -412,7 +412,6 @@ private void RenderTabHierarchy()
412412
Type type = AppDomain.CurrentDomain.GetAssemblies()
413413
.Select(a => a.GetType(gameObjectSearch, false, true))
414414
.FirstOrDefault(t => t != null);
415-
gameObjectSearchResult = Resources.FindObjectsOfTypeAll<GameObject>().Where(go => Regex.IsMatch(go.name, gameObjectSearch)).OrderBy(go => go.name).ToList();
416415
if (type != null)
417416
{
418417
List<GameObject> gameObjects = Resources.FindObjectsOfTypeAll<GameObject>()
@@ -421,6 +420,10 @@ private void RenderTabHierarchy()
421420

422421
gameObjectSearchResult = gameObjects;
423422
}
423+
else
424+
{
425+
gameObjectSearchResult = Resources.FindObjectsOfTypeAll<GameObject>().Where(go => Regex.IsMatch(go.name, gameObjectSearch, RegexOptions.IgnoreCase)).OrderBy(go => go.name).ToList();
426+
}
424427
gameObjectSearchCache = gameObjectSearch;
425428
}
426429
else

0 commit comments

Comments
 (0)