Skip to content

Commit 148ad72

Browse files
committed
Added online player counter to matchmaking screen
1 parent 5324a78 commit 148ad72

4 files changed

Lines changed: 245 additions & 0 deletions
Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Nuutti <snuutti@protonmail.com>
3+
Date: Sat, 25 Apr 2026 16:45:06 +0300
4+
Subject: [PATCH] Add online player counter to matchmaking screen
5+
6+
7+
diff --git a/Assets/Scripts/Assembly-CSharp/EnteringMatchScreen.cs b/Assets/Scripts/Assembly-CSharp/EnteringMatchScreen.cs
8+
index 3a5019a2..c2c2b6be 100644
9+
--- a/Assets/Scripts/Assembly-CSharp/EnteringMatchScreen.cs
10+
+++ b/Assets/Scripts/Assembly-CSharp/EnteringMatchScreen.cs
11+
@@ -37,2 +37,4 @@ public class EnteringMatchScreen : MonoBehaviour
12+
13+
+ public TextMeshProUGUI OnlineText;
14+
+
15+
[Header("Background Elements")]
16+
@@ -85,2 +87,6 @@ public class EnteringMatchScreen : MonoBehaviour
17+
}
18+
+ if (OnlineText)
19+
+ {
20+
+ OnlineText.gameObject.SetActive(true);
21+
+ }
22+
}
23+
@@ -163,2 +169,6 @@ public class EnteringMatchScreen : MonoBehaviour
24+
}
25+
+ if (OnlineText.gameObject.activeSelf)
26+
+ {
27+
+ OnlineText.gameObject.SetActive(false);
28+
+ }
29+
}
30+
diff --git a/Assets/Scripts/Assembly-CSharp/OnlineCountText.cs b/Assets/Scripts/Assembly-CSharp/OnlineCountText.cs
31+
new file mode 100644
32+
index 00000000..30cec0d9
33+
--- /dev/null
34+
+++ b/Assets/Scripts/Assembly-CSharp/OnlineCountText.cs
35+
@@ -0,0 +1,37 @@
36+
+using System.Collections;
37+
+using Newtonsoft.Json;
38+
+using TMPro;
39+
+using UnityEngine;
40+
+using UnityEngine.Networking;
41+
+
42+
+public class OnlineCountText : MonoBehaviour
43+
+{
44+
+ private TMP_Text _text;
45+
+
46+
+ private void Start()
47+
+ {
48+
+ _text = GetComponent<TMP_Text>();
49+
+ _text.text = "Loading online count...";
50+
+ StartCoroutine(UpdateOnlineCount());
51+
+ }
52+
+
53+
+ private IEnumerator UpdateOnlineCount()
54+
+ {
55+
+ while (true)
56+
+ {
57+
+ using var uwr = UnityWebRequest.Get(GameShell.GetServerInterface().GetServerAddress() + "stats.json");
58+
+ yield return uwr.SendWebRequest();
59+
+
60+
+ var stats = JsonConvert.DeserializeObject<ServerStats>(uwr.downloadHandler.text);
61+
+ _text.text = $"{stats.OnlinePlayers} online | {stats.ActiveBattles} active battles";
62+
+
63+
+ yield return new WaitForSeconds(5);
64+
+ }
65+
+ }
66+
+
67+
+ public class ServerStats
68+
+ {
69+
+ public int OnlinePlayers { get; set; }
70+
+ public int ActiveBattles { get; set; }
71+
+ }
72+
+}
73+
\ No newline at end of file
74+
diff --git a/Assets/Scripts/Assembly-CSharp/OnlineCountText.cs.meta b/Assets/Scripts/Assembly-CSharp/OnlineCountText.cs.meta
75+
new file mode 100644
76+
index 00000000..0f9b18a8
77+
--- /dev/null
78+
+++ b/Assets/Scripts/Assembly-CSharp/OnlineCountText.cs.meta
79+
@@ -0,0 +1,3 @@
80+
+fileFormatVersion: 2
81+
+guid: 3ba3494398194c79a033a36cf20800a4
82+
+timeCreated: 1777086225
83+
\ No newline at end of file
84+
diff --git a/Assets/prefabs/ui/entermatch/EnteringMatch.prefab b/Assets/prefabs/ui/entermatch/EnteringMatch.prefab
85+
index 4d97cd63..d655bb26 100644
86+
--- a/Assets/prefabs/ui/entermatch/EnteringMatch.prefab
87+
+++ b/Assets/prefabs/ui/entermatch/EnteringMatch.prefab
88+
@@ -7045,2 +7045,3 @@ MonoBehaviour:
89+
CancelMatchmakingButton: {fileID: 1161607090078389}
90+
+ OnlineText: {fileID: 3629023196993208479}
91+
GameCamera: {fileID: 20694121525821480}
92+
@@ -7451,2 +7452,3 @@ RectTransform:
93+
- {fileID: 224534704304255049}
94+
+ - {fileID: 7152391952487535975}
95+
- {fileID: 224264357844037074}
96+
@@ -7779 +7781,149 @@ MonoBehaviour:
97+
m_EditorClassIdentifier:
98+
+--- !u!1 &7730304590025242324
99+
+GameObject:
100+
+ m_ObjectHideFlags: 0
101+
+ m_CorrespondingSourceObject: {fileID: 0}
102+
+ m_PrefabInstance: {fileID: 0}
103+
+ m_PrefabAsset: {fileID: 0}
104+
+ serializedVersion: 6
105+
+ m_Component:
106+
+ - component: {fileID: 7152391952487535975}
107+
+ - component: {fileID: 2416730669248565582}
108+
+ - component: {fileID: 3629023196993208479}
109+
+ - component: {fileID: 7003398451001004435}
110+
+ m_Layer: 5
111+
+ m_Name: OnlineText
112+
+ m_TagString: Untagged
113+
+ m_Icon: {fileID: 0}
114+
+ m_NavMeshLayer: 0
115+
+ m_StaticEditorFlags: 0
116+
+ m_IsActive: 1
117+
+--- !u!224 &7152391952487535975
118+
+RectTransform:
119+
+ m_ObjectHideFlags: 0
120+
+ m_CorrespondingSourceObject: {fileID: 0}
121+
+ m_PrefabInstance: {fileID: 0}
122+
+ m_PrefabAsset: {fileID: 0}
123+
+ m_GameObject: {fileID: 7730304590025242324}
124+
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
125+
+ m_LocalPosition: {x: 0, y: 0, z: 0}
126+
+ m_LocalScale: {x: 1, y: 1, z: 1}
127+
+ m_ConstrainProportionsScale: 0
128+
+ m_Children: []
129+
+ m_Father: {fileID: 224291844617409189}
130+
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
131+
+ m_AnchorMin: {x: 0, y: 0}
132+
+ m_AnchorMax: {x: 1, y: 0}
133+
+ m_AnchoredPosition: {x: 0, y: 20}
134+
+ m_SizeDelta: {x: -40, y: 100}
135+
+ m_Pivot: {x: 0.5, y: 0}
136+
+--- !u!222 &2416730669248565582
137+
+CanvasRenderer:
138+
+ m_ObjectHideFlags: 0
139+
+ m_CorrespondingSourceObject: {fileID: 0}
140+
+ m_PrefabInstance: {fileID: 0}
141+
+ m_PrefabAsset: {fileID: 0}
142+
+ m_GameObject: {fileID: 7730304590025242324}
143+
+ m_CullTransparentMesh: 1
144+
+--- !u!114 &3629023196993208479
145+
+MonoBehaviour:
146+
+ m_ObjectHideFlags: 0
147+
+ m_CorrespondingSourceObject: {fileID: 0}
148+
+ m_PrefabInstance: {fileID: 0}
149+
+ m_PrefabAsset: {fileID: 0}
150+
+ m_GameObject: {fileID: 7730304590025242324}
151+
+ m_Enabled: 1
152+
+ m_EditorHideFlags: 0
153+
+ m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
154+
+ m_Name:
155+
+ m_EditorClassIdentifier:
156+
+ m_Material: {fileID: 0}
157+
+ m_Color: {r: 1, g: 1, b: 1, a: 1}
158+
+ m_RaycastTarget: 1
159+
+ m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
160+
+ m_Maskable: 1
161+
+ m_OnCullStateChanged:
162+
+ m_PersistentCalls:
163+
+ m_Calls: []
164+
+ m_text: Loading online count...
165+
+ m_isRightToLeft: 0
166+
+ m_fontAsset: {fileID: 11400000, guid: ce62afb04dbe15178e3ff84ff2726426, type: 2}
167+
+ m_sharedMaterial: {fileID: -95363901605624429, guid: ce62afb04dbe15178e3ff84ff2726426,
168+
+ type: 2}
169+
+ m_fontSharedMaterials: []
170+
+ m_fontMaterial: {fileID: 0}
171+
+ m_fontMaterials: []
172+
+ m_fontColor32:
173+
+ serializedVersion: 2
174+
+ rgba: 4278190080
175+
+ m_fontColor: {r: 0, g: 0, b: 0, a: 1}
176+
+ m_enableVertexGradient: 0
177+
+ m_colorMode: 3
178+
+ m_fontColorGradient:
179+
+ topLeft: {r: 1, g: 1, b: 1, a: 1}
180+
+ topRight: {r: 1, g: 1, b: 1, a: 1}
181+
+ bottomLeft: {r: 1, g: 1, b: 1, a: 1}
182+
+ bottomRight: {r: 1, g: 1, b: 1, a: 1}
183+
+ m_fontColorGradientPreset: {fileID: 0}
184+
+ m_spriteAsset: {fileID: 0}
185+
+ m_tintAllSprites: 0
186+
+ m_StyleSheet: {fileID: 0}
187+
+ m_TextStyleHashCode: -1183493901
188+
+ m_overrideHtmlColors: 0
189+
+ m_faceColor:
190+
+ serializedVersion: 2
191+
+ rgba: 4294967295
192+
+ m_fontSize: 100
193+
+ m_fontSizeBase: 165
194+
+ m_fontWeight: 400
195+
+ m_enableAutoSizing: 1
196+
+ m_fontSizeMin: 50
197+
+ m_fontSizeMax: 200
198+
+ m_fontStyle: 0
199+
+ m_HorizontalAlignment: 2
200+
+ m_VerticalAlignment: 4096
201+
+ m_textAlignment: 65535
202+
+ m_characterSpacing: 0
203+
+ m_wordSpacing: 0
204+
+ m_lineSpacing: 0
205+
+ m_lineSpacingMax: 0
206+
+ m_paragraphSpacing: 0
207+
+ m_charWidthMaxAdj: 0
208+
+ m_enableWordWrapping: 1
209+
+ m_wordWrappingRatios: 0.4
210+
+ m_overflowMode: 0
211+
+ m_linkedTextComponent: {fileID: 0}
212+
+ parentLinkedComponent: {fileID: 0}
213+
+ m_enableKerning: 1
214+
+ m_enableExtraPadding: 0
215+
+ checkPaddingRequired: 0
216+
+ m_isRichText: 1
217+
+ m_parseCtrlCharacters: 1
218+
+ m_isOrthographic: 1
219+
+ m_isCullingEnabled: 0
220+
+ m_horizontalMapping: 0
221+
+ m_verticalMapping: 0
222+
+ m_uvLineOffset: 0
223+
+ m_geometrySortingOrder: 0
224+
+ m_IsTextObjectScaleStatic: 0
225+
+ m_VertexBufferAutoSizeReduction: 0
226+
+ m_useMaxVisibleDescender: 1
227+
+ m_pageToDisplay: 1
228+
+ m_margin: {x: 0, y: 0, z: 0, w: 0}
229+
+ m_isUsingLegacyAnimationComponent: 0
230+
+ m_isVolumetricText: 0
231+
+ m_hasFontAssetChanged: 0
232+
+ m_baseMaterial: {fileID: 0}
233+
+ m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
234+
+--- !u!114 &7003398451001004435
235+
+MonoBehaviour:
236+
+ m_ObjectHideFlags: 0
237+
+ m_CorrespondingSourceObject: {fileID: 0}
238+
+ m_PrefabInstance: {fileID: 0}
239+
+ m_PrefabAsset: {fileID: 0}
240+
+ m_GameObject: {fileID: 7730304590025242324}
241+
+ m_Enabled: 1
242+
+ m_EditorHideFlags: 0
243+
+ m_Script: {fileID: 11500000, guid: 3ba3494398194c79a033a36cf20800a4, type: 3}
244+
+ m_Name:
245+
+ m_EditorClassIdentifier:
File renamed without changes.

0 commit comments

Comments
 (0)