Skip to content

Commit 0fec5f3

Browse files
committed
Added axis for graphs.
Goodbye message Compact fps history graph.
1 parent 24865c3 commit 0fec5f3

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

Assets/DebugOverlay/DebugOverlay.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ void _DrawGraph(float x, float y, float w, float h, float[] data, int startSampl
242242
old_pos_y = pos_y;
243243
}
244244
}
245+
AddLine(x, y + h, x + w, y + h, color[0]);
246+
AddLine(x, y, x, y + h, color[0]);
245247
}
246248

247249
void _DrawHist(float x, float y, float w, float h, float[] data, int startSample, Color[] color, int numSets, float maxRange = -1.0f)

Assets/Demo/Game.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public void Init()
3434

3535
m_Console = new Console();
3636
m_Console.Init(DebugOverlay.Width, DebugOverlay.Height);
37+
3738
m_Console.AddCommand("quit", CmdQuit, "Quit game");
3839

3940
m_Stats = new Stats();
@@ -58,6 +59,7 @@ public void Shutdown()
5859

5960
void CmdQuit(string[] args)
6061
{
62+
Game.console.Write("Goodbye\n");
6163
#if UNITY_EDITOR
6264
EditorApplication.isPlaying = false;
6365
#else

Assets/Demo/Stats.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ void CalcStatistics(float[] data, int count, out float mean, out float variance,
5252
}
5353

5454
static Color[] colors = new Color[] { Color.red, Color.green };
55+
float[] fpsHistory = new float[50];
5556
public void TickUpdate()
5657
{
5758
if (m_ShowStats < 1)
@@ -63,14 +64,17 @@ public void TickUpdate()
6364

6465
DebugOverlay.SetColor(Color.yellow);
6566
DebugOverlay.SetOrigin(0, 0);
66-
DebugOverlay.Write(0, 0, "FPS: {0,7:###.##}", 1.0f / Time.deltaTime);
67+
68+
DebugOverlay.Write(1, 0, "FPS:{0,6:###.##}", 1.0f / Time.deltaTime);
69+
fpsHistory[Time.frameCount % fpsHistory.Length] = 1.0f / Time.deltaTime;
70+
DebugOverlay.DrawGraph(1, 1, 9, 1.5f, fpsHistory, Time.frameCount % fpsHistory.Length, Color.green);
6771

6872
if (m_ShowStats < 2)
6973
return;
7074

71-
DebugOverlay.Write(0, 1, "Hello, {0,-5} world!", Time.frameCount % 100 < 50 ? "Happy" : "Evil");
72-
DebugOverlay.Write(0, 2, "FrameNo: {0,7}", Time.frameCount);
73-
DebugOverlay.Write(0, 3, "MonoHeap:{0,7} kb", (int)(UnityEngine.Profiling.Profiler.GetMonoUsedSizeLong() / 1024));
75+
DebugOverlay.Write(0, 4, "Hello, {0,-5} world!", Time.frameCount % 100 < 50 ? "Happy" : "Evil");
76+
DebugOverlay.Write(0, 5, "FrameNo: {0,7}", Time.frameCount);
77+
DebugOverlay.Write(0, 6, "MonoHeap:{0,7} kb", (int)(UnityEngine.Profiling.Profiler.GetMonoUsedSizeLong() / 1024));
7478

7579
/// Graphing difference between deltaTime and actual passed time
7680
float fps = Time.deltaTime * 1000.0f;

0 commit comments

Comments
 (0)