
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
다시하기 버튼이 뜨고 눌렀을때 다시 시작해야 하는데, 다시 시작이 안되요.
코드 오류도 없고 유니티 게임매니저 세팅도 되어있어요.

작성한 코드 및 에러 메세지
#gameManager.cs
오류 발생 시, 작성한 코드 전체와 에러 메시지를 첨부using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class gameManager : MonoBehaviour
{
public GameObject food;
public GameObject dog;
public GameObject normalCat;
public GameObject fatCat;
public GameObject pirateCat;
public GameObject retryBtn;
public Text levelText;
public GameObject levelFront;
public static gameManager I;
int level = 0;
int cat = 0;
void Awake()
{
I = this;
}
// Start is called before the first frame update
void Start()
{
Time.timeScale = 1f;
InvokeRepeating("makeFood", 0.0f, 0.05f);
InvokeRepeating("makeCat", 0.0f, 1.0f);
}
// Update is called once per frame
void Update()
{
}
void makeFood()
{
float x = dog.transform.position.x;
float y = dog.transform.position.y + 2.0f;
Instantiate(food, new Vector3(x, y, 0), Quaternion.identity);
}
void makeCat()
{
Instantiate(normalCat);
if (level == 1)
{
float p = Random.Range(0, 10);
if (p < 2) Instantiate(normalCat);
}
else if (level == 2)
{
float p = Random.Range(0, 10);
if (p < 5) Instantiate(normalCat);
}
else if (level == 3)
{
float p = Random.Range(0, 10);
if (p < 6) Instantiate(normalCat);
Instantiate(fatCat);
}
else if (level >= 4)
{
float p = Random.Range(0, 10);
if (p < 5) Instantiate(normalCat);
Instantiate(fatCat);
Instantiate(pirateCat);
}
}
public void gameOver()
{
retryBtn.SetActive(true);
Time.timeScale = 0f;
}
public void addCat()
{
cat += 1;
level = cat / 5;
levelText.text = level.ToString();
levelFront.transform.localScale = new Vector3((cat - level * 5) / 5.0f, 1.0f, 1.0f);
}
}해 주세요.
Tip 1) </> 아이콘을 눌러 코드박스를 만들어 보세요.
Tip 2) Ctrl+A(맥의 경우 Command+A) 단축키로 코드를 한 번에 선택할 수 있어요!
#retryBtn.cs
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class retryBtn : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void ReGame()
{
SceneManager.LoadScene("MainScene");
}
}
