diff --git a/NewHorizons/Utility/SearchUtilities.cs b/NewHorizons/Utility/SearchUtilities.cs index 4d032232..66a6e68b 100644 --- a/NewHorizons/Utility/SearchUtilities.cs +++ b/NewHorizons/Utility/SearchUtilities.cs @@ -100,9 +100,10 @@ namespace NewHorizons.Utility public static GameObject Find(string path) { var go = GameObject.Find(path); - if(go == null) + + var names = path.Split(new char[] { '\\', '/' }); + if (go == null) { - var names = path.Split(new char[] { '\\', '/' }); // Get the root object and hope its the right one var root = GameObject.Find(names[0]); @@ -143,6 +144,13 @@ namespace NewHorizons.Utility go = t.gameObject; } + if(go == null) + { + var name = names.Last(); + Logger.LogWarning($"Couldn't find object {path}, will look for potential matches for name {name}"); + go = FindObjectOfTypeAndName(name); + } + return go; } }