커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
3주차 고양이 밥주기 게임에서 게임메니저 에러가뜨고 Play 버튼을누르면 실행되지 않습니다.
undefined주차
북마크
문*철
댓글
57
추천
0
조회수
61
조회수
61
답변 완료

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

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


3주차강의 고양이 밥주기 게임에서 게임메니저 에러가나오고 play 버튼실행시 에러가 나옵니다 해결책좀 알려주세요


아래첫번째 화면- 게임메니저 스크립트 두번째 화면-유니티 에러화면

게임메니저 코드입니다(첫번째화면)


using UnityEngine;

 using UnityEngine.UI;     

   

  public class GameManager : MonoBehaviour

  {

    public static GameManager Instance;

   

    public GameObject normalCat;

    public GameObject fatCat;

    public GameObject retryBtn;

   

    public RectTransform levelFront;

    public Text levelTxt;

   

    public int level = 0;

    int score = 0;

   

    private void Awake()

    {

      if(Instance == null)

      {

        Instance = this;

      }

      Application.targetFrameRate = 60;

      Time.timeScale = 1.0f;

    }

   

    // Start is called before the first frame update

    void Start()

    {

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

    }

   

    void MakeCat()

    {

      Instantiate(normalCat);

   

      // lv.1 20% 확률로 고양이를 더 생성해준다.

      if(level == 1)

      {

        int p = Random.Range(0, 10);

        if(p < 2) Instantiate(normalCat);

      }

      else if(level == 2)

      {

        // lv.2 50% 확률로 고양이를 더 생성해준다.

        int p = Random.Range(0, 10);

        if (p < 5) Instantiate(normalCat);

      }

      else if(level == 3)

      {

        // lv.3 뚱뚱한 고양이를 생성해준다.

        Instantiate(fatCat);

      }

    }

   

    public void GameOver()

    {

      retryBtn.SetActive(true);

      Time.timeScale = 0f;

    }

   

    public void AddScore()

    {

      score++;

      level = score / 5;

      levelTxt.text = level.ToString();

      levelFront.localScale = new Vector3((score - level * 5) / 5.0f, 1f, 1f);

    }

  }



두번째 화면-유니티 화면 에러메세지

스파르타 즉문즉답





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