Skip to content

Commit 5356e3c

Browse files
type and rtt text is now TextMeshPro and sized properly (#559) (#561)
1 parent aecb4d4 commit 5356e3c

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

Assets/BossRoom/Prefabs/Debug Overlay Canvas.prefab

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ RectTransform:
134134
m_AnchorMin: {x: 0, y: 0}
135135
m_AnchorMax: {x: 0, y: 0}
136136
m_AnchoredPosition: {x: 40, y: 40}
137-
m_SizeDelta: {x: 200, y: 400}
137+
m_SizeDelta: {x: 240, y: 400}
138138
m_Pivot: {x: 0, y: 0}
139139
--- !u!114 &3464894946384537378
140140
MonoBehaviour:
@@ -157,8 +157,8 @@ MonoBehaviour:
157157
m_Spacing: 0
158158
m_ChildForceExpandWidth: 1
159159
m_ChildForceExpandHeight: 0
160-
m_ChildControlWidth: 0
161-
m_ChildControlHeight: 0
160+
m_ChildControlWidth: 1
161+
m_ChildControlHeight: 1
162162
m_ChildScaleWidth: 0
163163
m_ChildScaleHeight: 0
164164
m_ReverseArrangement: 0

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
using System.Collections.Generic;
2+
using TMPro;
23
using Unity.Netcode;
3-
using Unity.Netcode.Transports.UNET;
44
using UnityEngine;
55
using UnityEngine.Assertions;
6-
using UnityEngine.UI;
76

87
namespace Unity.Multiplayer.Samples.BossRoom
98
{
@@ -47,8 +46,8 @@ public ExponentialMovingAverageCalculator(float average)
4746
ExponentialMovingAverageCalculator m_UtpRTT = new ExponentialMovingAverageCalculator(0);
4847

4948
float m_LastPingTime;
50-
Text m_TextStat;
51-
Text m_TextHostType;
49+
TextMeshProUGUI m_TextStat;
50+
TextMeshProUGUI m_TextHostType;
5251

5352
// When receiving pong client RPCs, we need to know when the initiating ping sent it so we can calculate its individual RTT
5453
int m_CurrentRTTPingId;
@@ -85,16 +84,16 @@ void CreateNetworkStatsText()
8584
InitializeTextLine("No Stat", out m_TextStat);
8685
}
8786

88-
void InitializeTextLine(string defaultText, out Text textComponent)
87+
void InitializeTextLine(string defaultText, out TextMeshProUGUI textComponent)
8988
{
90-
GameObject rootGO = new GameObject("UI Stat Text");
91-
textComponent = rootGO.AddComponent<Text>();
89+
var rootGO = new GameObject("UI Stat Text");
90+
textComponent = rootGO.AddComponent<TextMeshProUGUI>();
91+
textComponent.fontSize = 24;
9292
textComponent.text = defaultText;
93-
textComponent.font = Font.CreateDynamicFontFromOSFont("Arial", 24);
94-
textComponent.horizontalOverflow = HorizontalWrapMode.Overflow;
95-
textComponent.alignment = TextAnchor.MiddleLeft;
93+
textComponent.horizontalAlignment = HorizontalAlignmentOptions.Left;
94+
textComponent.verticalAlignment = VerticalAlignmentOptions.Middle;
9695
textComponent.raycastTarget = false;
97-
textComponent.resizeTextForBestFit = true;
96+
textComponent.autoSizeTextContainer = true;
9897

9998
var rectTransform = rootGO.GetComponent<RectTransform>();
10099
Editor.NetworkOverlay.Instance.AddToUI(rectTransform);

0 commit comments

Comments
 (0)