Skip to content

fix: RTT text too small #559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Assets/BossRoom/Prefabs/Debug Overlay Canvas.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 40, y: 40}
m_SizeDelta: {x: 200, y: 400}
m_SizeDelta: {x: 240, y: 400}
m_Pivot: {x: 0, y: 0}
--- !u!114 &3464894946384537378
MonoBehaviour:
Expand All @@ -157,8 +157,8 @@ MonoBehaviour:
m_Spacing: 0
m_ChildForceExpandWidth: 1
m_ChildForceExpandHeight: 0
m_ChildControlWidth: 0
m_ChildControlHeight: 0
m_ChildControlWidth: 1
m_ChildControlHeight: 1
m_ChildScaleWidth: 0
m_ChildScaleHeight: 0
m_ReverseArrangement: 0
21 changes: 10 additions & 11 deletions Assets/BossRoom/Scripts/Shared/Net/NetworkStats.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System.Collections.Generic;
using TMPro;
using Unity.Netcode;
using Unity.Netcode.Transports.UNET;
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.UI;

namespace Unity.Multiplayer.Samples.BossRoom
{
Expand Down Expand Up @@ -47,8 +46,8 @@ public ExponentialMovingAverageCalculator(float average)
ExponentialMovingAverageCalculator m_UtpRTT = new ExponentialMovingAverageCalculator(0);

float m_LastPingTime;
Text m_TextStat;
Text m_TextHostType;
TextMeshProUGUI m_TextStat;
TextMeshProUGUI m_TextHostType;

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

void InitializeTextLine(string defaultText, out Text textComponent)
void InitializeTextLine(string defaultText, out TextMeshProUGUI textComponent)
{
GameObject rootGO = new GameObject("UI Stat Text");
textComponent = rootGO.AddComponent<Text>();
var rootGO = new GameObject("UI Stat Text");
textComponent = rootGO.AddComponent<TextMeshProUGUI>();
textComponent.fontSize = 24;
textComponent.text = defaultText;
textComponent.font = Font.CreateDynamicFontFromOSFont("Arial", 24);
textComponent.horizontalOverflow = HorizontalWrapMode.Overflow;
textComponent.alignment = TextAnchor.MiddleLeft;
textComponent.horizontalAlignment = HorizontalAlignmentOptions.Left;
textComponent.verticalAlignment = VerticalAlignmentOptions.Middle;
textComponent.raycastTarget = false;
textComponent.resizeTextForBestFit = true;
textComponent.autoSizeTextContainer = true;

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