유니티 화면 일시정지 기능 (Unity Pause)

농담고미고미·2024년 5월 29일

Unity 개발 일지

목록 보기
5/26

내가 원하는 기능

  • Game Over 되면 Game Over Panel이 뜬다.
  • 그럼 게임이 일시정지되면서, 이번판 Score가 떠야한다.
  • 또 메인버튼을 누르면 시작화면으로, 리플레이버튼을 누르면 게임이 다시 시작돼야한다.
  • 목숨은 0개에서 다시 3개로 돌아와야한다.

게임 정지 + 이번판 Score 기능

PlayerManager script 수정

using UnityEngine.SceneManagement;
using UnityEngine;
using UnityEngine.UI;

public class PlayerManager : MonoBehaviour
{
    public static bool isGameOver;
    public GameObject gameOverScreen;
    public Text scoreText1;

    private void Awake()
    {
        isGameOver = false;
    }
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (isGameOver)
        {
            gameOverScreen.SetActive(true);
            ***Time.timeScale = 0;
            scoreText1.text = "점수 :           " + ScoreManager.scoreCount;***
        }
    }
}

GameOverPanel에 들어가서 ScoreText1에 게임 오브젝트 ScoreText1을 드롭한다. 게임 오브젝트 PlayerManager에 들어가서도 ScoreText1에 게임 오브젝트 ScoreText1을 드롭한다.

이번판 점수가 잘 뜬다 ^^

profile
농담곰을 좋아해요 말랑곰탱이

0개의 댓글