|
1 | 1 | using System.Collections.Generic;
|
| 2 | +using TMPro; |
2 | 3 | using Unity.Netcode;
|
3 |
| -using Unity.Netcode.Transports.UNET; |
4 | 4 | using UnityEngine;
|
5 | 5 | using UnityEngine.Assertions;
|
6 |
| -using UnityEngine.UI; |
7 | 6 |
|
8 | 7 | namespace Unity.Multiplayer.Samples.BossRoom
|
9 | 8 | {
|
@@ -47,8 +46,8 @@ public ExponentialMovingAverageCalculator(float average)
|
47 | 46 | ExponentialMovingAverageCalculator m_UtpRTT = new ExponentialMovingAverageCalculator(0);
|
48 | 47 |
|
49 | 48 | float m_LastPingTime;
|
50 |
| - Text m_TextStat; |
51 |
| - Text m_TextHostType; |
| 49 | + TextMeshProUGUI m_TextStat; |
| 50 | + TextMeshProUGUI m_TextHostType; |
52 | 51 |
|
53 | 52 | // When receiving pong client RPCs, we need to know when the initiating ping sent it so we can calculate its individual RTT
|
54 | 53 | int m_CurrentRTTPingId;
|
@@ -85,16 +84,16 @@ void CreateNetworkStatsText()
|
85 | 84 | InitializeTextLine("No Stat", out m_TextStat);
|
86 | 85 | }
|
87 | 86 |
|
88 |
| - void InitializeTextLine(string defaultText, out Text textComponent) |
| 87 | + void InitializeTextLine(string defaultText, out TextMeshProUGUI textComponent) |
89 | 88 | {
|
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; |
92 | 92 | 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; |
96 | 95 | textComponent.raycastTarget = false;
|
97 |
| - textComponent.resizeTextForBestFit = true; |
| 96 | + textComponent.autoSizeTextContainer = true; |
98 | 97 |
|
99 | 98 | var rectTransform = rootGO.GetComponent<RectTransform>();
|
100 | 99 | Editor.NetworkOverlay.Instance.AddToUI(rectTransform);
|
|
0 commit comments