Unity:ランキング入力時のリセットキー無効化

前提

Unityで制作しているゲームに、こちらのサイトを参考にしてランキング機能をつけました。
https://blog.naichilab.com/entry/webgl-simple-ranking

ゲームオーバー時にゲームオーバーパネルが出現、そのときにRキー、Bキーで画面を切り替えるようにしています。
そのキー入力がランキング入力時にも反映されてしまうので名前にbやrが入っている人の場合、送信前に画面が切り替わってしまいます。
ランキングがシーン上にあるか検知してif分に追加する方法を探しているのですが、ランキングはゲームとは別のシーンなのでどう検知すればいいか分かりません。
検知方法、もしくはその他の方法があれば教えていただきたいです。

実現したいこと

ランキング入力中はリセットキー・リスタートキーを無効化したい。

発生している問題・エラーメッセージ

ランキング入力中に特定キーを入力すると、スコアが破棄されて画面が切り替わってしまう。

該当のソースコード

using System.Collections; using DG.Tweening; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; public class GameManager : MonoBehaviour { [SerializeField] private int countDownTime; [SerializeField] private Text countDownText, gameOverText, scoreText; [SerializeField] private GameObject gameOverPanel; void Start() { if (!countDownText.gameObject.activeSelf) { countDownText.gameObject.SetActive(true); } StartCoroutine(CountDownStart()); } private void Update() { //ここにランキングシーンの検知を追加したい。 if (gameOverPanel.activeSelf) { if (Input.GetKeyDown(KeyCode.B)) { SceneManager.LoadScene(0); Time.timeScale = 1; } else if (Input.GetKeyDown(KeyCode.R)) { SceneManager.LoadScene(1); Time.timeScale = 1; } } } IEnumerator CountDownStart() { while (countDownTime > 0) { countDownText.text = countDownTime.ToString(); yield return new WaitForSeconds(1f); countDownTime --; } countDownText.text = "START!"; yield return new WaitForSeconds(1f); countDownText.gameObject.SetActive(false); yield break; } public void GameOver() { scoreText.text = string.Format("SCORE:{0}", ScoreManager.score); gameOverPanel.SetActive(true); gameOverText.transform.DOShakePosition(1f, 100f, 30, 30, false, true) .SetUpdate(true); //ランキングの表示 naichilab.RankingLoader.Instance.SendScoreAndShowRanking(ScoreManager.score); Time.timeScale = 0; } }

試したこと

Active

コメントを投稿

0 コメント