Skip to content

Commit e3857f2

Browse files
committed
Using TMP for NetworkLatencyWarning and increasing font size
1 parent 6b5f057 commit e3857f2

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

Assets/BossRoom/Scripts/Infrastructure/Editor/NetworkLatencyWarning.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using TMPro;
23
using UnityEngine;
34
using UnityEngine.UI;
45
using Unity.Netcode;
@@ -10,7 +11,7 @@ namespace Unity.Multiplayer.Samples.BossRoom.Editor
1011
{
1112
public class NetworkLatencyWarning : MonoBehaviour
1213
{
13-
Text m_LatencyText;
14+
TextMeshProUGUI m_LatencyText;
1415
bool m_LatencyTextCreated;
1516

1617
Color m_TextColor = Color.red;
@@ -68,12 +69,12 @@ void CreateLatencyText()
6869

6970
var statUI = new GameObject("UI Latency Warning Text");
7071

71-
m_LatencyText = statUI.AddComponent<Text>();
72-
m_LatencyText.font = Font.CreateDynamicFontFromOSFont("Arial", 24);
73-
m_LatencyText.horizontalOverflow = HorizontalWrapMode.Overflow;
74-
m_LatencyText.alignment = TextAnchor.MiddleLeft;
72+
m_LatencyText = statUI.AddComponent<TextMeshProUGUI>();
73+
m_LatencyText.fontSize = 32;
74+
m_LatencyText.horizontalAlignment = HorizontalAlignmentOptions.Left;
75+
m_LatencyText.verticalAlignment = VerticalAlignmentOptions.Middle;
7576
m_LatencyText.raycastTarget = false;
76-
m_LatencyText.resizeTextForBestFit = true;
77+
m_LatencyText.autoSizeTextContainer = true;
7778

7879
m_LatencyText.text = "Network Latency Enabled";
7980

Assets/BossRoom/Scripts/Infrastructure/NetworkStats.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void InitializeTextLine(string defaultText, out TextMeshProUGUI textComponent)
100100
{
101101
var rootGO = new GameObject("UI Stat Text");
102102
textComponent = rootGO.AddComponent<TextMeshProUGUI>();
103-
textComponent.fontSize = 24;
103+
textComponent.fontSize = 32;
104104
textComponent.text = defaultText;
105105
textComponent.horizontalAlignment = HorizontalAlignmentOptions.Left;
106106
textComponent.verticalAlignment = VerticalAlignmentOptions.Middle;

0 commit comments

Comments
 (0)