From 5afdbd94c37fc679e617e620cf1502c1ef5b1528 Mon Sep 17 00:00:00 2001 From: "Nick J. Connors" Date: Fri, 11 Feb 2022 00:38:35 -0500 Subject: [PATCH] Fix SearchUtilities find method --- NewHorizons/Utility/SearchUtilities.cs | 37 +++++++++++++------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/NewHorizons/Utility/SearchUtilities.cs b/NewHorizons/Utility/SearchUtilities.cs index f9422cb1..953fe211 100644 --- a/NewHorizons/Utility/SearchUtilities.cs +++ b/NewHorizons/Utility/SearchUtilities.cs @@ -115,33 +115,34 @@ namespace NewHorizons.Utility if (t == null) { Logger.LogWarning($"Couldn't find root object in path ({names[0]})"); - return null; } - - for (int i = 1; i < names.Length; i++) + else { - var child = t.transform.Find(names[i]); - - if (child == null) + for (int i = 1; i < names.Length; i++) { - foreach (Transform c in t.GetComponentsInChildren(true)) + var child = t.transform.Find(names[i]); + + if (child == null) { - if (t.name.Equals(names[i])) + foreach (Transform c in t.GetComponentsInChildren(true)) { - child = c; - break; + if (t.name.Equals(names[i])) + { + child = c; + break; + } } } - } - if (child == null) - { - Logger.LogWarning($"Couldn't find object in path ({names[i]})"); - t = null; - break; - } + if (child == null) + { + Logger.LogWarning($"Couldn't find object in path ({names[i]})"); + t = null; + break; + } - t = child; + t = child; + } } go = t?.gameObject;