Optimize text stuff

This commit is contained in:
2025-05-31 16:54:33 -07:00
parent 01d28cd8ce
commit 7368bc6fff

View File

@@ -84,7 +84,7 @@ public class Game : MonoBehaviour
PlayerPrefs.Save(); PlayerPrefs.Save();
backgroundMusic.volume = PlayerPrefs.GetFloat("musicVolume", 1f); backgroundMusic.volume = PlayerPrefs.GetFloat("musicVolume", 1f);
screenWidth = Camera.main.orthographicSize * 2f * Camera.main.aspect; screenWidth = Camera.main.orthographicSize * 2f * Camera.main.aspect;
GameObject.Find("HighScoreText").GetComponent<TMP_Text>().text = $"High Score: {highscore}"; highScoreText.text = $"High Score: {highscore}";
if (PlayerPrefs.GetInt("Setting2", 0) == 1) if (PlayerPrefs.GetInt("Setting2", 0) == 1)
{ {
GameObject leftArrow = new("LeftArrow"); GameObject leftArrow = new("LeftArrow");
@@ -295,16 +295,16 @@ public class Game : MonoBehaviour
if (boostLeft > 0f) if (boostLeft > 0f)
{ {
boostLeft -= Time.deltaTime; boostLeft -= Time.deltaTime;
boostText.GetComponent<TMP_Text>().text = "Boost expires in " + $"{boostLeft:0.0}" + "s"; boostText.text = "Boost expires in " + $"{boostLeft:0.0}" + "s";
} }
else if (slownessLeft > 0f) else if (slownessLeft > 0f)
{ {
slownessLeft -= Time.deltaTime; slownessLeft -= Time.deltaTime;
boostText.GetComponent<TMP_Text>().text = "Slowness expires in " + $"{slownessLeft:0.0}" + "s"; boostText.text = "Slowness expires in " + $"{slownessLeft:0.0}" + "s";
} }
else else
{ {
boostText.GetComponent<TMP_Text>().text = ""; boostText.text = "";
} }
} }
} }