From 35e3ad37122f8bcf80ed3697dd892d79fe50878a Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Sun, 24 Aug 2025 15:00:43 -0700 Subject: [PATCH] Fix restart button not being gray --- Assets/Scenes/GamePlayer.unity | 10 +++++----- Assets/Scripts/GamePlayer.cs | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Assets/Scenes/GamePlayer.unity b/Assets/Scenes/GamePlayer.unity index 80ced30..b99ed9b 100644 --- a/Assets/Scenes/GamePlayer.unity +++ b/Assets/Scenes/GamePlayer.unity @@ -2289,11 +2289,11 @@ MonoBehaviour: overlayRender: {fileID: 450099081} berryParent: {fileID: 157908646} mobileButtons: {fileID: 872476494} - pauseButton: {fileID: 1577031231} - restartButton: {fileID: 34767209} - jumpButton: {fileID: 293594132} - rightButton: {fileID: 1125207525} - leftButton: {fileID: 2069651271} + pauseButton: {fileID: 1577031227} + restartButton: {fileID: 34767206} + jumpButton: {fileID: 293594129} + rightButton: {fileID: 1125207522} + leftButton: {fileID: 2069651268} --- !u!1 &527090675 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/GamePlayer.cs b/Assets/Scripts/GamePlayer.cs index a8ed56b..7f62c75 100644 --- a/Assets/Scripts/GamePlayer.cs +++ b/Assets/Scripts/GamePlayer.cs @@ -42,11 +42,11 @@ public class GamePlayer : MonoBehaviour public GameObject berryParent; public GameObject mobileButtons; - public HoldableButton pauseButton; - public HoldableButton restartButton; - public HoldableButton jumpButton; - public HoldableButton rightButton; - public HoldableButton leftButton; + public Button pauseButton; + public Button restartButton; + public Button jumpButton; + public Button rightButton; + public Button leftButton; void Start() { @@ -205,11 +205,11 @@ public class GamePlayer : MonoBehaviour var pos = touches[i].screenPosition; UnityEngine.Vector3 clickPosition = Camera.main.ScreenToWorldPoint(new UnityEngine.Vector3(pos.x, pos.y, 0f)); clickPosition.z = 0f; - if (leftButton.isPressed) doMoveLeft = true; - if (rightButton.isPressed) doMoveRight = true; - if (jumpButton.isPressed) doJump = true; - if (restartButton.isPressed) doRestart = true; - if (pauseButton.isPressed) doBack = true; + if (leftButton.GetComponent().isPressed) doMoveLeft = true; + if (rightButton.GetComponent().isPressed) doMoveRight = true; + if (jumpButton.GetComponent().isPressed) doJump = true; + if (restartButton.GetComponent().isPressed) doRestart = true; + if (pauseButton.GetComponent().isPressed) doBack = true; } } if (doMoveLeft && !doMoveRight) @@ -608,7 +608,7 @@ public class GamePlayer : MonoBehaviour scoreText.text = $"Score: {Tools.FormatWithCommas(score)} \\u2022 Attempts: {Tools.FormatWithCommas(attempts)}"; highScoreText.text = $"High Score: {Tools.FormatWithCommas(highscore)} \\u2022 Total Attempts: {Tools.FormatWithCommas(totalAttempts)}"; coinText.text = $"Coins: {Tools.FormatWithCommas(totalCoins)}"; - if (Application.isMobilePlatform) restartButton.transform.GetChild(0).GetComponent().material.color = score == 0 ? Color.gray : Color.white; + if (Application.isMobilePlatform) restartButton.interactable = score != 0; } void CheckIfGrounded()