
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
16:08에 보시면 OnClick에서 Panel을 끌어와 no function에서 Panel을 찾으면 retry가 있을 거라고 하시는데
Panel은 제대로 끌어와지는데
제가 어디서부터 놓친건지 no function에 Panel이 없고 GameObject랑 RectTransform, Canvas,
CanvasScalar, GraphicRaycaster, Button밖에 없네요ㅠ
Panel.cs에서 GameManager를 호출하는 것까지 하고 저장했었습니다.
Panel.cs이구요.
작성한 코드 및 에러 메세지
GameManager.cs입니다.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour
{
public GameObject Rain;
public GameObject Panel;
public static GameManager I; // GameManager의 싱글톤화
public Text scoreText;
public Text timeText;
int totalScore;
float limit = 5f;
void Awake()
{
I = this;
}
// Start is called before the first frame update
void Start()
{
InvokeRepeating("makeRain", 0, 0.5f);
}
// Update is called once per frame
void Update()
{
limit -= Time.deltaTime;
if (limit < 0)
{
Time.timeScale = 0.0f;
Panel.SetActive(true);
limit = 0.0f;
}
timeText.text = limit.ToString("N2"); // 소수점 둘째 자리까지 잘라서 문자열로 바꾸기
}
void makeRain()
{
Instantiate(Rain);
}
public void addScore(int score)
{
totalScore += score;
scoreText.text = totalScore.ToString();
}
public void retry()
{
SceneManager.LoadScene("MainScene");
}
}
오류 발생 시, 작성한 코드 전체와 에러 메시지를 첨부해 주세요.
Tip 1) </> 아이콘을 눌러 코드박스를 만들어 보세요.
Tip 2) Ctrl+A(맥의 경우 Command+A) 단축키로 코드를 한 번에 선택할 수 있어요!
