-
[Unity]GameOver Scene만들기Unity/게임 만들어보기 기록장 2022. 10. 23. 19:15728x90
1. 새로운 Scene를 만든 후 Panel 을 만들어 줍니다
2. Panel에 이미지를 넣어 줍니다.
3. Text도 넣어줍니다.
4. scene를 추가해줍니다.
5. 만든 script의 replay를 넣어줍니다
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class BirdJump : MonoBehaviour { Rigidbody2D rb; public float jumpPower; // Start is called before the first frame update void Start() { rb = GetComponent<Rigidbody2D>(); } // Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { rb.velocity = Vector2.up * jumpPower; //(0,3) } } //충돌시 게임오버 private void OnCollisionEnter2D(Collision2D other) { SceneManager.LoadScene("GameOverScene"); } }
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class Replay : MonoBehaviour { public void ReplayGame(){ SceneManager.LoadScene("PlayScene"); } }
728x90'Unity > 게임 만들어보기 기록장' 카테고리의 다른 글
[Unity] 너무 높게나는거 방지하기 (0) 2022.10.24 [Unity] Score 초기화 및 Best Score (0) 2022.10.24 [Unity] Score 스크립트 만들기 (0) 2022.10.22 [Unity] Prefab을 이용하여 파이프 만들기 (0) 2022.10.22 [Unity] 점프 기능 구현 (0) 2022.10.21