Skip to content

Commit 215592a

Browse files
committed
Updated text sizing
- Ellipsis text larger then MaxLength (default 20) - Resized text in various UI for better spacing
1 parent a0cee99 commit 215592a

7 files changed

Lines changed: 102 additions & 30 deletions

File tree

Assets/EC2018/CountInDetailPopulator.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public class CountInDetailPopulator : MonoBehaviour {
88

99
public TextMeshProUGUI tmpPlayerA;
1010
public TextMeshProUGUI tmpPlayerB;
11+
public int MaxLength = 20;
1112

1213
void Start () {
1314
tmpPlayerA.text = GetPlayerName (PlayerType.A);
@@ -16,10 +17,17 @@ void Start () {
1617

1718
public string GetPlayerName(PlayerType playerType) {
1819
var allPlayers = Directory.GetDirectories(GetReplayPathFromPrefs() + "/Round 000");
20+
string playerName;
1921
if (playerType == PlayerType.A) {
20-
return new DirectoryInfo(allPlayers[0]).Name;
22+
playerName = new DirectoryInfo(allPlayers[0]).Name;
2123
}
22-
return new DirectoryInfo(allPlayers[1]).Name;
24+
playerName = new DirectoryInfo(allPlayers[1]).Name;
25+
26+
if(playerName.Length > MaxLength) {
27+
playerName = playerName.Substring(0, MaxLength) + "...";
28+
}
29+
30+
return playerName;
2331
}
2432

2533
string GetReplayPathFromPrefs() {

Assets/EC2018/Countdown.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ void Start () {
1818

1919
IEnumerator StartReplayScene() {
2020
yield return new WaitForSeconds (startDelay);
21-
countdownText.fontSize = 50;
21+
countdownText.fontSize = 40;
2222
countdownText.text = "3";
2323
yield return new WaitForSeconds (counterTime);
24-
countdownText.fontSize = 70;
24+
countdownText.fontSize = 60;
2525
countdownText.text = "2";
2626
yield return new WaitForSeconds (counterTime);
27-
countdownText.fontSize = 100;
27+
countdownText.fontSize = 80;
2828
countdownText.text = "1";
2929
yield return new WaitForSeconds (counterTime);
30-
countdownText.fontSize = 120;
30+
countdownText.fontSize = 100;
3131

3232
int i = Random.Range(0, kickOffPhrases.Length);
3333

Assets/EC2018/EllipsisText.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using UnityEngine.UI;
5+
6+
public class EllipsisText : MonoBehaviour {
7+
8+
public Text Text;
9+
public int MaxLength;
10+
11+
void Update () {
12+
InvokeRepeating("CheckAndSetText", 0f, 0.1f);
13+
}
14+
15+
void CheckAndSetText() {
16+
if(Text.text.Length > MaxLength) {
17+
Text.text = Text.text.Substring(0, MaxLength) + "...";
18+
}
19+
}
20+
}

Assets/EC2018/EllipsisText.cs.meta

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/EC2018/UIManager.cs

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public class UIManager : MonoBehaviour {
3434
public BarrierHealth barrierHealthA;
3535
public BarrierHealth barrierHealthB;
3636

37+
public int MaxLength = 20;
38+
3739
GameManager gameManager;
3840

3941
bool pulseIronCurtainPlayerA;
@@ -66,8 +68,12 @@ void Update() {
6668
}
6769

6870
public void SetPlayerNames(string playerAName, string playerBName) {
69-
PlayerAName.text = playerAName;
70-
PlayerBName.text = playerBName;
71+
PlayerAName.text = playerAName.Length > MaxLength ?
72+
playerAName.Substring(0, MaxLength) + "..." :
73+
playerAName;
74+
PlayerBName.text = playerBName.Length > MaxLength ?
75+
playerBName.Substring(0, MaxLength) + "..." :
76+
playerBName;
7177
}
7278

7379
public void UpdateUI(GameDetails gameDetails, Player playerA, Player playerB) {
@@ -123,21 +129,44 @@ public void UpdateUI(GameDetails gameDetails, Player playerA, Player playerB) {
123129
}
124130

125131
public void DisplayFinalGameMessage(GameState finalState, string namePlayerA, string namePlayerB) {
132+
133+
string nameA = namePlayerA.Length > MaxLength ?
134+
namePlayerA.Substring(0, MaxLength) + "..." :
135+
namePlayerA;
136+
string nameB = namePlayerB.Length > MaxLength ?
137+
namePlayerB.Substring(0, MaxLength) + "..." :
138+
namePlayerB;
139+
126140
FinalGameHolder.SetActive(true);
141+
142+
string winnerStatsText = "";
143+
string loserStatsText = "";
144+
127145
if(winningPlayer == PlayerType.A) {
128146
playerAWinHolder.SetActive(true);
129-
winningPlayerText.text = namePlayerA + "\nWins!";
147+
winningPlayerText.text = nameA + "\nWins!";
148+
149+
winnerStatsText = "Score: " + finalState.Players[0].Score + "\n" +
150+
"Hits taken: " + finalState.Players[0].HitsTaken;
151+
152+
loserStatsText = "Player: " + nameB + "\n" +
153+
"Score: " + finalState.Players[1].Score + "\n" +
154+
"Hits taken: " + finalState.Players[1].HitsTaken;
130155
} else {
131156
playerBWinHolder.SetActive(true);
132-
winningPlayerText.text = namePlayerB + "\nWins!";
157+
winningPlayerText.text = nameB + "\nWins!";
158+
159+
winnerStatsText = "Score: " + finalState.Players[1].Score + "\n" +
160+
"Hits taken: " + finalState.Players[1].HitsTaken;
161+
162+
loserStatsText = "Player: " + nameA + "\n" +
163+
"Score: " + finalState.Players[0].Score + "\n" +
164+
"Hits taken: " + finalState.Players[0].HitsTaken;
133165
}
134166

135-
winningPlayerStatsText.text = "Score: " + finalState.Players[0].Score + "\n" +
136-
"Hits taken: " + finalState.Players[0].HitsTaken;
167+
winningPlayerStatsText.text = winnerStatsText;
137168

138-
losingPlayerStatsText.text = "Player: " + namePlayerB + "\n" +
139-
"Score: " + finalState.Players[1].Score + "\n" +
140-
"Hits taken: " + finalState.Players[1].HitsTaken;
169+
losingPlayerStatsText.text = loserStatsText;
141170
}
142171

143172
string GetPlayerType(Player player) {

Assets/Scenes/CountInScene.unity

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,7 @@ MonoBehaviour:
950950
m_EditorClassIdentifier:
951951
tmpPlayerA: {fileID: 300225247}
952952
tmpPlayerB: {fileID: 1831951726}
953+
MaxLength: 20
953954
--- !u!1 &1116120781
954955
GameObject:
955956
m_ObjectHideFlags: 0
@@ -1330,9 +1331,9 @@ MonoBehaviour:
13301331
kickOffPhrases:
13311332
- Let the battle begin!
13321333
- Bots starting up...
1333-
- Two enter, one leaves!
1334+
- 2 enter, 1 leaves!
13341335
- Are ya ready kids?
1335-
- War. War never changes
1336+
- War never changes!
13361337
--- !u!1 &1831951724
13371338
GameObject:
13381339
m_ObjectHideFlags: 0

Assets/Scenes/ReplayScene.unity

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,7 +2268,7 @@ RectTransform:
22682268
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
22692269
m_AnchorMin: {x: 0, y: 0.5}
22702270
m_AnchorMax: {x: 1, y: 0.5}
2271-
m_AnchoredPosition: {x: 0, y: 0}
2271+
m_AnchoredPosition: {x: 0, y: -10}
22722272
m_SizeDelta: {x: 0, y: 125}
22732273
m_Pivot: {x: 0.5, y: 0.5}
22742274
--- !u!114 &125699162
@@ -2318,8 +2318,8 @@ MonoBehaviour:
23182318
m_outlineColor:
23192319
serializedVersion: 2
23202320
rgba: 4278190080
2321-
m_fontSize: 42
2322-
m_fontSizeBase: 42
2321+
m_fontSize: 38
2322+
m_fontSizeBase: 38
23232323
m_fontWeight: 400
23242324
m_enableAutoSizing: 0
23252325
m_fontSizeMin: 18
@@ -2795,8 +2795,8 @@ MonoBehaviour:
27952795
m_outlineColor:
27962796
serializedVersion: 2
27972797
rgba: 4278190080
2798-
m_fontSize: 36
2799-
m_fontSizeBase: 36
2798+
m_fontSize: 34
2799+
m_fontSizeBase: 34
28002800
m_fontWeight: 400
28012801
m_enableAutoSizing: 0
28022802
m_fontSizeMin: 18
@@ -12460,6 +12460,7 @@ MonoBehaviour:
1246012460
losingPlayerStatsText: {fileID: 148899221}
1246112461
barrierHealthA: {fileID: 912874940}
1246212462
barrierHealthB: {fileID: 1641376618}
12463+
MaxLength: 20
1246312464
--- !u!114 &893612604
1246412465
MonoBehaviour:
1246512466
m_ObjectHideFlags: 0
@@ -16484,8 +16485,8 @@ RectTransform:
1648416485
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
1648516486
m_AnchorMin: {x: 0.5, y: 0}
1648616487
m_AnchorMax: {x: 0.5, y: 0}
16487-
m_AnchoredPosition: {x: 0, y: 75}
16488-
m_SizeDelta: {x: 360, y: 400}
16488+
m_AnchoredPosition: {x: 0, y: 50}
16489+
m_SizeDelta: {x: 360, y: 425}
1648916490
m_Pivot: {x: 0.5, y: 0}
1649016491
--- !u!1001 &1214056443
1649116492
Prefab:
@@ -23622,7 +23623,7 @@ RectTransform:
2362223623
m_AnchorMin: {x: 0, y: 1}
2362323624
m_AnchorMax: {x: 1, y: 1}
2362423625
m_AnchoredPosition: {x: 0, y: 0}
23625-
m_SizeDelta: {x: 0, y: 125}
23626+
m_SizeDelta: {x: 0, y: 140}
2362623627
m_Pivot: {x: 0.5, y: 1}
2362723628
--- !u!114 &1726131729
2362823629
MonoBehaviour:
@@ -23643,7 +23644,7 @@ MonoBehaviour:
2364323644
m_Calls: []
2364423645
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
2364523646
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
23646-
m_text: B - Jan van der Westhuyzen wins!
23647+
m_text: "B - Jan van der Westhuyzen \nwins!"
2364723648
m_isRightToLeft: 0
2364823649
m_fontAsset: {fileID: 11400000, guid: 11ec85aa2b844468eb819656bb4ee6b8, type: 2}
2364923650
m_sharedMaterial: {fileID: 21045330511842694, guid: 11ec85aa2b844468eb819656bb4ee6b8,
@@ -23712,12 +23713,12 @@ MonoBehaviour:
2371223713
m_margin: {x: 0, y: 0, z: 0, w: 0}
2371323714
m_textInfo:
2371423715
textComponent: {fileID: 1726131729}
23715-
characterCount: 32
23716+
characterCount: 33
2371623717
spriteCount: 0
23717-
spaceCount: 6
23718+
spaceCount: 7
2371823719
wordCount: 7
2371923720
linkCount: 0
23720-
lineCount: 2
23721+
lineCount: 3
2372123722
pageCount: 1
2372223723
materialCount: 1
2372323724
m_havePropertiesChanged: 0
@@ -25479,7 +25480,7 @@ GameObject:
2547925480
m_Icon: {fileID: 0}
2548025481
m_NavMeshLayer: 0
2548125482
m_StaticEditorFlags: 0
25482-
m_IsActive: 0
25483+
m_IsActive: 1
2548325484
--- !u!224 &1871486360
2548425485
RectTransform:
2548525486
m_ObjectHideFlags: 0

0 commit comments

Comments
 (0)