
컴파일 오류같은데 뭔지 잘 모르겠습니다 ㅠ

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class gameManager : MonoBehaviour
{
public GameObject square;
public Text timeTxt;
public Text thisscoreTxt;
float alive = 0f;
float endTime = 0f; // 종료시에 종료 시점을 저장하는 변수
bool isRunning = true;
public static gameManager I;
public GameObject endPanel;
public Text maxScoreTxt;
void Awake()
{
I = this;
}
void Start()
{
InvokeRepeating("makeSquare", 0.0f, 0.7f);
}
// Update is called once per frame
void Update()
{
if (isRunning)
{
Debug.Log("업데이트"); // <-디버그
alive += Time.deltaTime;
timeTxt.text = alive.ToString("N2");
}
else
{
Debug.Log("종료후 업데이트"); // <- 디버그
timeTxt.text = endTime.ToString("N2"); // 종료되었다면? 종료시점의 시간으로 고정
}
}
void makeSquare()
{
Instantiate(square);
}
public void gameOver()
{
isRunning = false;
Time.timeScale = 0f;
endTime = alive; // 종료 시점의 시간
Debug.Log("종료"); // <- 디버그
thisscoreTxt.text = endTime.ToString("N2"); // 종료 시점의 시간을 보여주기
endPanel.SetActive(true);
if (PlayerPrefs.HasKey("bestScore") == false)
{
PlayerPrefs.SetFloat("bestScore", alive);
}
else
{
if (PlayerPrefs.GetFloat("bestScore") < alive)
{
PlayerPrefs.SetFloat("bestScore", alive);
}
}
float maxscore text = PlayerPrefs GetFloat("bestscore");
maxscore text.text = maxScore.ToString("N2");
}
public void retry()
{
SceneManager.LoadScene("MainScene");
}
}
