Skip to content

Commit 1aabf73

Browse files
committed
Added coloring of stats text
* Becomes yellow after 130ms and red after 200ms
1 parent 4d863e5 commit 1aabf73

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Assets/BossRoom/Scripts/Shared/Net/NetworkStats.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public ExponentialMovingAverageCalculator(float average)
4242
const float k_PingIntervalSeconds = 0.1f;
4343
const float k_MaxWindowSize = k_MaxWindowSizeSeconds / k_PingIntervalSeconds;
4444

45+
const float k_StrugglingNetworkConditionsRTTThreshold = 130;
4546
const float k_BadNetworkConditionsRTTThreshold = 200;
4647

4748
ExponentialMovingAverageCalculator m_BossRoomRTT = new ExponentialMovingAverageCalculator(0);
@@ -129,6 +130,18 @@ void FixedUpdate()
129130
if (m_TextStat != null)
130131
{
131132
m_TextToDisplay = $"RTT: {(m_BossRoomRTT.Average * 1000).ToString("0")} ms;\nUTP RTT {m_UtpRTT.Average.ToString("0")} ms";
133+
if (m_UtpRTT.Average > k_BadNetworkConditionsRTTThreshold)
134+
{
135+
m_TextStat.color = Color.red;
136+
}
137+
else if (m_UtpRTT.Average > k_StrugglingNetworkConditionsRTTThreshold)
138+
{
139+
m_TextStat.color = Color.yellow;
140+
}
141+
else
142+
{
143+
m_TextStat.color = Color.white;
144+
}
132145
}
133146

134147
if (m_TextBadNetworkConditions != null)

0 commit comments

Comments
 (0)