diff --git a/LuaProfiler/example/Assets/LuaProfiler/Editor/Window/ProfilerWin/TreeView/LuaProfilerTreeView.cs b/LuaProfiler/example/Assets/LuaProfiler/Editor/Window/ProfilerWin/TreeView/LuaProfilerTreeView.cs index efd3a082..39a178a6 100644 --- a/LuaProfiler/example/Assets/LuaProfiler/Editor/Window/ProfilerWin/TreeView/LuaProfilerTreeView.cs +++ b/LuaProfiler/example/Assets/LuaProfiler/Editor/Window/ProfilerWin/TreeView/LuaProfilerTreeView.cs @@ -911,6 +911,7 @@ public void LoadRootSample(Sample sample) public int GetNextFrame(int start, bool isChange) { + start = Math.Max(1, Math.Min(start, history.Count - 1)); int ret = start; int frameCount = history[start].frameCount; for (int i = start + 1, imax = history.Count; i < imax; i++) @@ -930,6 +931,9 @@ public int GetNextFrame(int start, bool isChange) public int GetPreFrame(int start, bool isChange) { + if (history.Count <= 0) return 0; + + start = Math.Max(1, Math.Min(start, history.Count - 1)); int ret = start; int frameCount = history[start].frameCount; for (int i = start - 1; i >= 0; i--) @@ -950,7 +954,10 @@ public int GetPreFrame(int start, bool isChange) public int GetNextProgramFrame(int start) { + if (history.Count <= 0) return 0; + start = Math.Max(1, Math.Min(start, history.Count - 1)); int ret = start + 1; + if (ret >= history.Count) return history.Count - 1; var setting = LuaDeepProfilerSetting.Instance; for (int i = start + 1, imax = history.Count; i < imax; i++)