using System.Collections; using System.Collections.Generic; using UnityEngine; public class showGameOverScreen : MonoBehaviour { public void replay() { //(1)錯誤做法:把this.gameObject隱藏(結果,不會重新開始) //隱藏目前這個物件(背景圖) //gameObject.SetActive(false); //(2)正確做法 SceneManager.LoadScene("SampleScene"); } public void myquit() { Application.Quit(); } void Start() { } // Update is called once per frame void Update() { if(Input.GetKeyDown(KeyCode.R)) { //隱藏目前這個物件(背景圖) gameObject.SetActive(false); } else if(Input.GetKeyDown(KeyCode.Q)) { Application.Quit(); } } }