Skip to content

Commit f7f1043

Browse files
committed
fix(UI): 改进UI路径查找的错误信息并优化字符串比较
将模糊的"error path"异常信息替换为具体描述,明确指示索引越界、子对象未找到或非容器组件等具体问题。 优化字符串比较,使用StringComparison.OrdinalIgnoreCase进行不区分大小写的比较,避免创建临时字符串。 移除不必要的代码块,简化逻辑结构。
1 parent a214aee commit f7f1043

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

Runtime/FairyGUIPathFinderHelper.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ private static GObject SearchChild(GComponent o, Queue<string> q)
175175

176176
if (index < 0 || index >= o.numChildren)
177177
{
178-
throw new Exception("eror path");
178+
throw new Exception("Invalid UI path: index out of range");
179179
}
180180

181181
child = o.GetChildAt(index);
@@ -188,7 +188,7 @@ private static GObject SearchChild(GComponent o, Queue<string> q)
188188

189189
if (child == null)
190190
{
191-
throw new Exception("error path");
191+
throw new Exception("Invalid UI path: child not found");
192192
}
193193

194194
if (q.Count <= 0)
@@ -202,7 +202,7 @@ private static GObject SearchChild(GComponent o, Queue<string> q)
202202
return SearchChild(child as GComponent, q);
203203
}
204204

205-
throw new Exception("error path");
205+
throw new Exception("Invalid UI path: not a GComponent");
206206
}
207207

208208
/// <summary>
@@ -217,7 +217,7 @@ private static GObject SearchChild(GComponent o, Queue<string> q)
217217
[UnityEngine.Scripting.Preserve]
218218
public static bool SearchPathInclude(string path, GObject gObject)
219219
{
220-
if ("all".ToLower() == path)
220+
if (string.Equals(path, "all", StringComparison.OrdinalIgnoreCase))
221221
{
222222
return false;
223223
}
@@ -267,9 +267,7 @@ public static bool SearchPathInclude(string path, GObject gObject)
267267
continue;
268268
}
269269

270-
{
271-
return false;
272-
}
270+
return false;
273271
}
274272

275273
return false;

0 commit comments

Comments
 (0)