커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
2-8 게임종료 판넬 만들기 하다 에러가 나와서 봐주세요
undefined주차
북마크
문*철
댓글
8
추천
0
조회수
9
조회수
9
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


게임매니져 코드에 에러가 나왔습니다

밑에첫번째 유니티 에러캡쳐화면이고 2번째는 게임매니져 코드 입니다

초보이니 게임매니져코드 좀 올려주시고 어떤부분에서 에러가나왔는지 상세히 설명 부탁드립니다.







using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.UI;


public class GameManager : MonoBehaviour

{

  public static GameManager Instance;


  public GameObject square;

  public GameObject endPanel;

  public Text timeTxt;

  public Text nowScore;

  public Text bestScore;


  public Animator anim;

   

  bool isPlay = true;

   

  float time = 0.0f;

   

  string key = "bestScore";

   

  private void Awake()  

  {  

   if(Instance == null)

   {  

     Instance = this;  

   }   

  }

   

  void Start()  

  {

    Time.timeScale = 1.0f; 

    InvokeRepeating("MakeSquare", 0f, 1f);

  }  

     

  // Update is called once per frame  

  void Update()

  {

   if (isPlay)

   {

     time += Time.deltaTime;

     timeTxt.text = time.ToString("N2");

   }

  }   

   

  void MakeSquare()

  {  

    Instantiate(square);

  }  

    

  public void GameOver()  

  {

    isPlay = false;

    anim.SetBool("isDie", true);

    Invoke("TimeStop", 0.5f);

    nowScore.text = time.ToString("N2");

    

    // 최고점수가 있다면

    if (PlayerPrefs.HasKey(key))

    {

     float best = PlayerPrefs.GetFloat(key);

     // 최고점수 < 현재 점수

     if (best < time)

     {

     // 현재 점수를 최고 점수에 저장한다.

      PlayerPrefs.SetFloat(key , time);

      bestScore.text =time.ToString("N2");

     }  

     else

     { 

       bestScore.text = best.ToString("N2");

     }  

    }

    else

    {

      PlayerPrefs.SetFloat(key, time);

      bestScore.text = time.ToString("N2");

    }  

    

    endPanel.SetActive(true); 

  }   


  void TimeStop()

  {

    Time.timeScale = 0.0f;

  }  

}     


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