커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
스스로 해결
1-10(게임 끝내기)에서 패널을 클릭해도 초기화가 되지 않습니다.
게임개발 종합반 v8
1주차
북마크
신*지
댓글
4
추천
1
조회수
25
조회수
25
스스로 해결



안녕하세요~ 1주차 10번째 강의, 게임 끝내기 편을 학습하다 오류가 생겨 질문을 남깁니다.

강의대로 모든 절차를 밟고, on click에도 Panel 을 드래그 앤 드롭으로 연동해두었으나 Main Scene이 제대로 초기화되지 않네요.

혹시 코드 내 Main Scene의 띄어쓰기가 문제일까 싶어, MainScene과 Main Scene 양쪽 모두 실험해보았지만 그대로였습니다.


스파르타 즉문즉답스파르타 즉문즉답스파르타 즉문즉답



작성한 코드 및 에러 메세지



게임 매니저의 코드입니다.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;


public class GameManager : MonoBehaviour
{
    public GameObject Rain;
    public static GameManager I;
    public Text scoreText;
    public Text timeText;
    public GameObject panel;
    int totalScore;
    float limit = 10f;
    


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


패널(버튼)의 코드입니다.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class panel : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }


    // Update is called once per frame
    void Update()
    {
        
    }
    public void retry()
    {
        GameManager.I.retry();
    }
}



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