커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
retry 버튼을 눌러도 동작하지 않습니다 -_ ㅠ
게임개발 종합반 v0
2주차
북마크
김*원
댓글
11
추천
0
조회수
33
조회수
33
답변 완료

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

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


retry 버튼을 눌러도 작동하지 않아요



스파르타 즉문즉답




작성한 코드 및 에러 메세지


Retry script

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


public class RetryButton : MonoBehaviour
{
    public void Retry()
    {
        SceneManager.LoadScene("MainScene");
    }
   
}


Gamamanager script

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


public class GameManager : MonoBehaviour
{
    public static GameManager Instance; //싱글톤


    public GameObject square;
    public Text timeTxt; //unityengine.ui 필요
    public GameObject EndPanel;
    public Text NowScore;


    bool isPlay = true;


    float time = 0.0f;




    private void Awake() //싱클톤
    {
        if(Instance == null)
        {
            Instance = this;
        }
    }


    // Start is called before the first frame update
    void Start()
    {
        Time.timeScale = 1.0f;
        InvokeRepeating("MakeSquare",0f,1);
        //반복 생성은 InvokeRepeating 
        //그 안에 함수 만들어 넣어주고 
        //바로 실행은 0f
        //주기는 1초마다
    }


    // Update is called once per frame
    void Update()
    {
        if (isPlay)
        {
            time += Time.deltaTime;
            timeTxt.text = time.ToString("N2"); //숫자이기 때문에 스트링으로 변환, 소숫점 2째자리 N2
        }
       
    }


    void MakeSquare()
    {
        Instantiate(square);
        // public GameObject square; 로 변수 선언해주고 
        // instantiate 로 스퀘어 프리펩 가져옴. 
    }


    public void GameOver()
    {
        //게임을 끝내고 endpanel을 켜야함
        isPlay = false;


        Time.timeScale = 0f; //타임 크기를 0으로 하면 멈춤. (기본은 1)
        NowScore.text = time.ToString("N2");
        EndPanel.SetActive(true);


        //
        


    }


}


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