커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
컴파일 오류같은데 뭔지 잘 모르겠습니다 ㅠ
undefined주차
북마크
임*윤
댓글
7
추천
0
조회수
8
조회수
8
답변 완료

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

스파르타 즉문즉답


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");
    }
}

        
취소
 공유
취소
댓글 0
댓글 알림
나의얼굴